From 0fd9ac6da39944db946320ddf51d940745079577 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Thu, 13 Jul 2023 12:13:00 +0200 Subject: [PATCH] feat: support strings in voicing function --- packages/tonal/voicings.mjs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/tonal/voicings.mjs b/packages/tonal/voicings.mjs index dea0fff2..996bbb28 100644 --- a/packages/tonal/voicings.mjs +++ b/packages/tonal/voicings.mjs @@ -178,13 +178,14 @@ export const rootNotes = register('rootNotes', function (octave, pat) { * - `offset`: whole number that shifts the voicing up or down to the next voicing * - `n`: if set, the voicing is played like a scale. Overshooting numbers will be octaved * - * All of the above controls are optional, except `chord` + * All of the above controls are optional, except `chord`. + * If you pass a pattern of strings to voicing, they will be interpreted as chords. * * @name voicing * @param {string} dictionary which voicing dictionary to use. * @returns Pattern * @example - * chord("").voicing() + * voicing("") * @example * n("0 1 2 3 4 5 6 7").chord("").voicing() */ @@ -192,6 +193,7 @@ export const voicing = register('voicing', function (pat) { return pat .fmap((value) => { // destructure voicing controls out + value = typeof value === 'string' ? { chord: value } : value; let { dictionary = 'default', chord, anchor, offset, mode, n, ...rest } = value; dictionary = typeof dictionary === 'string' ? voicingRegistry[dictionary] : { dictionary, mode: 'below', anchor: 'c5' };