From 18e73395f95ef637894bb89435ef165d60996807 Mon Sep 17 00:00:00 2001 From: Lumi Pakkanen Date: Thu, 21 Dec 2023 10:05:49 +0200 Subject: [PATCH] Don't rely on formatting options to determine monzo type in rank-2 --- src/__tests__/scale.spec.ts | 11 +++++++++++ src/scale.ts | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/__tests__/scale.spec.ts b/src/__tests__/scale.spec.ts index b88aac4..bda1536 100644 --- a/src/__tests__/scale.spec.ts +++ b/src/__tests__/scale.spec.ts @@ -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( diff --git a/src/scale.ts b/src/scale.ts index 1acddbb..c438feb 100644 --- a/src/scale.ts +++ b/src/scale.ts @@ -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,