Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::audio::VoiceModulationSources< MaximumVoices > Class Template Reference

A fixed-capacity bank of per-voice modulation sources. More...

#include <voice_modulation_sources.hpp>

Public Member Functions

 VoiceModulationSources ()=default
bool prepare (const VoiceModulationSourcesConfig &config) noexcept
 Control/background-thread only.
void release () noexcept
 Control/background-thread only. Invalidates prepared storage.
void reset () noexcept
 RT-safe after prepare. Resets every voice's sources to a fresh start.
bool prepared () const noexcept
const VoiceModulationSourcesConfig & config () const noexcept
bool set_lfo_rate_hz (double rate_hz) noexcept
 RT-safe after prepare.
bool set_lfo_depth (float depth) noexcept
 RT-safe after prepare.
void set_lfo_wave (pulp::signal::Lfo::Wave wave) noexcept
 RT-safe after prepare.
void note_on (std::size_t voice_index) noexcept
 RT-safe after prepare.
void note_off (std::size_t voice_index) noexcept
 RT-safe after prepare. Releases that voice's envelope.
VoiceModulationResult append_lfo_lane (std::size_t voice_index, VoiceModulationBuffer &destination, VoiceModulationTarget target, VoiceModulationRate rate, std::uint32_t frame_count) noexcept
 RT-safe after prepare.
VoiceModulationResult append_envelope_lane (std::size_t voice_index, VoiceModulationBuffer &destination, VoiceModulationTarget target, VoiceModulationRate rate, std::uint32_t frame_count) noexcept
 RT-safe after prepare.
VoiceModulationResult write_voice (std::size_t voice_index, VoiceModulationBuffer &destination, VoiceModulationTarget lfo_target, VoiceModulationTarget envelope_target, VoiceModulationRate rate, std::uint32_t frame_count) noexcept
 RT-safe after prepare.

Detailed Description

template<std::size_t MaximumVoices>
class pulp::audio::VoiceModulationSources< MaximumVoices >

A fixed-capacity bank of per-voice modulation sources.

MaximumVoices sizes both the source instances and the unison phase spread. The bank stores resolved samples; like VoiceModulationBuffer, it applies no routing, scaling beyond depth, smoothing, or unit conversion.

Constructor & Destructor Documentation

◆ VoiceModulationSources()

template<std::size_t MaximumVoices>
pulp::audio::VoiceModulationSources< MaximumVoices >::VoiceModulationSources ( )
default

Member Function Documentation

◆ append_envelope_lane()

template<std::size_t MaximumVoices>
VoiceModulationResult pulp::audio::VoiceModulationSources< MaximumVoices >::append_envelope_lane ( std::size_t voice_index,
VoiceModulationBuffer & destination,
VoiceModulationTarget target,
VoiceModulationRate rate,
std::uint32_t frame_count )
inlinenoexcept

RT-safe after prepare.

Appends the voice's envelope as one lane to a block the caller has already begun. Fails with InvalidTarget when the envelope source is disabled.

◆ append_lfo_lane()

template<std::size_t MaximumVoices>
VoiceModulationResult pulp::audio::VoiceModulationSources< MaximumVoices >::append_lfo_lane ( std::size_t voice_index,
VoiceModulationBuffer & destination,
VoiceModulationTarget target,
VoiceModulationRate rate,
std::uint32_t frame_count )
inlinenoexcept

RT-safe after prepare.

Appends the voice's LFO as one lane to a block the caller has already begun with VoiceModulationBuffer::begin_block. Fails with InvalidTarget when the LFO source is disabled.

◆ config()

template<std::size_t MaximumVoices>
const VoiceModulationSourcesConfig & pulp::audio::VoiceModulationSources< MaximumVoices >::config ( ) const
inlinenoexcept

◆ note_off()

template<std::size_t MaximumVoices>
void pulp::audio::VoiceModulationSources< MaximumVoices >::note_off ( std::size_t voice_index)
inlinenoexcept

RT-safe after prepare. Releases that voice's envelope.

◆ note_on()

