|
DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
|
Complete WAV file reader and writer in pure C++20. More...
#include <WavFile.h>


Public Member Functions | |
| ~WavFile () override | |
| bool | openRead (const std::filesystem::path &path) override |
| Opens a WAV file for reading. | |
| bool | openWrite (const std::filesystem::path &path, const AudioFileInfo &info) override |
| Opens a WAV file for writing, 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. | |
Public Member Functions inherited from dspark::AudioFile | |
| virtual | ~AudioFile ()=default |
Complete WAV file reader and writer in pure C++20.
Inherits from AudioFile to provide a uniform interface. Handles both standard PCM and IEEE float formats, mono through multi-channel (up to 64 channels).
|
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 when you need the write error-checked (a destructor cannot report failure) or the file released before the object dies.
Implements dspark::AudioFile.
|
inlineoverridevirtual |
Retrieves metadata of the currently opened file.
Implements dspark::AudioFile.
|
inlineoverridevirtualnoexcept |
Checks if a valid file handle is currently open.
Implements dspark::AudioFile.
|
inlineoverridevirtual |
Opens a WAV file for reading.
| path | Platform-independent path to the WAV file. |
Implements dspark::AudioFile.
|
inlineoverridevirtual |
Opens a WAV file for writing, overwriting if it exists.
The requested format is validated BEFORE the destination is touched: an unsupported format returns false without creating or truncating anything on disk.
| path | Platform-independent output path. |
| info | Configuration for sample rate, bit depth, and channels. |
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.