diff --git a/packages/core/controls.mjs b/packages/core/controls.mjs index a3ca638aa..e317af357 100644 --- a/packages/core/controls.mjs +++ b/packages/core/controls.mjs @@ -1750,17 +1750,64 @@ export const { semitone } = registerControl('semitone'); // TODO: synth param export const { voice } = registerControl('voice'); // voicings // https://codeberg.org/uzu/strudel/issues/506 -// chord to voice, like C Eb Fm7 G7. the symbols can be defined via addVoicings +/** + * The chord to voice + * @name chord + * @param {string | Pattern} symbols chord symbols to voice e.g., C, Eb, Fm7, G7. The symbols can be defined via addVoicings + * @example + * chord("").voicing() + **/ export const { chord } = registerControl('chord'); -// which dictionary to use for the voicings +/** + * Which dictionary to use for the voicings. This falls back to the default dictionary if not provided + * + * @name dictionary + * @param {string} dictionaryName which dictionary (having been defined with `addVoicings`) to use + * @example + * addVoicings('house', { +'': ['7 12 16', '0 7 16', '4 7 12'], +'m': ['0 3 7'] +}) +chord("") +.dict('house').anchor(66) +.voicing().room(.5) + **/ export const { dictionary, dict } = registerControl('dictionary', 'dict'); -// the top note to align the voicing to, defaults to c5 +/** The top note to align the voicing to. Defaults to c5 + * + * @name anchor + * @param {string | Pattern} anchorNote the note to align the voicings to + * @example + * anchor("").chord("C").voicing() + **/ export const { anchor } = registerControl('anchor'); -// how the voicing is offset from the anchored position +/** + * Sets how the voicing is offset from the anchored position + * + * @name offset + * @param {number | Pattern} shift the amount to shift the voicing up or down + * @example + * chord("").offset("<0 1 2 3 4 5>") // alter the voicing each time + **/ export const { offset } = registerControl('offset'); -// how many octaves are voicing steps spread apart, defaults to 1 +/** + * How many octaves are voicing steps spread apart, defaults to 1 + * + * @name octaves + * @param {number | Pattern} count the number of octaves + * @example + * chord("").octaves("<2 4>").voicing() + **/ export const { octaves } = registerControl('octaves'); -// below = anchor note will be removed from the voicing, useful for melody harmonization +/** + * Remove anchor note from the voicing. Useful for melody harmonization + * + * @name mode + * @param {string | Pattern} modeName one of {below | above | duck | root} + * @example + * mode("").chord("C").voicing() + * + **/ export const { mode } = registerControl(['mode', 'anchor']); /** diff --git a/test/__snapshots__/examples.test.mjs.snap b/test/__snapshots__/examples.test.mjs.snap index a27c5a6bc..00da4f48f 100644 --- a/test/__snapshots__/examples.test.mjs.snap +++ b/test/__snapshots__/examples.test.mjs.snap @@ -840,6 +840,31 @@ exports[`runs examples > example "amp" example index 0 1`] = ` ] `; +exports[`runs examples > example "anchor" example index 0 1`] = ` +[ + "[ 0/1 → 1/1 | note:E2 ]", + "[ 0/1 → 1/1 | note:C3 ]", + "[ 0/1 → 1/1 | note:E3 ]", + "[ 0/1 → 1/1 | note:G3 ]", + "[ 0/1 → 1/1 | note:C4 ]", + "[ 1/1 → 2/1 | note:C3 ]", + "[ 1/1 → 2/1 | note:G3 ]", + "[ 1/1 → 2/1 | note:C4 ]", + "[ 1/1 → 2/1 | note:E4 ]", + "[ 1/1 → 2/1 | note:G4 ]", + "[ 2/1 → 3/1 | note:E3 ]", + "[ 2/1 → 3/1 | note:C4 ]", + "[ 2/1 → 3/1 | note:E4 ]", + "[ 2/1 → 3/1 | note:G4 ]", + "[ 2/1 → 3/1 | note:C5 ]", + "[ 3/1 → 4/1 | note:C4 ]", + "[ 3/1 → 4/1 | note:G4 ]", + "[ 3/1 → 4/1 | note:C5 ]", + "[ 3/1 → 4/1 | note:E5 ]", + "[ 3/1 → 4/1 | note:G5 ]", +] +`; + exports[`runs examples > example "apply" example index 0 1`] = ` [ "[ 0/1 → 1/1 | note:C3 ]", @@ -1847,6 +1872,31 @@ exports[`runs examples > example "chop" example index 0 1`] = ` ] `; +exports[`runs examples > example "chord" example index 0 1`] = ` +[ + "[ 0/1 → 1/1 | note:A3 ]", + "[ 0/1 → 1/1 | note:C4 ]", + "[ 0/1 → 1/1 | note:E4 ]", + "[ 0/1 → 1/1 | note:A4 ]", + "[ 0/1 → 1/1 | note:C5 ]", + "[ 1/1 → 2/1 | note:E3 ]", + "[ 1/1 → 2/1 | note:C4 ]", + "[ 1/1 → 2/1 | note:E4 ]", + "[ 1/1 → 2/1 | note:G4 ]", + "[ 1/1 → 2/1 | note:C5 ]", + "[ 2/1 → 3/1 | note:D3 ]", + "[ 2/1 → 3/1 | note:A3 ]", + "[ 2/1 → 3/1 | note:D4 ]", + "[ 2/1 → 3/1 | note:Gb4 ]", + "[ 2/1 → 3/1 | note:A4 ]", + "[ 3/1 → 4/1 | note:F3 ]", + "[ 3/1 → 4/1 | note:C4 ]", + "[ 3/1 → 4/1 | note:F4 ]", + "[ 3/1 → 4/1 | note:A4 ]", + "[ 3/1 → 4/1 | note:C5 ]", +] +`; + exports[`runs examples > example "chorus" example index 0 1`] = ` [ "[ 0/1 → 1/4 | note:d s:sawtooth chorus:0.5 ]", @@ -2739,6 +2789,23 @@ exports[`runs examples > example "detune" example index 0 1`] = ` ] `; +exports[`runs examples > example "dictionary" example index 0 1`] = ` +[ + "[ 0/1 → 1/1 | note:A3 room:0.5 ]", + "[ 0/1 → 1/1 | note:C4 room:0.5 ]", + "[ 0/1 → 1/1 | note:E4 room:0.5 ]", + "[ 1/1 → 2/1 | note:G3 room:0.5 ]", + "[ 1/1 → 2/1 | note:C4 room:0.5 ]", + "[ 1/1 → 2/1 | note:E4 room:0.5 ]", + "[ 2/1 → 3/1 | note:A3 room:0.5 ]", + "[ 2/1 → 3/1 | note:D4 room:0.5 ]", + "[ 2/1 → 3/1 | note:Gb4 room:0.5 ]", + "[ 3/1 → 4/1 | note:A3 room:0.5 ]", + "[ 3/1 → 4/1 | note:C4 room:0.5 ]", + "[ 3/1 → 4/1 | note:F4 room:0.5 ]", +] +`; + exports[`runs examples > example "distort" example index 0 1`] = ` [ "[ 0/1 → 1/8 | s:hh distort:0 ]", @@ -6496,6 +6563,28 @@ exports[`runs examples > example "miditouch" example index 0 1`] = ` ] `; +exports[`runs examples > example "mode" example index 0 1`] = ` +[ + "[ 0/1 → 1/1 | note:E3 ]", + "[ 0/1 → 1/1 | note:C4 ]", + "[ 0/1 → 1/1 | note:E4 ]", + "[ 0/1 → 1/1 | note:G4 ]", + "[ 0/1 → 1/1 | note:C5 ]", + "[ 1/1 → 2/1 | note:C5 ]", + "[ 1/1 → 2/1 | note:G5 ]", + "[ 1/1 → 2/1 | note:C6 ]", + "[ 1/1 → 2/1 | note:E6 ]", + "[ 2/1 → 3/1 | note:E3 ]", + "[ 2/1 → 3/1 | note:C4 ]", + "[ 2/1 → 3/1 | note:E4 ]", + "[ 2/1 → 3/1 | note:G4 ]", + "[ 3/1 → 4/1 | note:C5 ]", + "[ 3/1 → 4/1 | note:G5 ]", + "[ 3/1 → 4/1 | note:C6 ]", + "[ 3/1 → 4/1 | note:E6 ]", +] +`; + exports[`runs examples > example "morph" example index 0 1`] = ` [ "[ 0/1 → 1/8 | s:hh ]", @@ -6814,6 +6903,31 @@ exports[`runs examples > example "octave" example index 0 1`] = ` ] `; +exports[`runs examples > example "octaves" example index 0 1`] = ` +[ + "[ 0/1 → 1/1 | note:A3 ]", + "[ 0/1 → 1/1 | note:C4 ]", + "[ 0/1 → 1/1 | note:E4 ]", + "[ 0/1 → 1/1 | note:A4 ]", + "[ 0/1 → 1/1 | note:C5 ]", + "[ 1/1 → 2/1 | note:E3 ]", + "[ 1/1 → 2/1 | note:C4 ]", + "[ 1/1 → 2/1 | note:E4 ]", + "[ 1/1 → 2/1 | note:G4 ]", + "[ 1/1 → 2/1 | note:C5 ]", + "[ 2/1 → 3/1 | note:D3 ]", + "[ 2/1 → 3/1 | note:A3 ]", + "[ 2/1 → 3/1 | note:D4 ]", + "[ 2/1 → 3/1 | note:Gb4 ]", + "[ 2/1 → 3/1 | note:A4 ]", + "[ 3/1 → 4/1 | note:F3 ]", + "[ 3/1 → 4/1 | note:C4 ]", + "[ 3/1 → 4/1 | note:F4 ]", + "[ 3/1 → 4/1 | note:A4 ]", + "[ 3/1 → 4/1 | note:C5 ]", +] +`; + exports[`runs examples > example "off" example index 0 1`] = ` [ "[ -5/24 ⇜ (0/1 → 1/8) | note:62 ]", @@ -6847,6 +6961,15 @@ exports[`runs examples > example "off" example index 0 1`] = ` ] `; +exports[`runs examples > example "offset" example index 0 1`] = ` +[ + "[ 0/1 → 1/1 | chord:Am offset:0 ]", + "[ 1/1 → 2/1 | chord:C offset:1 ]", + "[ 2/1 → 3/1 | chord:D offset:2 ]", + "[ 3/1 → 4/1 | chord:F offset:3 ]", +] +`; + exports[`runs examples > example "often" example index 0 1`] = ` [ "[ 0/1 → 1/8 | s:hh speed:0.5 ]",