Skip to content

Commit

Permalink
Fix beat groups in 6/4, 9/4, 12/4
Browse files Browse the repository at this point in the history
  • Loading branch information
vanderstel committed Sep 1, 2024
1 parent 66adc89 commit ce04483
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion src/meter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,14 @@ export class TimeSignature extends base.Music21Object {
tempBeatGroups.push([1, 1]);
} else {
// 4/4, 2/4, 3/4, standard stuff
tempBeatGroups.push([2, 8]);
if (numBeats % 3 === 0 && numBeats > 3) {
while (numBeats) {
tempBeatGroups.push([3, beatValue]);
numBeats -= 3;
}
} else {
tempBeatGroups.push([2, 8]);
}
}
return tempBeatGroups;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/moduleTests/meter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,10 @@ export default function tests() {
assertBeatGroups('3/4', [[2, 8]]);
assertBeatGroups('4/4', [[2, 8]]);
assertBeatGroups('5/4', [[2, 8]]);
assertBeatGroups('6/4', [[2, 8]]);
assertBeatGroups('6/4', [[3, 4], [3, 4]]);
assertBeatGroups('7/4', [[2, 8]]);
assertBeatGroups('9/4', [[2, 8]]);
assertBeatGroups('12/4', [[2, 8]]);
assertBeatGroups('9/4', [[3, 4], [3, 4], [3, 4]]);
assertBeatGroups('12/4', [[3, 4], [3, 4], [3, 4], [3, 4]]);
assertBeatGroups('2/8', [[1, 8]]);
assertBeatGroups('3/8', [[3, 8]]);
assertBeatGroups('4/8', [[1, 8]]);
Expand Down

0 comments on commit ce04483

Please sign in to comment.