|
| | Sampler ()=default |
| |
| | ~Sampler () |
| |
| | Sampler (const Sampler &)=delete |
| |
| Sampler & | operator= (const Sampler &)=delete |
| |
| void | prepare (const AudioSpec &spec, int maxVoices=32) |
| | Allocates the voices and the event queue.
|
| |
| void | reset () noexcept |
| | Silences every voice and drops queued events. Audio thread.
|
| |
| bool | setZones (std::span< const ZoneSpec > zones) |
| | Replaces the zone set.
|
| |
| bool | loadSample (AudioBufferView< const T > audio, double sampleRate, int rootKey=60) |
| | One zone over the whole keyboard and velocity range.
|
| |
| void | clearZones () |
| | Publishes an empty zone set: sounding voices finish, new notes are silent.
|
| |
| void | setEnvelope (T attackMs, T decayMs, T sustain, T releaseMs) noexcept |
| | ADSR for notes that start from now on (release: also for notes released from now on). Times in ms, sustain 0..1.
|
| |
| void | setVelocityRange (T rangeDb) noexcept |
| | Velocity sensitivity: velocity 0 plays rangeDb below velocity 1 (0..96 dB, default 24; 0 ignores velocity).
|
| |
| void | setGain (T dB) noexcept |
| | Output gain in dB.
|
| |
| void | noteOn (int key, T velocity, int offset=0) noexcept |
| | Starts a note at offset samples into the next block. Velocity 0 is a note-off, as in MIDI.
|
| |
| void | noteOff (int key, int offset=0) noexcept |
| | Releases a note at offset samples into the next block.
|
| |
| void | setSustainPedal (bool down, int offset=0) noexcept |
| | Sustain pedal: while down, released keys keep sounding.
|
| |
| void | setPitchBend (T semitones, int offset=0) noexcept |
| | Pitch bend in semitones (-48..48), applied to every voice.
|
| |
| void | allNotesOff (int offset=0) noexcept |
| | Releases every sounding note (and lifts the pedal).
|
| |
| void | processBlock (AudioBufferView< T > out) noexcept |
| | Renders the block, overwriting out, and applies the queued events at their offsets. Allocation free, lock free.
|
| |
| int | getActiveVoiceCount () const noexcept |
| | Voices sounding after the last block, stealing fades included.
|
| |
| int | getPolyphony () const noexcept |
| | Polyphony set by prepare().
|
| |
template<FloatType T>
class dspark::Sampler< T >
Polyphonic multi-zone sample player.
sampler.
noteOn(64, 0.8f, offsetInBlock);
Polyphonic multi-zone sample player.
void processBlock(AudioBufferView< T > out) noexcept
Renders the block, overwriting out, and applies the queued events at their offsets....
void noteOn(int key, T velocity, int offset=0) noexcept
Starts a note at offset samples into the next block. Velocity 0 is a note-off, as in MIDI.
bool loadSample(AudioBufferView< const T > audio, double sampleRate, int rootKey=60)
One zone over the whole keyboard and velocity range.
void prepare(const AudioSpec &spec, int maxVoices=32)
Allocates the voices and the event queue.
- Template Parameters
-
| T | Sample type (float or double). |
Definition at line 104 of file Sampler.h.
Renders the block, overwriting out, and applies the queued events at their offsets. Allocation free, lock free.
One output channel receives the mean of a zone's channels; two or more receive a mono zone on both of the first two (constant-power pan, unity at centre) or a multichannel zone's first two channels with the pan as balance. Further output channels are left silent.
Definition at line 304 of file Sampler.h.
Replaces the zone set.
Validates and copies every zone, bakes loop crossfades, and publishes the set without blocking the audio thread. A zone with no audio, an invalid rate or an empty key or velocity range is rejected, and so is the whole call. Loop points are clamped into the recording, and the crossfade to the samples available before the loop start and inside the loop.
- Returns
- True when the set was accepted.
Definition at line 197 of file Sampler.h.