Merge pull request #502 from tidalcycles/scale-space-alternative

can now use : as a replacement for space in scales
This commit is contained in:
Felix Roos 2023-03-03 12:40:23 +01:00 committed by GitHub
commit 4bfeaa47bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -30,4 +30,11 @@ describe('tonal', () => {
.firstCycleValues.map((h) => h.note),
).toEqual(['C3', 'D3', 'E3']);
});
it('scale with colon', () => {
expect(
n(0, 1, 2)
.scale('C:major')
.firstCycleValues.map((h) => h.note),
).toEqual(['C3', 'D3', 'E3']);
});
});

View File

@ -146,6 +146,7 @@ export const scale = register('scale', function (scale /* : string */, pat) {
let note = isObject ? hap.value.n : hap.value;
const asNumber = Number(note);
if (!isNaN(asNumber)) {
scale = scale.replaceAll(':', ' ');
let [tonic, scaleName] = Scale.tokenize(scale);
const { pc, oct = 3 } = Note.get(tonic);
note = scaleOffset(pc + ' ' + scaleName, asNumber, pc + oct);