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

Memory-mapped audio file reader. More...

#include <mmap_reader.hpp>

Public Member Functions

 MemoryMappedAudioReader ()
 ~MemoryMappedAudioReader ()
 MemoryMappedAudioReader (MemoryMappedAudioReader &&) noexcept
MemoryMappedAudioReader & operator= (MemoryMappedAudioReader &&) noexcept
bool open (std::string_view path)
 Open and memory-map an audio file. Returns false on failure.
bool open (std::string_view path, std::size_t maximum_mapped_bytes)
void close ()
 Close the mapped file.
bool is_open () const
 Whether an immutable snapshot of the source is currently mapped.
const AudioFileInfo & info () const
 File info (available after open).
bool read_frames (float **dest_channels, uint32_t num_channels, uint64_t start_frame, uint64_t num_frames)
 Read a range of frames into deinterleaved float buffers.
bool read_frames_ranged_only (float **dest_channels, uint32_t num_channels, uint64_t start_frame, uint64_t num_frames)
 Strict counterpart to read_frames().
bool supports_ranged_read () const
 True when a ranged (seek-based, no whole-file decode) reader is active for this file.
std::optional< AudioFileData > read_all ()
 Read the entire immutable source snapshot.
const uint8_t * data () const
 Raw bytes from the immutable source snapshot (for custom decoding).
size_t size () const
bool copy_access_policy_to (std::string_view destination) const noexcept
 Copy the access policy captured by the retained source handle to an existing artifact.
runtime::AccessPolicyTarget prepare_access_policy_target (std::string_view destination) const noexcept
bool path_refers_to_open_file (std::string_view path) const noexcept
runtime::FileIdentity opened_file_identity () const noexcept

Detailed Description

Memory-mapped audio file reader.

Maps the file into memory and decodes on demand. Ideal for large sample libraries where loading the entire file is impractical.

Constructor & Destructor Documentation

◆ MemoryMappedAudioReader() [1/2]

pulp::audio::MemoryMappedAudioReader::MemoryMappedAudioReader ( )

◆ ~MemoryMappedAudioReader()

pulp::audio::MemoryMappedAudioReader::~MemoryMappedAudioReader ( )

◆ MemoryMappedAudioReader() [2/2]

pulp::audio::MemoryMappedAudioReader::MemoryMappedAudioReader ( MemoryMappedAudioReader && )
noexcept

Member Function Documentation

◆ close()

void pulp::audio::MemoryMappedAudioReader::close ( )

Close the mapped file.

◆ copy_access_policy_to()

bool pulp::audio::MemoryMappedAudioReader::copy_access_policy_to ( std::string_view destination) const
noexcept

Copy the access policy captured by the retained source handle to an existing artifact.

Control thread only.

◆ data()

const uint8_t * pulp::audio::MemoryMappedAudioReader::data ( ) const

Raw bytes from the immutable source snapshot (for custom decoding).

◆ info()

const AudioFileInfo & pulp::audio::MemoryMappedAudioReader::info ( ) const
inline

File info (available after open).

◆ is_open()

bool pulp::audio::MemoryMappedAudioReader::is_open ( ) const

Whether an immutable snapshot of the source is currently mapped.

◆ open() [1/2]

bool pulp::audio::MemoryMappedAudioReader::open ( std::string_view path)

Open and memory-map an audio file. Returns false on failure.

◆ open() [2/2]

bool pulp::audio::MemoryMappedAudioReader::open ( std::string_view path,
std::size_t maximum_mapped_bytes )

◆ opened_file_identity()

runtime::FileIdentity pulp::audio::MemoryMappedAudioReader::opened_file_identity ( ) const
noexcept

◆ operator=()

MemoryMappedAudioReader & pulp::audio::MemoryMappedAudioReader::operator= ( MemoryMappedAudioReader && )
noexcept

◆ path_refers_to_open_file()

bool pulp::audio::MemoryMappedAudioReader::path_refers_to_open_file ( std::string_view path) const
noexcept

◆ prepare_access_policy_target()

runtime::AccessPolicyTarget pulp::audio::MemoryMappedAudioReader::prepare_access_policy_target ( std::string_view destination) const
noexcept

◆ read_all()

std::optional< AudioFileData > pulp::audio::MemoryMappedAudioReader::read_all ( )

Read the entire immutable source snapshot.

◆ read_frames()

bool pulp::audio::MemoryMappedAudioReader::read_frames ( float ** dest_channels,
uint32_t num_channels,
uint64_t start_frame,
uint64_t num_frames )

Read a range of frames into deinterleaved float buffers.

Seekable formats use the mapped ranged decoder; unsupported formats or an unexpected ranged decode failure fall back to a cached whole-file decode. Returns false on error. Frames past end-of-file are zero-filled. RT note: this performs decode/copy work, so it is for the control or background reader thread, never the audio callback. Concurrent calls on one instance are serialized internally. Open, close, move, and destruction must not overlap reads. This API remains non-RT: callers may block on decoding, allocation, I/O, or another reader.

◆ read_frames_ranged_only()

bool pulp::audio::MemoryMappedAudioReader::read_frames_ranged_only ( float ** dest_channels,
uint32_t num_channels,
uint64_t start_frame,
uint64_t num_frames )

Strict counterpart to read_frames().

Returns false unless the requested frames were served by the mapped ranged decoder; it never starts or uses the whole-file fallback cache.

◆ size()

size_t pulp::audio::MemoryMappedAudioReader::size ( ) const

◆ supports_ranged_read()

bool pulp::audio::MemoryMappedAudioReader::supports_ranged_read ( ) const

True when a ranged (seek-based, no whole-file decode) reader is active for this file.

False means read_frames falls back to a one-time whole-file decode cached on first use (e.g. a format the streaming reader can't seek).


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