Struct audio_decoder¶
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() Fully qualified name: kfr::audio_decoder::~audio_decoder()
Declared at audio/decoder.hpp:41
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. |
Fully qualified name: kfr::audio_decoder::open(std::shared_ptr<binary_reader>)
Declared at audio/decoder.hpp:48
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. |
Fully qualified name: kfr::audio_decoder::open(const file_path &)
Declared at audio/decoder.hpp:56
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. |
Fully qualified name: kfr::audio_decoder::read_to(const audio_data_interleaved &)
Declared at audio/decoder.hpp:72
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. |
Fully qualified name: kfr::audio_decoder::read(size_t)
Declared at audio/decoder.hpp:79
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. |
Fully qualified name: kfr::audio_decoder::seek_is_precise()
Declared at audio/decoder.hpp:85
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. |
Fully qualified name: kfr::audio_decoder::seek(uint64_t)
Declared at audio/decoder.hpp:92
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. |
Fully qualified name: kfr::audio_decoder::read_all()
Declared at audio/decoder.hpp:98
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. |
Fully qualified name: kfr::audio_decoder::read_all_planar()
Declared at audio/decoder.hpp:104
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. |
Fully qualified name: kfr::audio_decoder::format()
Declared at audio/decoder.hpp:110
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. |
Fully qualified name: kfr::audio_decoder::has_chunk(std::span<const std::byte>)
Declared at audio/decoder.hpp:117
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. |
Fully qualified name: kfr::audio_decoder::read_chunk(std::span<const std::byte>, const std::function<bool (std::span<const std::byte>)> &, size_t)
Declared at audio/decoder.hpp:126
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. |
Fully qualified name: kfr::audio_decoder::read_chunk_bytes(std::span<const std::byte>)
Declared at audio/decoder.hpp:135
function close() ¶
virtual void close() = 0 Closes the audio file and releases resources.
Fully qualified name: kfr::audio_decoder::close()
Declared at audio/decoder.hpp:140
function reader() ¶
std::shared_ptr<binary_reader> reader() const noexcept Retrieves the binary reader associated with the decoder.
| Shared pointer to the binary reader. |
Fully qualified name: kfr::audio_decoder::reader()
Declared at audio/decoder.hpp:146
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. |
Fully qualified name: kfr::audio_decoder::read_buffered(const audio_data_interleaved &, const std::function<expected<audio_data_interleaved, audiofile_error> ()> &, audio_data_interleaved &)
Declared at audio/decoder.hpp:156
constructor audio_decoder() ¶
audio_decoder() = default Fully qualified name: kfr::audio_decoder::audio_decoder()
Declared at audio/decoder.hpp:161
variable m_format ¶
std::optional<audiofile_format> m_format Fully qualified name: kfr::audio_decoder::m_format
Declared at audio/decoder.hpp:162
variable m_reader ¶
std::shared_ptr<binary_reader> m_reader Fully qualified name: kfr::audio_decoder::m_reader
Declared at audio/decoder.hpp:163
Fully qualified name: kfr::audio_decoder
Declared at audio/encoder.hpp:31