Skip to content

Commit

Permalink
Don't rely on formatting options to determine monzo type in rank-2
Browse files Browse the repository at this point in the history
  • Loading branch information
frostburn committed Dec 21, 2023
1 parent 95e0ba7 commit 18e7339
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/__tests__/scale.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,17 @@ describe('Scale', () => {
expect(intervals[4].totalCents()).toBe(1200);
expect(intervals[4].type).toBe('monzo');
});

it('can generate rank 2 (mixing equal temperament with hard cents)', () => {
const fifth = new Interval(
new ExtendedMonzo([new Fraction('5/14')], undefined, -3),
'equal temperament'
);
const octave = new Interval(ExtendedMonzo.fromFraction(2, 1), 'ratio');
const scale = Scale.fromRank2(fifth, octave, 14, 0);
expect(scale.size).toBe(14);
});

it('can generate harmonic series segment', () => {
const scale = Scale.fromHarmonicSeries(4, 8, 4);
expect(
Expand Down
5 changes: 4 additions & 1 deletion src/scale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ export class Scale {
}
size /= numPeriods;
down /= numPeriods;
if (generator.type === 'equal temperament') {
if (
generator.type === 'equal temperament' &&
generator.monzo.isEqualTemperament()
) {
const [genFraction, genEquave] = generator.monzo.toEqualTemperament();
const options: IntervalOptions = {
preferredEtDenominator: genFraction.d,
Expand Down

0 comments on commit 18e7339

Please sign in to comment.