template<std::size_t MaximumVoices>
void pulp::audio::VoiceModulationSources< MaximumVoices >::note_on ( std::size_t voice_index)
inlinenoexcept

RT-safe after prepare.

Note-on retriggers that voice's LFO per its phase policy (free-running ignores it) and restarts its envelope.

◆ prepare()

template<std::size_t MaximumVoices>
bool pulp::audio::VoiceModulationSources< MaximumVoices >::prepare ( const VoiceModulationSourcesConfig & config)
inlinenoexcept

Control/background-thread only.

Allocates fixed scratch storage and prepares every voice's sources. Invalid configs leave the previous state untouched and return false.

◆ prepared()

template<std::size_t MaximumVoices>
bool pulp::audio::VoiceModulationSources< MaximumVoices >::prepared ( ) const
inlinenoexcept

◆ release()

template<std::size_t MaximumVoices>
void pulp::audio::VoiceModulationSources< MaximumVoices >::release ( )
inlinenoexcept

Control/background-thread only. Invalidates prepared storage.

◆ reset()

template<std::size_t MaximumVoices>
void pulp::audio::VoiceModulationSources< MaximumVoices >::reset ( )
inlinenoexcept

RT-safe after prepare. Resets every voice's sources to a fresh start.

◆ set_lfo_depth()

template<std::size_t MaximumVoices>
bool pulp::audio::VoiceModulationSources< MaximumVoices >::set_lfo_depth ( float depth)
inlinenoexcept

RT-safe after prepare.

Rescales every voice's bipolar LFO output.

Negative values invert the wave, which is the documented way to express a source whose convention is the inverse of this one's. Depth is the other half of a live LFO's automation surface, and has the same reason as the rate for not living behind prepare().

Rejects a non-finite depth, leaving the current depth in place, and reports whether the depth was taken.

◆ set_lfo_rate_hz()

template<std::size_t MaximumVoices>
bool pulp::audio::VoiceModulationSources< MaximumVoices >::set_lfo_rate_hz ( double rate_hz)
inlinenoexcept

RT-safe after prepare.

Retunes every voice's LFO, preserving phase and the lifecycle stage.

Rate is an automation destination in every synth that has an LFO at all — it is what a "LFO Rate" knob writes to — so it cannot be reachable only through prepare(). prepare() allocates, is control-thread only, and restarts phase; sweeping a rate knob through it would stall the LFO at phase 0 for the whole sweep.

Rejects a non-finite or non-positive rate — the rates prepare() refuses — and reports whether the rate was taken. The shipped LFO clamps a non-positive rate up into its own legal range rather than refusing it, so accepting one here would leave config() holding a rate that prepare(config()) then rejects: the bank and the config it reports would disagree.

◆ set_lfo_wave()

template<std::size_t MaximumVoices>
void pulp::audio::VoiceModulationSources< MaximumVoices >::set_lfo_wave ( pulp::signal::Lfo::Wave wave)
inlinenoexcept

RT-safe after prepare.

Reshapes every voice's LFO, preserving phase and the lifecycle stage.

A shape selector is a control a player turns, so it belongs with the rate and depth rather than behind prepare(). Leaving it prepare-only forces a caller whose shape is authored per patch to re-prepare a bank the audio thread may be reading from, which is a data race the caller then has to invent a publication scheme to avoid. Random streams are not reseeded, so switching away from sh_random and back resumes the same stream rather than replaying it.

◆ write_voice()

template<std::size_t MaximumVoices>
VoiceModulationResult pulp::audio::VoiceModulationSources< MaximumVoices >::write_voice ( std::size_t voice_index,
VoiceModulationBuffer & destination,
VoiceModulationTarget lfo_target,
VoiceModulationTarget envelope_target,
VoiceModulationRate rate,
std::uint32_t frame_count )
inlinenoexcept

RT-safe after prepare.

Convenience owner of the whole block: begins a block on destination and appends one lane per enabled source to lfo_target and envelope_target. Both targets must differ and both sources must be enabled.


The documentation for this class was generated from the following file: