Build with this node

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

Ask Studio

@maruaudio/dsp/mixing/key-velocity-response interpolates a gain and a velocity exponent across the keyboard from prepared register anchors, and applies them to one strike:

gain = 10^(gainDb(note)/20) × (clamp(velocity, 0, 1) / anchorVelocity)^max(0, exponent(note))

keyInterpolatedValue(note, keys, values, count) interpolates linearly between the two anchors around note and extrapolates the end segments, so the register slope continues past the first and last anchor. keyTrackedVelocityGain combines the two interpolations. The …Eight variants are fixed eight-anchor forms used by the piano voice.

Parameters

There are no setters or state. The caller passes Float32Array tables of ordered, distinct key anchors with equal-length gain (dB) and exponent tables, the anchor count and the anchor velocity on every call.

Lifecycle

Pure functions, evaluated once per strike. The tables are prepared by the caller beforehand. No allocation, state change or sample or layer selection happens here.

When to use it

Calibrating an instrument's loudness and velocity sensitivity by register, so low and high notes respond to touch differently, with a handful of anchors instead of a table per key.

Limits

  • Loudness only; physical excitation stays with the caller.
  • Zero dB and a zero exponent are exactly neutral, including at velocity 0.
  • With count ≤ 1 the first value is returned unchanged.
  • Repeated anchor keys divide by zero; the anchors must be distinct.
  • Tables are f32; interpolation runs in doubles and the final gain is rounded to f32.

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

Used by