Build with this node

Start with a prompt in Studio, or copy it into your own coding agent.

Ask Studio

@maruaudio/dsp/processors/midi-pattern walks the held notes as a step pattern and emits MIDI: an arpeggiator (mode 0) or a sixteen-step sequencer with per-step velocity and swing (mode 1). Steps run at a rate in steps per second; each step is 1 / rate seconds converted to exact fractional frames through @maru/control-musical-clock, and every onset is rounded once from a grid anchor, so onsets do not drift when a step is not a whole number of frames. Controls are held as integer millionths. The Steps and Arpeggiator module Processors own mode and schema; generated adapters own handles and I/O.

Parameters

configureMidiPatternProcessor(state, mode, sampleRate, rate, pattern, octaves, gate, swing, length, seed, enabled) sets them together.

Argument or setterRange as codedDefault
mode≥ 1 is the sequencer, otherwise the arpeggiator0
rate0.5 to 32 steps per second8
patternFloored, at most 4: 0 up, 1 down, 2 up-down, 3 played order, 4 seeded random0
octavesFloored, 1 to 41
gate0.05 to 0.95 of a step, then at most 95 % of it and at least one frame0.6
swing0.5 to 0.75; delays odd steps in the sequencer only0.5
lengthFloored, 1 to 16 steps16
setMidiPatternTempo(bpm, stepsPerBeat)Each at least 1, giving a rate clamped to 0.5 to 32none
setMidiPatternStepVelocity(index, v)Index below 16; velocity 0 to 1, scaling held velocity in the sequencer0.9, 0.45, 0, 0.45 repeating

enabled 0 passes input through unchanged; sampleRate below 1 is refused.

Lifecycle

createMidiPatternState (fixed typed arrays) → configure and setters → enqueueMidiPatternEvent(frame, status, data1, data2) → processMidiPatternProcessor(blockStart, frames) → emitMidiPatternEvents (MIDI byte events); saveMidiPatternState / restoreMidiPatternState (a versioned 3,066-byte layout, refused when malformed); resetMidiPatternState.

When to use it

An arpeggiator or a step sequencer driven by held notes, where steps must stay on an exact grid at any host rate.

Limits

  • Queues of 128 input events, 128 pending note-offs and 256 outputs. A full input queue refuses the enqueue; a full output or note-off queue, or caller output with too little room, makes emitMidiPatternEvents return false.
  • A block may not start before the previous one or have no frames. Notes above 127 after the octave shift are skipped.

Algorithm properties and proofs

No Lean 4 proof is mapped to this node.

Explore proofs alongside performance

Dependencies

Dependents

No other node imports this one.

Used by