Merge pull request 'tonal: allow scales without tonic (default to C)' (#1092) from kasparsj/tonal-fix into main

Reviewed-on: https://codeberg.org/uzu/strudel/pulls/1092
This commit is contained in:
froos
2025-06-24 05:53:21 +02:00
2 changed files with 8 additions and 1 deletions
+7
View File
@@ -37,6 +37,13 @@ describe('tonal', () => {
.firstCycleValues.map((h) => h.note),
).toEqual(['C3', 'D3', 'E3']);
});
it('scale without tonic', () => {
expect(
n(0, 1, 2)
.scale('major')
.firstCycleValues.map((h) => h.note),
).toEqual(['C3', 'D3', 'E3']);
});
it('scale with mininotation colon', () => {
expect(
n(0, 1, 2)
+1 -1
View File
@@ -14,7 +14,7 @@ function scaleStep(step, scale) {
scale = scale.replaceAll(':', ' ');
step = Math.ceil(step);
let { intervals, tonic, empty } = Scale.get(scale);
if ((empty && isNote(scale)) || (!empty && !tonic)) {
if ((empty && isNote(scale)) || (empty && !tonic)) {
throw new Error(`incomplete scale. Make sure to use ":" instead of spaces, example: .scale("C:major")`);
} else if (empty) {
throw new Error(`invalid scale "${scale}"`);