struct audio_decoder audio¶
struct audio_decoder Abstract base class for audio decoders providing methods for opening and reading audio files.
destructor ~audio_decoder() ¶
virtual ~audio_decoder() Defined at audio/decoder.hpp:44
function open(std::shared_ptr<binary_reader>) ¶
[[nodiscard]] virtual expected<audiofile_format, audiofile_error> open(
std::shared_ptr<binary_reader> reader) = 0 Opens an audio file using a binary reader and retrieves its format.
| reader | Shared pointer to a binary reader. |
| Audio format on success, or an error code on failure. |
Defined at audio/decoder.hpp:51
function open(const file_path &) ¶
[[nodiscard]] expected<audiofile_format, audiofile_error> open(const file_path& path) Opens an audio file from a file path and retrieves its format.
| path | Path to the audio file. |
| Audio format on success, or an error code on failure. |
Defined at audio/decoder.hpp:59
function open(const std::string &) ¶
[[nodiscard]] expected<audiofile_format, audiofile_error> open(const std::string& path) Opens an audio file using a UTF-8 encoded string path (Windows-specific).
| path | UTF-8 encoded file path. |
| Audio format on success, or an error code on failure. |
Defined at audio/decoder.hpp:67
function read_to(const audio_data_interleaved &) ¶
[[nodiscard]] virtual expected<size_t, audiofile_error> read_to(const audio_data_interleaved& output) = 0 Reads audio frames into an interleaved buffer.
| output | Destination buffer for decoded samples. |
| Number of frames read on success, or an error code on failure. |
Defined at audio/decoder.hpp:75
function read(size_t) ¶
[[nodiscard]] expected<audio_data_interleaved, audiofile_error> read(size_t maximum_frames) Reads up to a maximum number of audio frames into a newly allocated buffer.
| maximum_frames | Maximum number of frames to read. |
| Audio data on success, or an error code on failure. |
Defined at audio/decoder.hpp:82
function seek_is_precise() ¶
[[nodiscard]] virtual bool seek_is_precise() const Determines whether seeking is precise for this decoder.
| True if seeking is precise, false otherwise. |
Defined at audio/decoder.hpp:88
function seek(uint64_t) ¶
[[nodiscard]] virtual expected<void, audiofile_error> seek(uint64_t position) = 0 Seeks to a specific sample position in the audio stream.
| position | Target position in sample frames. |
| Success, or an error code if seeking fails. |
Defined at audio/decoder.hpp:95
function read_all() ¶
[[nodiscard]] expected<audio_data_interleaved, audiofile_error> read_all() Reads the entire audio stream into an interleaved buffer.
| Audio data on success, or an error code on failure. |
Defined at audio/decoder.hpp:101
function read_all_planar() ¶
[[nodiscard]] expected<audio_data_planar, audiofile_error> read_all_planar() Reads the entire audio stream into a planar buffer.
| Audio data on success, or an error code on failure. |
Defined at audio/decoder.hpp:107
function format() ¶
[[nodiscard]] const std::optional<audiofile_format>& format() const Retrieves the format of the currently opened audio file.
| Audio format if available, or std::nullopt. |
Defined at audio/decoder.hpp:113
function has_chunk(std::span<const std::byte>) ¶
Checks if the file contains a chunk with the specified ID.
| chunk_id | Identifier of the chunk. |
| Chunk size if found, or std::nullopt. |
Defined at audio/decoder.hpp:120
function read_chunk(std::span<const std::byte>, const std::function<bool (std::span<const std::byte>)> &, size_t) ¶
[[nodiscard]] virtual expected<void, audiofile_error> read_chunk(
std::span<const std::byte> chunk_id, const std::function<bool(std::span<const std::byte>)>& handler,
size_t buffer_size = 65536) Reads a RIFF chunk by its identifier.
| chunk_id | Chunk ID to read. |
| handler | Callback invoked with chunk data. |
| buffer_size | Buffer size for reading, defaults to 64 KiB. |
| Success or an error code. |
Defined at audio/decoder.hpp:129
function read_chunk_bytes(std::span<const std::byte>) ¶
expected<std::vector<uint8_t>, audiofile_error> read_chunk_bytes(std::span<const std::byte> chunk_id) Reads a RIFF chunk into a byte vector.
| chunk_id | Chunk ID to read. |
| Chunk data on success, or an error code on failure. |
Defined at audio/decoder.hpp:138
function close() ¶
virtual void close() = 0 Closes the audio file and releases resources.
Defined at audio/decoder.hpp:143
function reader() ¶
std::shared_ptr<binary_reader> reader() const noexcept Retrieves the binary reader associated with the decoder.
| Shared pointer to the binary reader. |
Defined at audio/decoder.hpp:149
function read_buffered(const audio_data_interleaved &, const std::function<expected<audio_data_interleaved, audiofile_error> ()> &, audio_data_interleaved &) ¶
expected<size_t, audiofile_error> read_buffered(
const audio_data_interleaved& output,
const std::function<expected<audio_data_interleaved, audiofile_error>()>& read_packet,
audio_data_interleaved& buffer) Reads audio frames into a buffer using a custom read function.
| output | Destination buffer for decoded samples. |
| read_packet | Function to read audio packets. |
| buffer | Temporary buffer for intermediate data. |
| Number of frames read on success, or an error code on failure. |
Defined at audio/decoder.hpp:159
constructor audio_decoder() ¶
audio_decoder() = default Defined at audio/decoder.hpp:164
variable m_format ¶
std::optional<audiofile_format> m_format Defined at audio/decoder.hpp:165
variable m_reader ¶
std::shared_ptr<binary_reader> m_reader Defined at audio/decoder.hpp:166
Defined at audio/encoder.hpp:34