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

Drives an AudioSource from a host audio callback. More...

#include <source_player.hpp>

Public Member Functions

 AudioSourcePlayer ()=default
void set_source (AudioSource *source)
 Bind a source (or nullptr to detach).
AudioSource * source () const
void set_gain (float gain)
 Overall gain applied after the source's render. Default 1.0.
float gain () const
void audio_callback (BufferView< float > out, int num_samples, double sample_rate)
 Call from the host's audio callback.
void release ()
 Manually release the source's resources (mirrors what set_source(nullptr) does for the prior source).

Detailed Description

Drives an AudioSource from a host audio callback.

The player re-issues prepare_to_play automatically when the host's sample-rate or block-size differs from the last call, so callers don't need to call it manually after a device change.

Output is multi-channel via BufferView<float>; channels are rendered into the buffer at offset 0 (the player does not chase start_sample; that's a per-source concern).

Constructor & Destructor Documentation

◆ AudioSourcePlayer()

pulp::audio::AudioSourcePlayer::AudioSourcePlayer ( )
default

Member Function Documentation

◆ audio_callback()

void pulp::audio::AudioSourcePlayer::audio_callback ( BufferView< float > out,
int num_samples,
double sample_rate )
inline

Call from the host's audio callback.

Re-prepares the source if sample_rate or num_samples differs from the last call.

◆ gain()

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

◆ release()

void pulp::audio::AudioSourcePlayer::release ( )
inline

Manually release the source's resources (mirrors what set_source(nullptr) does for the prior source).

◆ set_gain()

void pulp::audio::AudioSourcePlayer::set_gain ( float gain)
inline

Overall gain applied after the source's render. Default 1.0.

◆ set_source()

void pulp::audio::AudioSourcePlayer::set_source ( AudioSource * source)
inline

Bind a source (or nullptr to detach).

If a source was already playing, the previous source's resources are released first.

◆ source()

AudioSource * pulp::audio::AudioSourcePlayer::source ( ) const
inline

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