Add packages/edo for Equal Division of the Octave scales
This commit is contained in:
parent
db413881db
commit
73965a3a39
12 changed files with 764 additions and 0 deletions
34
packages/edo/test/edo.test.mjs
Normal file
34
packages/edo/test/edo.test.mjs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
edo.test.mjs - tests of edo.mjs
|
||||
Copyright (C) 2025 Rob McKinnon and Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/tonal/test/tonal.test.mjs>
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import '../edo.mjs';
|
||||
import { n } from '@strudel/core';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
describe('edoScale', () => {
|
||||
it('Should run tonal functions ', () => {
|
||||
// base note A3 = 220Hz
|
||||
let baseNote = 'A3';
|
||||
let root = 220;
|
||||
let freq = 220;
|
||||
let pattern = n('0').edoScale([baseNote, 'LLsLLLs', 2, 1]);
|
||||
let cycle = pattern.firstCycleValues[0];
|
||||
expect(cycle.freq).toEqual(freq);
|
||||
expect(cycle.edo).toEqual(12);
|
||||
expect(cycle.degree).toEqual(1);
|
||||
expect(parseFloat(cycle.root).toFixed(0)).toEqual(root.toFixed(0));
|
||||
|
||||
// base note A4 = 440Hz
|
||||
baseNote = 'A4';
|
||||
root = 440;
|
||||
freq = 880;
|
||||
pattern = n('7').edoScale([baseNote, 'LLsLLLs', 2, 1]);
|
||||
cycle = pattern.firstCycleValues[0];
|
||||
expect(cycle.freq).toEqual(freq);
|
||||
expect(cycle.edo).toEqual(12);
|
||||
expect(cycle.degree).toEqual(1);
|
||||
expect(parseFloat(cycle.root).toFixed(0)).toEqual(root.toFixed(0));
|
||||
});
|
||||
});
|
||||
21
packages/edo/test/edoscale.test.mjs
Normal file
21
packages/edo/test/edoscale.test.mjs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
edoscale.test.mjs - tests of EdoScale from edoscale.mjs
|
||||
Copyright (C) 2025 Rob McKinnon and Strudel contributors - see <https://codeberg.org/uzu/strudel/src/branch/main/packages/edo/test/edoscale.test.mjs>
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import '../edoscale.mjs'; // need to import this to add prototypes
|
||||
import { EdoScale } from '../edoscale.mjs';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
describe('EdoScale', () => {
|
||||
it('updates edivisions', () => {
|
||||
let scale = new EdoScale(2, 1, ['L', 'L', 's', 'L', 'L', 'L', 's']);
|
||||
expect(scale.stepSize(0)).toEqual('L');
|
||||
expect(scale.stepValue(0)).toEqual(2);
|
||||
|
||||
expect(scale.stepSize(2)).toEqual('s');
|
||||
expect(scale.stepValue(2)).toEqual(1);
|
||||
|
||||
expect(scale.edivisions).toEqual(12);
|
||||
});
|
||||
});
|
||||
18
packages/edo/test/ratios.test.mjs
Normal file
18
packages/edo/test/ratios.test.mjs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
ratios.test.mjs - tests of ratios.mjs
|
||||
Copyright (C) 2025 Rob McKinnon and Strudel contributors - see <https://codeberg.org/uzu/strudel/src/branch/main/packages/edo/test/ratios.test.mjs>
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import ratiointervals from '../ratios.mjs';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
describe('ratiointervals', () => {
|
||||
it('updates edivisions', () => {
|
||||
let ratio = 9 / 7;
|
||||
expect(ratiointervals.key(ratio)).toEqual('S3');
|
||||
expect(ratiointervals.label(ratio)).toEqual('M3');
|
||||
expect(ratiointervals.fjs(ratio)).toEqual('M3_7');
|
||||
expect(ratiointervals.nom(ratio)).toEqual(9);
|
||||
expect(ratiointervals.denom(ratio)).toEqual(7);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue