Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::audio::AudioTransportSource Class Reference

Wraps a PositionableAudioSource with transport-level control: More...

#include <transport_source.hpp>

Public Member Functions

 AudioTransportSource ()=default
void set_source (PositionableAudioSource *source)
 Bind a source (or nullptr to detach). Resets gain ramp state.
PositionableAudioSource * source () const
void start ()
void stop ()
bool is_playing () const
void set_gain (float new_gain)
 Set the target gain.
float gain () const
float current_gain () const
void prepare_to_play (int samples_per_block, double sample_rate) override
 Called before playback begins.
void release_resources () override
 Called when playback is finished.
void get_next_audio_block (BufferView< float > out, int start_sample, int num_samples) override
 Fill num_samples of out, starting at start_sample within out.
void set_next_read_position (uint64_t new_position) override
 Move the read head to new_position (frames from the start of the source).
uint64_t get_next_read_position () const override
 Current frame position the next get_next_audio_block call will read from.
uint64_t get_total_length () const override
 Total length in frames. 0 means "unknown" or "infinite".
bool is_looping () const override
 True if the source should wrap back to 0 when it reaches the end.
void set_looping (bool should_loop) override
 Enable / disable looping.

Detailed Description

Wraps a PositionableAudioSource with transport-level control:

  • start / stop toggle whether get_next_audio_block emits source audio or silence.
  • set_gain applies a linear gain ramp across the next block (no per-sample click on level changes).
  • position / length / looping pass through to the wrapped source.

The transport does not own the source — caller is responsible for keeping the PositionableAudioSource* alive at least as long as get_next_audio_block may be called.

Constructor & Destructor Documentation

◆ AudioTransportSource()

pulp::audio::AudioTransportSource::AudioTransportSource ( )
default

Member Function Documentation

◆ current_gain()

float pulp::audio::AudioTransportSource::current_gain ( ) const
inline

◆ gain()

float pulp::audio::AudioTransportSource::gain ( ) const
inline

◆ get_next_audio_block()

void pulp::audio::AudioTransportSource::get_next_audio_block ( BufferView< float > out,
int start_sample,
int num_samples )
inlineoverridevirtual

Fill num_samples of out, starting at start_sample within out.

The source writes (not adds) into the range so callers don't need to pre-zero.

Implements pulp::audio::AudioSource.

◆ get_next_read_position()

uint64_t pulp::audio::AudioTransportSource::get_next_read_position ( ) const
inlineoverridevirtual

Current frame position the next get_next_audio_block call will read from.

Implements pulp::audio::PositionableAudioSource.

◆ get_total_length()

uint64_t pulp::audio::AudioTransportSource::get_total_length ( ) const
inlineoverridevirtual

Total length in frames. 0 means "unknown" or "infinite".

Implements pulp::audio::PositionableAudioSource.

◆ is_looping()

bool pulp::audio::AudioTransportSource::is_looping ( ) const
inlineoverridevirtual

True if the source should wrap back to 0 when it reaches the end.

Looping infinite sources are no-op.

Implements pulp::audio::PositionableAudioSource.

◆ is_playing()

bool pulp::audio::AudioTransportSource::is_playing ( ) const
inline

◆ prepare_to_play()

void pulp::audio::AudioTransportSource::prepare_to_play ( int samples_per_block_expected,
double sample_rate )
inlineoverridevirtual

Called before playback begins.

samples_per_block_expected is the maximum block length the host will ever ask for; implementations may allocate scratch buffers of that size here.

Implements pulp::audio::AudioSource.

◆ release_resources()

void pulp::audio::AudioTransportSource::release_resources ( )
inlineoverridevirtual

Called when playback is finished.

Implementations should free any buffers allocated in prepare_to_play.

Implements pulp::audio::AudioSource.

◆ set_gain()

void pulp::audio::AudioTransportSource::set_gain ( float new_gain)
inline

Set the target gain.

The change is applied as a per-sample ramp from the current gain to new_gain across the next block — click-free under typical fader motion.

◆ set_looping()

void pulp::audio::AudioTransportSource::set_looping ( bool )
inlineoverridevirtual

Enable / disable looping.

Default no-op for sources that don't support it; concrete sources override.

Reimplemented from pulp::audio::PositionableAudioSource.

◆ set_next_read_position()

void pulp::audio::AudioTransportSource::set_next_read_position ( uint64_t new_position)
inlineoverridevirtual

Move the read head to new_position (frames from the start of the source).

For finite sources, positions past get_total_length() are caller-defined behavior — most implementations clamp to total length or wrap on the next read.

Implements pulp::audio::PositionableAudioSource.

◆ set_source()

void pulp::audio::AudioTransportSource::set_source ( PositionableAudioSource * source)
inline

Bind a source (or nullptr to detach). Resets gain ramp state.

◆ source()

PositionableAudioSource * pulp::audio::AudioTransportSource::source ( ) const
inline

◆ start()

void pulp::audio::AudioTransportSource::start ( )
inline

◆ stop()

void pulp::audio::AudioTransportSource::stop ( )
inline

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