|
DSPark 1.9.0
Header-only C++20 DSP for real-time and offline audio
|
#include <Mp3File.h>


Public Member Functions | |
| ~Mp3File () override | |
| bool | openRead (const std::filesystem::path &path) override |
| Opens a file for reading. | |
| bool | openWrite (const std::filesystem::path &path, const AudioFileInfo &info) override |
| Opens a file for writing, creating it or overwriting if it exists. | |
| AudioFileInfo | getInfo () const override |
| Retrieves metadata of the currently opened file. | |
| bool | readSamples (AudioBufferView< float > dest) override |
| Reads samples from the start of the file into the destination view. | |
| bool | readSamples (AudioBufferView< float > dest, int64_t startFrame, int64_t numFrames) override |
| Reads a specific range of sample frames. Useful for chunked streaming. | |
| bool | writeSamples (AudioBufferView< const float > src) override |
| Writes samples from the view to the file. | |
| void | close () override |
| Finalizes file headers and releases system handles. | |
| bool | isOpen () const noexcept override |
| Checks if a valid file handle is currently open. | |
| bool | hasWriteError () const noexcept override |
| True when a write, the codec flush or the Info tag patch of the current or most recent writer failed. | |
Public Member Functions inherited from dspark::AudioFile | |
| virtual | ~AudioFile ()=default |
Static Public Attributes | |
| static constexpr uint64_t | kMaxInputBytes = 256ull * 1024 * 1024 |
| Largest input file openRead() accepts. | |
| static constexpr uint64_t | kMaxDecodedPcmBytes = 8ull << 30 |
| Largest decoded length, as float PCM bytes over all channels, of a file openRead() accepts. | |
|
inlineoverridevirtual |
Finalizes file headers and releases system handles.
Safe to call multiple times. Implementations invoke this from their destructor, so an open file is always finalized; call it explicitly, then hasWriteError(), when you need to know that a written file is complete (a destructor cannot report failure), or to release the file before the object dies.
Implements dspark::AudioFile.
|
inlineoverridevirtual |
Retrieves metadata of the currently opened file.
Implements dspark::AudioFile.
|
inlineoverridevirtualnoexcept |
True when a write, the codec flush or the Info tag patch of the current or most recent writer failed.
Remains readable after close() until the next open call.
Reimplemented from dspark::AudioFile.
|
inlineoverridevirtualnoexcept |
Checks if a valid file handle is currently open.
Implements dspark::AudioFile.
|
inlineoverridevirtual |
Opens a file for reading.
Any previously open file is closed first.
| path | File path using C++20 std::filesystem (handles UTF-8/cross-platform safely). |
Implements dspark::AudioFile.
|
inlineoverridevirtual |
Opens a file for writing, creating it or overwriting if it exists.
Any previously open file is closed first.
| path | File path. |
| info | Desired output format metadata. |
Implements dspark::AudioFile.
|
inlineoverridevirtual |
Reads samples from the start of the file into the destination view.
Reads up to min(view length, file length) frames into up to min(view channels, file channels) channels. Excess buffer space and channels beyond those present in the file are left untouched.
| dest | Buffer view to receive the audio data. |
Implements dspark::AudioFile.
|
inlineoverridevirtual |
Reads a specific range of sample frames. Useful for chunked streaming.
The requested range must lie entirely within the file (startFrame >= 0, numFrames > 0, startFrame + numFrames <= numSamples); out-of-range requests return false without reading. As with the full-file overload, the transfer is clamped to the view's capacity.
| dest | Buffer view to receive the audio data. |
| startFrame | The absolute frame index in the file to start reading from. |
| numFrames | The number of frames to read. |
Implements dspark::AudioFile.
|
inlineoverridevirtual |
Writes samples from the view to the file.
Converts float [-1.0, 1.0] back to the native bit-depth defined in openWrite(). May be called repeatedly to append blocks (streaming writes).
| src | Buffer view containing the data to write. |
Implements dspark::AudioFile.
|
staticconstexpr |
Largest decoded length, as float PCM bytes over all channels, of a file openRead() accepts.
|
staticconstexpr |
Largest input file openRead() accepts.