@maruaudio/dsp/physical/strike gives the per-mode excitation gains a strike hands a modal bank at the moment of contact: how much energy each mode gets from where the body was hit, and how a soft strike attenuates the higher modes. strikeBarShape weights the modes of a free-free bar by a parity-alternating trigonometric approximation of their shapes (odd modes symmetric about the centre, even modes antisymmetric). strikeGongShape does the same for a gong or kettle, alternating nodal-circle and nodal-diameter families from the boss to the rim. strikeVelocityTilt applies a power law in velocity whose exponent ramps across the bank.
| Function | Law |
|---|---|
strikeBarShape(mode, position) | u = position − 0.5; odd n: cos((n + 1)πu), even n: sin((n + 1)πu), n = mode + 1 |
strikeGongShape(mode, position) | Odd n: cos(((n + 1)/2 − 0.5)πp); even n: sin((n/2)πp); p = 0 at the boss, 1 at the rim |
| Both shapes | `0.02 + 0.98 · |
strikeVelocityTilt(v, mode, count, amount) | max(v, 0.001) ^ (amount · 2 · mode / (count − 1)) |
Lifecycle
None: stateless stage functions with no allocation, computed once per strike and mode. Each call runs one cos, sin or pow.
When to use it
Letting a struck bar or gong respond to where it is hit and how hard: a bar struck at its centre favours its odd modes, a gong struck at the boss favours its fundamental, and a soft strike reaches the upper modes less.
Limits
- The bar shapes match the node count and parity of a free-free bar, not its exact node positions (mode 1's nodes fall at 0.25 and 0.75, not 0.224 and 0.776).
- The floor means no mode is ever fully removed by position.
- The fundamental (mode 0) always gets tilt 1, and
amount ≤ 0returns 1 for every mode, so the tilt is defeatable to the bit. A one-mode bank has span 0. - These are scalar gains at contact, not a filter during the burst.