Plays back a MemoryMappedAudioReader as a PositionableAudioSource. More...
#include <format_reader_source.hpp>
Public Member Functions | |
| AudioFormatReaderSource ()=default | |
| AudioFormatReaderSource (std::shared_ptr< MemoryMappedAudioReader > reader) | |
| void | set_reader (std::shared_ptr< MemoryMappedAudioReader > reader) |
| MemoryMappedAudioReader * | reader () const |
| Non-owning accessor — useful when the caller already owns the reader and wants to query info / metadata. | |
| void | prepare_to_play (int, double) 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. | |
Plays back a MemoryMappedAudioReader as a PositionableAudioSource.
Read position is tracked in frames from the start of the file. Loops back to 0 when set_looping(true) is set and the read head reaches the end. Past-end reads on non-looping sources fill the remainder of the requested block with silence.
|
default |
|
inlineexplicit |
|
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.
|
inlineoverridevirtual |
Current frame position the next get_next_audio_block call will read from.
Implements pulp::audio::PositionableAudioSource.
|
inlineoverridevirtual |
Total length in frames. 0 means "unknown" or "infinite".
Implements pulp::audio::PositionableAudioSource.
|
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.
|
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.
|
inline |
Non-owning accessor — useful when the caller already owns the reader and wants to query info / metadata.
|
inlineoverridevirtual |
Called when playback is finished.
Implementations should free any buffers allocated in prepare_to_play.
Implements pulp::audio::AudioSource.
|
inlineoverridevirtual |
Enable / disable looping.
Default no-op for sources that don't support it; concrete sources override.
Reimplemented from pulp::audio::PositionableAudioSource.
|
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.
|
inline |