Skip to content

Commit

Permalink
beam 4 1/8 in duple time.
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronDavidNewman committed May 26, 2024
1 parent e6dae19 commit d0d7050
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/smo/data/score.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ export class SmoScore {
if (!this.formattingManager) {
this.formattingManager = new SmoFormattingManager(SmoFormattingManager.defaults);
}
// Set beaming rules based on preferences.
const pref = this.preferences;
SmoMeasure.defaultDupleDuration = pref.defaultDupleDuration;
SmoMeasure.defaultTripleDuration = pref.defaultTripleDuration;
if (this.staves.length) {
this.numberStaves();
}
Expand Down
18 changes: 17 additions & 1 deletion src/smo/xform/beamers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ export class SmoBeamer {
}
return false;
}
allEighth() {
for (var i = 0; i < this.currentGroup.length; ++i) {
const cg = this.currentGroup[i];
if (cg.tickCount !== 2048) {
return false;
}
}
return true;
}
beamNote(tickmap: TickMap, index: number, note: SmoNote) {
this.beamBeats = note.beamBeats;
this.duration += tickmap.deltaMap[index];
Expand All @@ -151,7 +160,6 @@ export class SmoBeamer {
this._advanceGroup();
return;
}

// is this beamable length-wise
const stemTicks = SmoMusic.closestDurationTickLtEq(note.tickCount) * tuplet.durationMap[tupletIndex];
if (note.noteType === 'n' && stemTicks < 4096) {
Expand All @@ -177,6 +185,14 @@ export class SmoBeamer {
this._completeGroup(tickmap.voice);
this._advanceGroup();
}
if (this.measure.timeSignature.actualBeats % 4 === 0) {
if (this.duration < 8192 && this.allEighth()) {
return;
} else if (this.duration === 8192) {
this._completeGroup(tickmap.voice);
this._advanceGroup();
}
}

if (this.duration === this.beamBeats) {
this._completeGroup(tickmap.voice);
Expand Down

0 comments on commit d0d7050

Please sign in to comment.