Skip to content

Commit 209489f

Browse files
committed
feat(rhythm): add support for 1/4 time with >6 spans line flag beam
1 parent c0bdecd commit 209489f

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

internal/rhythm/lines.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ func splitBeam(ctx context.Context, ts timesig.TimeSignature, notes []*entity.No
458458
notes[segment.StartIndex+2].UpdateBeam(1, musicxml.NoteBeamTypeEnd)
459459
notes[segment.StartIndex+3].UpdateBeam(1, musicxml.NoteBeamTypeBegin)
460460
case 6:
461-
currTs := ts.GetTimesignatureOnMeasure(ctx, segment.StartIndex)
461+
currTs := ts.GetTimesignatureOnMeasure(ctx, notes[segment.StartIndex].MeasureNumber)
462462
if currTs.BeatType == 4 {
463463
// split 2x2x2
464464
notes[segment.StartIndex+1].UpdateBeam(1, musicxml.NoteBeamTypeEnd)
@@ -470,6 +470,19 @@ func splitBeam(ctx context.Context, ts timesig.TimeSignature, notes []*entity.No
470470
notes[segment.StartIndex+2].UpdateBeam(1, musicxml.NoteBeamTypeEnd)
471471
notes[segment.StartIndex+3].UpdateBeam(1, musicxml.NoteBeamTypeBegin)
472472
}
473+
default:
474+
currTs := ts.GetTimesignatureOnMeasure(ctx, notes[segment.StartIndex].MeasureNumber)
475+
476+
if diff > 6 && currTs.Beat == 1 && currTs.BeatType == 4 {
477+
if diff%2 == 0 {
478+
// split by 2
479+
for n := 1; n <= diff; n = n + 2 {
480+
notes[segment.StartIndex+n].UpdateBeam(1, musicxml.NoteBeamTypeEnd)
481+
notes[segment.StartIndex+n+1].UpdateBeam(1, musicxml.NoteBeamTypeBegin)
482+
}
483+
}
484+
485+
}
473486
}
474487
}
475488

0 commit comments

Comments
 (0)