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

AudioSource with a notion of position. More...

#include <source.hpp>

Public Member Functions

virtual void set_next_read_position (uint64_t new_position)=0
 Move the read head to new_position (frames from the start of the source).
virtual uint64_t get_next_read_position () const =0
 Current frame position the next get_next_audio_block call will read from.
virtual uint64_t get_total_length () const =0
 Total length in frames. 0 means "unknown" or "infinite".
virtual bool is_looping () const =0
 True if the source should wrap back to 0 when it reaches the end.
virtual void set_looping (bool)
 Enable / disable looping.
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

AudioSource with a notion of position.

Subclasses expose a monotonic frame counter that can be reset (set_next_read_position), queried (get_next_read_position), and an optional total length for finite sources (returns 0 for infinite streams).

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 virtualinherited

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.

◆ get_next_read_position()

virtual uint64_t pulp::audio::PositionableAudioSource::get_next_read_position ( ) const
pure virtual

Current frame position the next get_next_audio_block call will read from.

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

◆ get_total_length()

virtual uint64_t pulp::audio::PositionableAudioSource::get_total_length ( ) const
pure virtual

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

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

◆ is_looping()

virtual bool pulp::audio::PositionableAudioSource::is_looping ( ) const
pure virtual

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

Looping infinite sources are no-op.

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 virtualinherited

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 virtualinherited

Called when playback is finished.

Implementations should free any buffers allocated in prepare_to_play.

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

◆ set_looping()

virtual void pulp::audio::PositionableAudioSource::set_looping ( bool )
inlinevirtual

Enable / disable looping.

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

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

◆ set_next_read_position()

virtual void pulp::audio::PositionableAudioSource::set_next_read_position ( uint64_t new_position)
pure virtual

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.

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