Build with this node

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

Ask Studio

@maruaudio/dsp/analysis/pitch-tracking interprets a stream of measured pitches as one causal monophonic voice. In direct mode (0) it passes the fractional MIDI pitch through once a note is active; in note mode (1) it outputs integer notes gated by attack, release and change dwell times with hysteresis around the held note. Each update reports noteOn and noteOff flags for that update only. An optional, experimental tuning estimate accumulates stable pitches on the semitone circle (a confidence-weighted circular mean of the fractional part, 0.75 s time constant) and, in note mode with compensation on, slews a correction of up to ±50 cents toward it over 250 ms.

Parameters

configurePitchTracking(state, mode, compensation, attackMs, releaseMs, changeMs, hysteresisCents)

ArgumentRange as codedDefault from initUnit
mode≥ 0.5 is note mode, else direct0index
compensation≥ 0.5 is on0flag
attackMs0 to 100035ms
releaseMs0 to 200080ms
changeMs0 to 100035ms
hysteresisCents0 to 4915cents

Lifecycle

initPitchTracking(sampleRate) (a rate outside 8 to 192 kHz becomes 48 kHz) → configurePitchTracking → updatePitchTracking(state, midi, confidence, rms, voiced, elapsedSamples) per detector hop, or advancePitchTracking, which separates render-clock time from fresh measurement time → resetPitchTracking. Configuring a different mode requires the caller to release any held note and then reset.

When to use it

Turning a pitch detector's output into MIDI notes or a continuous pitch for a pitch-to-MIDI or pitch-following instrument. The Pitchy module uses it.

Limits

  • Scalar state, no allocation. An observation counts only when voiced, MIDI is 0 to 127, confidence 0.5 to 1 and RMS above 0; otherwise silence accumulates and releases the note after releaseMs. Two seconds of silence clear tuning.
  • Updates with elapsedSamples of 0 or more than ten seconds are ignored.
  • The tuning estimate is experimental: not a key or scale estimator and not a calibrated probability. Onsets, transitions and slides faster than 4 semitones per second are excluded from it.
  • Velocity is min(1, rms × √2).

Algorithm properties and proofs

No Lean 4 proof is mapped to this node.

Explore proofs alongside performance

Dependencies

None: this node imports no other node.

Dependents

No other node imports this one.

Used by