The transient: a burst of noise through a lowpass, decaying in a few milliseconds. More...
#include <layers.hpp>
Public Member Functions | |
| void | prepare (double sample_rate) |
| void | reset () |
| void | set_level (double level) |
| void | set_cutoff_hz (double hz) |
| void | set_decay_ms (double ms) |
| double | level () const |
| double | cutoff_hz () const |
| void | trigger (double brightness=1.0) |
| Starts a click. | |
| bool | is_active () const |
| A silent layer is never active. | |
| double | process (double noise) |
| Next sample. noise is a raw white sample from the voice's generator. | |
The transient: a burst of noise through a lowpass, decaying in a few milliseconds.
Every percussion voice has one, and it is always built the same way, because a strike is broadband and short and a one-pole is what turns that into a specific-sounding strike. The cutoff is the interesting control, not the level: lowering it turns a beater tick into a thump and a rimshot into a body hit, whereas turning the level down just makes the same tick quieter. That is why velocity brightens the click here rather than only scaling it.
The layer does not own its noise generator. Voices share one generator across their layers so a hit reseeds once and stays reproducible; giving each layer its own would mean each hit's layers were correlated with each other in a way that changes with the layer count.
RT contract: prepare() allocates nothing; trigger() and process() allocate nothing and take no locks.
|
inline |
|
inline |
A silent layer is never active.
Both halves matter: without the level term a layer whose level is zero would report itself active forever, because process() returns early and so never advances the envelope that would eventually clear the flag – and a voice built from layers would then never finish and never leave the CPU.
|
inline |
|
inline |
|
inline |
Next sample. noise is a raw white sample from the voice's generator.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Starts a click.
brightness multiplies the cutoff, which is how velocity reaches this layer's timbre.