@maruaudio/dsp/processors/strum-notes picks the pitches a strummed chord grid plays. selectChordStrumNotes takes the held voicing and returns an ascending, contiguous window of its octave-repeated chord tones, centred on the voicing and shifted inward at the MIDI range edges. The length of the caller's output buffer chooses how many positions the window has, so one call serves an eight-zone grid or a twelve-string layout. It is a pure function over caller-owned arrays, with no instance state.
const output = new Int32Array(8) // position count
const candidates = new Int32Array(128) // scratch
const n = selectChordStrumNotes(held, heldCount, output, candidates)Lifecycle
None: no createState, prepare or reset. The caller owns the held pitches, the 128-entry candidate scratch and the output buffer, and calls the function whenever the chord changes. It allocates nothing, so a Processor can call it, and a face can reuse it for labels.
When to use it
A strum or harp surface where each zone or string should sound one chord tone, in register order, around where the player holds the chord. Both stroke directions read the same ascending register, so an up-stroke and a down-stroke cover the same pitches.
Limits
- Reads at most the first four held pitches. A pitch is eligible when it is a whole number of octaves, at most four (48 semitones), from a held pitch.
- Positions are
min(128, output.length). The return value is the number written, which is smaller when fewer eligible pitches exist; an empty chord or an empty output returns 0. - Output stays inside MIDI 0 to 127, in ascending order, with no duplicates and no eligible pitch skipped inside the window.
candidatesmust hold 128 entries; the function does not check its length.