mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-24 12:08:28 +00:00
can now set mode and anchor on voicing dictionary
This commit is contained in:
parent
4cf3655c08
commit
d8f80c058d
@ -90,7 +90,7 @@ let modeTarget = {
|
|||||||
above: (v) => v[0],
|
above: (v) => v[0],
|
||||||
};
|
};
|
||||||
|
|
||||||
export function renderVoicing({ chord, dictionary, offset = 0, n, mode = 'above', anchor = 'c4' }) {
|
export function renderVoicing({ chord, dictionary, offset = 0, n, mode = 'below', anchor = 'c5' }) {
|
||||||
const [root, symbol] = tokenizeChord(chord);
|
const [root, symbol] = tokenizeChord(chord);
|
||||||
const rootChroma = pc2chroma(root);
|
const rootChroma = pc2chroma(root);
|
||||||
anchor = anchor?.note || anchor;
|
anchor = anchor?.note || anchor;
|
||||||
|
|||||||
@ -51,9 +51,9 @@ const triads = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const voicingRegistry = {
|
export const voicingRegistry = {
|
||||||
lefthand: { dictionary: lefthand, range: ['F3', 'A4'] },
|
lefthand: { dictionary: lefthand, range: ['F3', 'A4'], mode: 'below', anchor: 'c5' },
|
||||||
triads: { dictionary: triads },
|
triads: { dictionary: triads, mode: 'below', anchor: 'c5' },
|
||||||
guidetones: { dictionary: guidetones },
|
guidetones: { dictionary: guidetones, mode: 'above', anchor: 'g4' },
|
||||||
};
|
};
|
||||||
export const setVoicingRange = (name, range) => addVoicings(name, voicingRegistry[name].dictionary, range);
|
export const setVoicingRange = (name, range) => addVoicings(name, voicingRegistry[name].dictionary, range);
|
||||||
|
|
||||||
@ -78,8 +78,8 @@ export const setVoicingRange = (name, range) => addVoicings(name, voicingRegistr
|
|||||||
* }, ['C3', 'C6'])
|
* }, ['C3', 'C6'])
|
||||||
* "<C^7 A7 Dm7 G7>".voicings('cookie').note()
|
* "<C^7 A7 Dm7 G7>".voicings('cookie').note()
|
||||||
*/
|
*/
|
||||||
export const addVoicings = (name, dictionary, range = ['F3', 'A4']) => {
|
export const addVoicings = (name, dictionary, options = {}) => {
|
||||||
Object.assign(voicingRegistry, { [name]: { dictionary, range } });
|
Object.assign(voicingRegistry, { [name]: { dictionary, ...options } });
|
||||||
};
|
};
|
||||||
|
|
||||||
const getVoicing = (chord, dictionaryName, lastVoicing) => {
|
const getVoicing = (chord, dictionaryName, lastVoicing) => {
|
||||||
@ -141,9 +141,9 @@ export const voicing = register('voicing', function (pat) {
|
|||||||
.fmap((value) => {
|
.fmap((value) => {
|
||||||
let { dictionary, ...rest } = value;
|
let { dictionary, ...rest } = value;
|
||||||
if (typeof dictionary === 'string') {
|
if (typeof dictionary === 'string') {
|
||||||
dictionary = voicingRegistry[dictionary]?.dictionary;
|
dictionary = voicingRegistry[dictionary];
|
||||||
}
|
}
|
||||||
let notes = renderVoicing({ ...value, dictionary });
|
let notes = renderVoicing({ ...dictionary, ...rest });
|
||||||
|
|
||||||
return stack(...notes)
|
return stack(...notes)
|
||||||
.note()
|
.note()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user