Audio file reader and writer. More...
#include <audiofile.h>
Classes | |
| class | Impl |
| Abstract implementation backend for AudioFile. More... | |
Public Types | |
| enum | Operation { InvalidOperation = 0 , Reader , Writer } |
| The type of operation to perform on an audio file. More... | |
| using | Ptr = SharedPtr< AudioFile > |
| Shared pointer type for AudioFile. | |
Public Member Functions | |
| AudioFile () | |
| Default constructor. Creates an invalid AudioFile. | |
| AudioFile (Impl *impl) | |
| Constructs an AudioFile from an Impl pointer, taking ownership. | |
| bool | isValid () const |
| Returns true if this AudioFile has a valid operation. | |
| Operation | operation () const |
| Returns the operation type (Reader or Writer). | |
| const String & | filename () const |
| Returns the filename associated with this audio file. | |
| void | setFilename (const String &val) |
| Sets the filename for this audio file. | |
| AudioDesc | desc () const |
| Returns the audio description. | |
| void | setDesc (const AudioDesc &val) |
| Sets the audio description for writing. | |
| IODevice * | device () const |
| Returns the IODevice associated with this audio file. | |
| Error | open () |
| Opens the audio file. | |
| void | close () |
| Closes the audio file. | |
| Error | read (Audio &audio, size_t maxSamples) |
| Reads audio samples from the file. | |
| Error | write (const Audio &audio) |
| Writes audio samples to the file. | |
| Error | seekToSample (size_t sample) |
| Seeks to a specific sample position in the file. | |
| size_t | sampleCount () const |
| Returns the total number of samples in the file. | |
Static Public Member Functions | |
| static AudioFile | createForOperation (Operation op, const String &filename) |
| Creates an AudioFile for the given operation and filename. | |
| static Result< AudioFile > | createForOperation (Operation op, IODevice *device, const String &formatHint="") |
| Creates an AudioFile for the given operation using an IODevice. | |
| static AudioFile | createReader (const String &filename) |
| Creates an AudioFile reader for the given filename. | |
| static AudioFile | createWriter (const String &filename) |
| Creates an AudioFile writer for the given filename. | |
Audio file reader and writer.
Provides a high-level interface for reading and writing audio files. The actual file format handling is delegated to an Impl subclass, which is selected automatically via AudioFileFactory based on the filename extension, format hint, or IODevice probe.
All code paths use sf_open_virtual() internally. When a filename is provided without an explicit IODevice, the backend creates an internal File IODevice automatically. An external IODevice can be supplied for non-file backends (e.g. BufferIODevice for in-memory operation).
|
inline |
|
static |
Creates an AudioFile for the given operation using an IODevice.
Uses AudioFileFactory to find an appropriate backend. The device must be seekable (non-sequential) and must outlive the AudioFile.
| op | The operation (Reader or Writer). |
| device | The IODevice to read from or write to. |
| formatHint | Extension hint (e.g. "wav"), no dot. |
|
inline |
Returns the audio description.
|
inline |
Returns the IODevice associated with this audio file.
Returns the filename associated with this audio file.
|
inline |
Returns true if this AudioFile has a valid operation.
|
inline |
Opens the audio file.
|
inline |
Returns the operation type (Reader or Writer).
|
inline |
Returns the total number of samples in the file.
Seeks to a specific sample position in the file.
| sample | The sample index to seek to. |
Sets the audio description for writing.
| val | The AudioDesc to set. |
Sets the filename for this audio file.
| val | The filename to set. |