Skip to content

Commit

Permalink
Use unrooted sorting when generating rank-2 with generators down
Browse files Browse the repository at this point in the history
  • Loading branch information
frostburn committed Jun 6, 2024
1 parent a2574d7 commit 647a9f9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/__tests__/scale.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,20 @@ describe('Scale', () => {

expect(scale.getMonzo(5).strictEquals(octave.monzo)).toBeTruthy();
});
it('can generate rank 2 (down)', () => {
const fifth = new Interval(
ExtendedMonzo.fromFraction(new Fraction(3, 2), 2),
'ratio'
);
const octave = new Interval(
ExtendedMonzo.fromFraction(new Fraction(2), 3),
'ratio'
);
const scale = Scale.fromRank2(fifth, octave, 7, 1, 1);
expect([...Array(8).keys()].map(i => scale.getCents(i).toFixed(1))).toEqual(
['0.0', '203.9', '407.8', '498.0', '702.0', '905.9', '1109.8', '1200.0']
);
});
it('can generate rank 2 (multiple periods per equave)', () => {
const fifth = new Interval(
ExtendedMonzo.fromFraction(new Fraction(3, 2), 2),
Expand Down
2 changes: 1 addition & 1 deletion src/scale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class Scale {
intervals.push(generator.mul(i - down).mmod(period));
}
const result = new Scale(intervals, period, baseFrequency);
result.sortInPlace();
result.sortInPlace(false);
return result.repeat(numPeriods);
}

Expand Down

0 comments on commit 647a9f9

Please sign in to comment.