|
| | SnareVoice () |
| void | set_tune_hz (double hz) |
| | Fundamental of the lower tone oscillator, in Hz.
|
| void | set_tone_ratio (double ratio) |
| | Frequency ratio of the upper tone oscillator to the lower.
|
| void | set_tone_level (double level) |
| void | set_tone_decay_ms (double ms) |
| void | set_pitch_sweep_octaves (double octaves) |
| | Depth and time constant of the shared downward pitch sweep, in octaves.
|
| void | set_pitch_sweep_ms (double ms) |
| void | set_fm_amount (double amount) |
| | Phase-modulation depth of the upper oscillator into the lower.
|
| void | set_ring (double amount) |
| | Crossfade from the two oscillators summed (0) to ring-modulated (1).
|
| void | set_noise_level (double level) |
| void | set_noise_decay_ms (double ms) |
| void | set_noise_color (NoiseColor color) |
| void | set_noise_cutoff_hz (double hz) |
| | Corner and resonance of the filter the wires are heard through.
|
| void | set_noise_resonance (double q) |
| void | set_noise_sweep_octaves (double octaves) |
| | How far that corner sweeps over the note, in octaves.
|
| void | set_rattle (double amount) |
| | Depth and rate of the wires' buzz against the head.
|
| void | set_rattle_hz (double hz) |
| void | set_snap_level (double level) |
| | The strike itself: a short highpassed crack, distinct from the wires.
|
| void | set_snap_cutoff_hz (double hz) |
| void | set_snap_decay_ms (double ms) |
| void | set_shell_level (double level) |
| | Level of the shell resonance applied to the noise path, and its Q.
|
| void | set_shell_resonance (double q) |
| OutputStage & | output () |
| const OutputStage & | output () const |
| OutputStage * | output_stage () noexcept override |
| | The terminal saturation and degradation stage, at the generic voice boundary.
|
| int | latency_samples () const noexcept override |
| | Fixed host-rate delay introduced by this voice's selected output quality.
|
| OutputOversampling | output_oversampling () const noexcept override |
| | Output quality at the generic voice boundary.
|
| void | set_output_oversampling (OutputOversampling factor) override |
| LofiChain & | tone_lofi () |
| | Degradation applied to the pitched shell before it meets the wires.
|
| LofiChain & | noise_lofi () |
| | A second degradation chain on the noise path alone.
|
| void | prepare (double sample_rate) |
| | Fixes the sample rate and clears all state.
|
| void | reset () |
| | Silences the voice immediately, without a fade.
|
| void | note_on (float velocity) |
| | Starts a hit. velocity is in [0, 1]; values outside are clamped.
|
| void | choke (float fade_ms=4.0f) |
| | Fades the voice out over fade_ms and then silences it.
|
| bool | is_active () const |
| | Whether the voice still has something to render.
|
| VoiceState | state () const |
| float | velocity () const |
| double | sample_rate () const |
| const OutputStage * | output_stage () const noexcept |
| void | set_velocity_response (const VelocityResponse &r) |
| const VelocityResponse & | velocity_response () const |
| void | process (float *out, int num_samples) |
| | Adds num_samples of this voice's output into out.
|
| void | process_stereo (float *left, float *right, int num_samples) |
| | Adds a stereo rendering to left and right.
|
|
| void | on_prepare (double sample_rate) override |
| | Sizes buffers and fixes coefficients.
|
| void | on_reset () override |
| | Clears every piece of state the voice carries, so is_active() becomes false and the next render starts from silence.
|
| void | on_note_on (float velocity) override |
| | Starts a hit at the given velocity, already clamped to [0, 1].
|
| bool | on_is_active () const override |
| void | render_add (float *out, int num_samples) override |
| | Adds the voice's output into out. Must add, never assign.
|
| virtual void | render_add_stereo (float *left, float *right, int num_samples) |
| | Optional stereo realization.
|
A snare drum.
A snare is two instruments in a shared shell and it has to be built that way. The drum itself is a small tuned membrane, which the tone pair below stands in for; the snares are a set of wires under the bottom head that rattle against it, which is the filtered noise. Neither alone reads as a snare – the tone on its own is a tom, and the noise on its own is a splash – and the balance between them is the single most recognisable control on the instrument.
Three details separate this from a tom with noise added:
- Two tone oscillators, not one. A snare's shell is small enough that its two lowest modes are close together and beat audibly. One oscillator cannot produce that beating, and the ratio between the two is what makes a snare sound taut rather than hollow.
- The wires buzz. They are not simply excited by the strike; they leave the head and return, which amplitude-modulates the noise at a rate set by how tight they are. set_rattle is that modulation, and without it the noise layer reads as a hiss laid over a drum.
- The shell resonates the noise. The high-Q bandpass takes the strike and the wires and puts the shell's own pitch back into them, which is why a snare's noise is pitched even though noise has no pitch.
RT contract: prepare() allocates nothing; every other method, including note_on and process, allocates nothing and takes no locks.