Skip to content

Commit

Permalink
Unify generator search for temperaments of all ranks
Browse files Browse the repository at this point in the history
  • Loading branch information
frostburn committed Jan 31, 2024
1 parent 68601ef commit b69b59c
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 124 deletions.
8 changes: 4 additions & 4 deletions src/__tests__/monzo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ describe('Respeller', () => {
});

it('knows that the major third is 9/7 in pajara', () => {
const third = new Fraction('3/2').div('7/5').pow(4);
const third = new Fraction('3/2').div('7/5').pow(4)!;
const spelling = spell(third, ['50/49', '64/63']);
expect(spelling.minBenedetti.equals('9/7')).toBeTruthy();
expect(spelling.noTwosMinNumerator.equals('32/25')).toBeTruthy();
expect(spelling.noTwosMinDenominator.equals('81/64')).toBeTruthy();
});

it('knows that the minor third is 7/6 is in pajara', () => {
const third = new Fraction('4/3').pow(3).div('10/7').div('10/7');
const third = new Fraction('4/3').pow(3)!.div('10/7').div('10/7');
const spelling = spell(third, ['50/49', '64/63']);
expect(spelling.minBenedetti.equals('7/6')).toBeTruthy();
});

it('knows that the minor third is 6/5 in srutal', () => {
const third = new Fraction('3/2').div('45/32').pow(3);
const third = new Fraction('3/2').div('45/32').pow(3)!;
const spelling = spell(third, ['2048/2025', '4375/4374']);
expect(spelling.minBenedetti.equals('6/5')).toBeTruthy();
});

