24#include "../Core/AudioBuffer.h"
25#include "../Core/AudioSpec.h"
83 const int64_t clamped = std::clamp<int64_t>(
84 numSamples, 0, std::numeric_limits<int>::max());
85 const int safeFullLength =
static_cast<int>(clamped);
89 .maxBlockSize = (defaultBlockSize > 0) ? defaultBlockSize : safeFullLength,
119 [[nodiscard]]
virtual bool openRead(
const std::filesystem::path& path) = 0;
165 int64_t startFrame, int64_t numFrames) = 0;
189 [[nodiscard]]
virtual bool isOpen() const noexcept = 0;
Non-owning view over audio channel data.
Abstract base class for audio file readers and writers.
virtual bool openRead(const std::filesystem::path &path)=0
Opens a file for reading.
virtual bool isOpen() const noexcept=0
Checks if a valid file handle is currently open.
virtual bool readSamples(AudioBufferView< float > dest, int64_t startFrame, int64_t numFrames)=0
Reads a specific range of sample frames. Useful for chunked streaming.
virtual ~AudioFile()=default
virtual bool writeSamples(AudioBufferView< const float > src)=0
Writes samples from the view to the file.
virtual AudioFileInfo getInfo() const =0
Retrieves metadata of the currently opened file.
virtual bool openWrite(const std::filesystem::path &path, const AudioFileInfo &info)=0
Opens a file for writing, creating it or overwriting if it exists.
virtual bool readSamples(AudioBufferView< float > dest)=0
Reads samples from the start of the file into the destination view.
virtual void close()=0
Finalizes file headers and releases system handles.
Main namespace for the DSPark framework.
Metadata describing an audio file's format and dimensions.
uint32_t numChannels
Number of audio channels (1 = mono, 2 = stereo).
bool isFloatingPoint
True if the file stores floating-point samples (IEEE 754).
uint32_t bitsPerSample
Bits per sample in the stored format (8, 16, 24, 32, 64).
AudioSpec toSpec(int defaultBlockSize=0) const noexcept
Converts this file info to an AudioSpec for processor preparation.
double sampleRate
Sample rate in Hz (e.g., 44100.0, 48000.0, 96000.0).
int64_t numSamples
Total number of sample frames in the file.
Describes the audio environment for a DSP processor.