diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index bf9d8ce0b..ff808ac4a 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -3359,6 +3359,11 @@ Pattern.prototype.shrinklist = function (amount) { export const shrinklist = (amount, pat) => pat.shrinklist(amount); +Pattern.prototype.growlist = function (amount) { + return this.shrinklist(amount).reverse(); +}; +export const growlist = (amount, pat) => pat.growlist(amount); + /** * *Experimental* * diff --git a/packages/midi/midi.mjs b/packages/midi/midi.mjs index bd40b743e..5880ca268 100644 --- a/packages/midi/midi.mjs +++ b/packages/midi/midi.mjs @@ -537,6 +537,9 @@ export async function midin(input) { * The note length is fixed as Superdough is not currently set up for undetermined * note durations * + * The 'midichan' control value contains the number of the channel the note is coming from + * so it could be filtered or manipulated further in the chain. + * * @name midikeys * @tags external_io, midi * @param {string | number} input MIDI device name or index defaulting to 0 @@ -552,6 +555,10 @@ export async function midin(input) { * .s("saw") * .add(note(rand.mul(0.3))) * .lpf(1000).lpe(2).room(0.5) + * @example + * // discard all notes not coming out from midi channel 2 + * const kb = await midikeys('Arturia KeyStep 32') + * kb().filterValues(v=>v.midichan==2).s("tri") */ const kHaps = {}; const kListeners = {}; @@ -633,7 +640,7 @@ export async function midikeys(input) { */ return; } else { - value = { ...value, note: Math.round(note), velocity: velocity / 127 }; + value = { ...value, note: Math.round(note), velocity: velocity / 127, midichan: message.channel }; } kHaps[input].push(new Hap(span, span, value, {})); if (!noteoff && triggerAvailable) { diff --git a/test/__snapshots__/examples.test.mjs.snap b/test/__snapshots__/examples.test.mjs.snap index f7989dc7e..f465f06bf 100644 --- a/test/__snapshots__/examples.test.mjs.snap +++ b/test/__snapshots__/examples.test.mjs.snap @@ -7927,6 +7927,8 @@ exports[`runs examples > example "midikeys" example index 0 1`] = `[]`; exports[`runs examples > example "midikeys" example index 1 1`] = `[]`; +exports[`runs examples > example "midikeys" example index 2 1`] = `[]`; + exports[`runs examples > example "midin" example index 0 1`] = ` [ "[ 0/1 → 1/4 | note:c cutoff:0 resonance:0 s:sawtooth ]",