scales can now be anchored
This commit is contained in:
parent
f37652edb3
commit
b27f177138
3 changed files with 86 additions and 2 deletions
|
|
@ -6,6 +6,7 @@ This program is free software: you can redistribute it and/or modify it under th
|
|||
|
||||
import { Note, Interval, Scale } from '@tonaljs/tonal';
|
||||
import { register, _mod, silence, logger, pure, isNote } from '@strudel.cycles/core';
|
||||
import { stepInNamedScale } from './tonleiter.mjs';
|
||||
|
||||
const octavesInterval = (octaves) => (octaves <= 0 ? -1 : 1) + octaves * 7 + 'P';
|
||||
|
||||
|
|
@ -184,7 +185,12 @@ export const scale = register('scale', function (scale, pat) {
|
|||
return silence;
|
||||
}
|
||||
try {
|
||||
const note = scaleStep(asNumber, scale);
|
||||
let note;
|
||||
if (value.anchor) {
|
||||
note = stepInNamedScale(asNumber, scale, value.anchor);
|
||||
} else {
|
||||
note = scaleStep(asNumber, scale);
|
||||
}
|
||||
value = pure(isObject ? { ...value, note } : note);
|
||||
} catch (err) {
|
||||
logger(`[tonal] ${err.message}`, 'error');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue