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

Abstract base — host-callable audio source. More...

#include <source.hpp>

Public Member Functions

virtual ~AudioSource ()=default
virtual void prepare_to_play (int samples_per_block_expected, double sample_rate)=0
 Called before playback begins.
virtual void release_resources ()=0
 Called when playback is finished.
virtual void get_next_audio_block (BufferView< float > out, int start_sample, int num_samples)=0
 Fill num_samples of out, starting at start_sample within out.

Detailed Description

Abstract base — host-callable audio source.

Lifecycle: prepare_to_play(block_size, sample_rate) is called once before audio starts; release_resources() once after audio stops. Between them, get_next_audio_block() is called per audio block. All three must be safe to call from the audio thread (no allocations after prepare_to_play).

Constructor & Destructor Documentation

◆ ~AudioSource()

virtual pulp::audio::AudioSource::~AudioSource ( )
virtualdefault

Member Function Documentation

◆ get_next_audio_block()

virtual void pulp::audio::AudioSource::get_next_audio_block ( BufferView< float > out,
int start_sample,
int num_samples )
pure virtual

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.

Implemented in pulp::audio::AudioFormatReaderSource, and pulp::audio::AudioTransportSource.

◆ prepare_to_play()

virtual void pulp::audio::AudioSource::prepare_to_play ( int samples_per_block_expected,
double sample_rate )
pure virtual

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.

Implemented in pulp::audio::AudioFormatReaderSource, and pulp::audio::AudioTransportSource.

◆ release_resources()

virtual void pulp::audio::AudioSource::release_resources ( )
pure virtual

Called when playback is finished.

Implementations should free any buffers allocated in prepare_to_play.

Implemented in pulp::audio::AudioFormatReaderSource, and pulp::audio::AudioTransportSource.


The documentation for this class was generated from the following file:
  • /home/runner/work/pulp/pulp/core/audio/include/pulp/audio/source.hpp