it('knows that the major third is 5/4 is in srutal', () => {
const third = new Fraction('4/3').pow(2).div('45/32');
const third = new Fraction('4/3').pow(2)!.div('45/32');
const spelling = spell(third, ['2048/2025', '4375/4374']);
expect(spelling.minBenedetti.equals('5/4')).toBeTruthy();
});
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/subgroup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('Fractional just intonation subgroup', () => {
expect(monzo[2]).toBe(1);
expect(
new Fraction(2)
.pow(monzo[0])
.pow(monzo[0])!
.mul(9 ** monzo[1])
.mul(5 ** monzo[2])
.equals(new Fraction(45, 32))
Expand All @@ -94,7 +94,7 @@ describe('Fractional just intonation subgroup', () => {
expect(arraysEqual(password, [6, -5, 0, 1])).toBeTruthy();
expect(
new Fraction(19, 5)
.pow(password[3])
.pow(password[3])!
.div(3 ** -password[1])
.mul(2 ** password[0])
.equals(new Fraction(1216, 1215))
Expand All @@ -105,7 +105,7 @@ describe('Fractional just intonation subgroup', () => {
expect(arraysEqual(island, [2, -3, 2, 0])).toBeTruthy();
expect(
new Fraction(13, 5)
.pow(island[2])
.pow(island[2])!
.div(3 ** -island[1])
.mul(2 ** island[0])
.equals(new Fraction(676, 675))
Expand Down
80 changes: 54 additions & 26 deletions src/__tests__/temperament.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ describe('Temperament', () => {
const monzo = [-5, 0, 7, -4, 0, 0, 0];
const subgroup = new Subgroup('2.5.7');
const temperament = Temperament.fromCommas([monzo], subgroup, true);
const [period, generator] = temperament.periodGenerator({
const [period, generator] = temperament.periodGenerators({
temperEquaves: true,
});
expect(period).toBeCloseTo(1200.3479);
Expand Down Expand Up @@ -368,7 +368,7 @@ describe('Temperament', () => {
it('can figure out the period and a generator for meantone', () => {
const syntonicComma = toMonzo(new Fraction(81, 80));
const temperament = Temperament.fromCommas([syntonicComma]);
const [numPeriods, generator] = temperament.numPeriodsGenerator();
const [numPeriods, [generator]] = temperament.numPeriodsGenerators();

expect(numPeriods).toBe(1);
expect(generator.length).toBe(3);
Expand All @@ -383,7 +383,7 @@ describe('Temperament', () => {
it('can figure out the period and a generator for orgone', () => {
const orgonisma = toMonzo(new Fraction(65536, 65219));
const temperament = Temperament.fromCommas([orgonisma]);
const [period, generator] = temperament.periodGenerator();
const [period, generator] = temperament.periodGenerators();

expect(period).toBeCloseTo(1200);
const poteGenerator = 323.372;
Expand All @@ -394,7 +394,7 @@ describe('Temperament', () => {
const limma = toMonzoAndResidual(new Fraction(256, 243), 3)[0];
const subgroup = new Subgroup(5);
const temperament = Temperament.fromCommas([limma], subgroup);
const [period, generator] = temperament.periodGenerator();
const [period, generator] = temperament.periodGenerators();

expect(period).toBeCloseTo(240);
const poteGenerator = 399.594;
Expand All @@ -405,7 +405,7 @@ describe('Temperament', () => {
const diesis = toMonzo(new Fraction(128, 125));
const subgroup = new Subgroup(5);
const temperament = Temperament.fromCommas([diesis], subgroup);
const [period, generator] = temperament.periodGenerator();
const [period, generator] = temperament.periodGenerators();

expect(period).toBeCloseTo(400);
const poteGenerator = 706.638;
Expand All @@ -414,7 +414,7 @@ describe('Temperament', () => {

it('can figure out the period and a generator for miracle', () => {
const temperament = Temperament.fromCommas(['225/224', '1029/1024']);
const [period, generator] = temperament.periodGenerator();
const [period, generator] = temperament.periodGenerators();

expect(period).toBeCloseTo(1200);
const poteGenerator = 116.675;
Expand All @@ -423,15 +423,15 @@ describe('Temperament', () => {

it('can figure out the generators of whitewood', () => {
const temperament = Temperament.fromCommas(['2187/2048'], 5);
const generators = temperament.generators();
const [period, generator] = temperament.periodGenerators();

expect(generators[0]).toBeCloseTo(1200 / 7);
expect(generators[1]).toBeCloseTo(mmod(374.469, 1200 / 7));
expect(period).toBeCloseTo(1200 / 7);
expect(generator).toBeCloseTo(mmod(374.469, 1200 / 7));
});

it('can figure out the generators of kleismic', () => {
const temperament = Temperament.fromCommas(['15625/15552'], 7);
const generators = temperament.generators();
const generators = temperament.periodGenerators();

const mapping = temperament.getMapping();

Expand All @@ -442,32 +442,32 @@ describe('Temperament', () => {

it('can figure out the generators of manwe', () => {
const temperament = Temperament.fromCommas(['176/175', '1331/1323']);
const generators = temperament.generators();
const generators = temperament.periodGenerators();

const mapping = temperament.getMapping();

expect(generators[0]).toBeCloseTo(mapping[0]);
expect(generators[1]).toBeCloseTo(mmod(-mapping[1], 1200));
expect(generators[2]).toBeCloseTo(mmod(mapping[2], 1200));
expect(generators[1]).toBeCloseTo(mmod(mapping[2], 1200));
expect(generators[2]).toBeCloseTo(mmod(-mapping[1], 1200));
});

it('can figure out the generators of kalismic', () => {
const temperament = Temperament.fromCommas(['9801/9800']);
const generators = temperament.generators();
const generators = temperament.periodGenerators();

const mapping = temperament.getMapping();

expect(generators[0]).toBeCloseTo(600);
expect(generators[0]).toBeCloseTo(temperament.tune('99/70'));
expect(generators[1]).toBeCloseTo(mmod(mapping[1], 600));
expect(generators[2]).toBeCloseTo(mmod(-mapping[2], 600));
expect(generators[3]).toBeCloseTo(mmod(-mapping[4], 600));
expect(generators[1]).toBeCloseTo(mmod(-mapping[4], 600));
expect(generators[2]).toBeCloseTo(mmod(mapping[1], 600));
expect(generators[3]).toBeCloseTo(mmod(-mapping[2], 600));
});

it('can figure out the generators of xeimtionic', () => {
const temperament = Temperament.fromCommas(['625/616']);

const generators = temperament.generators();
const generators = temperament.periodGenerators();
const mapping = temperament.getMapping();

expect(generators[0]).toBeCloseTo(1200);
Expand All @@ -477,22 +477,50 @@ describe('Temperament', () => {

it('can figure out the generators of rank-2 xeimtionic', () => {
const temperament = Temperament.fromCommas(['245/242', '625/616']);
const generators = temperament.generators();
const periodGenerator = temperament.periodGenerator();

expect(generators[1]).toBeCloseTo(periodGenerator[1]);
const generators = temperament.periodGenerators();
expect(generators[0]).toBeCloseTo(1200);
expect(generators[1]).toBeCloseTo(204.958);
});

it('can figure out the generators of frostmic', () => {
const temperament = Temperament.fromCommas(['245/242']);
const generators = temperament.generators();
const generators = temperament.periodGenerators();
const mapping = temperament.getMapping();

expect(generators[0]).toBeCloseTo(1200);
expect(generators[1]).toBeCloseTo(mmod(-mapping[2], 1200));
expect(generators[2]).toBeCloseTo(mmod(mapping[3], 1200));
});

it('can figure out the generators of altierran', () => {
const temperament = Temperament.fromCommas([
'32805/32768',
'161280/161051',
]);
const generators = temperament.periodGenerators();
const mapping = temperament.getMapping();

expect(generators[0]).toBeCloseTo(1200);
expect(generators[1]).toBeCloseTo(mmod(-mapping[1], 1200));
expect(generators[2]).toBeCloseTo(mmod(mapping[4], 1200));
});

it('can figure out the generators of tenierian', () => {
const temperament = Temperament.fromCommas([
'10985/10976',
'32805/32768',
'161280/161051',
]);
const generators = temperament.periodGenerators();
const mapping = temperament.getMapping();

expect(generators[0]).toBeCloseTo(1200);
expect(generators[1]).toBeCloseTo(mmod(-mapping[3], 1200));
expect(generators[2]).toBeCloseTo(
mmod(13 * mapping[1] + 13 * mapping[4] + mapping[5], 1200)
);
});

it('can recover semaphore from its prefix', () => {
const diesis = toMonzo(new Fraction(49, 48));
const temperament = Temperament.fromCommas([diesis]);
Expand Down Expand Up @@ -557,7 +585,7 @@ describe('Temperament', () => {
);
const pinkan = temperament.getMapping();

const [d, g] = temperament.numPeriodsGenerator();
const [d, [g]] = temperament.numPeriodsGenerators();

const semifourth = subgroup.toMonzoAndResidual(new Fraction(15, 13))[0];
const octave = [1, 0, 0, 0];
Expand Down Expand Up @@ -783,7 +811,7 @@ describe('Free Temperament', () => {

const barbados = temperament.getMapping({units: 'nats'});

const [period, generator] = temperament.periodGenerator();
const [period, generator] = temperament.periodGenerators();

temperament.canonize();
const prefix = temperament.rankPrefix(2);
Expand Down Expand Up @@ -820,7 +848,7 @@ describe('Free Temperament', () => {
);
const pinkan = temperament.getMapping();

const [d, g] = temperament.numPeriodsGenerator();
const [d, [g]] = temperament.numPeriodsGenerators();

const semifourth_ = toMonzo(new Fraction(15, 13));
const semifourth = [semifourth_[0], semifourth_[1], semifourth_[5], 0];
Expand Down
Loading

0 comments on commit b69b59c

Please sign in to comment.