libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
AudioFile::Impl Class Reference

Abstract implementation backend for AudioFile. More...

#include <audiofile.h>

Collaboration diagram for AudioFile::Impl:

Public Member Functions

 Impl (Operation op)
 Constructs an Impl for the given operation.
 
virtual ~Impl ()
 Virtual destructor.
 
bool isValid () const
 Returns true if this implementation has a valid operation.
 
Operation operation () const
 Returns the operation type for this implementation.
 
const Stringfilename () 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 (format, channels, sample rate, etc.).
 
void setDesc (const AudioDesc &val)
 Sets the audio description for writing.
 
IODevicedevice () const
 Returns the IODevice associated with this audio file.
 
void setDevice (IODevice *dev)
 Sets the IODevice for this audio file.
 
const StringformatHint () const
 Returns the format hint (e.g. "wav"), no dot.
 
void setFormatHint (const String &val)
 Sets the format hint for device-based operation.
 
virtual Error open ()
 Opens the audio file.
 
virtual void close ()
 Closes the audio file.
 
virtual Error read (Audio &audio, size_t maxSamples)
 Reads audio samples from the file.
 
virtual Error write (const Audio &audio)
 Writes audio samples to the file.
 
virtual Error seekToSample (size_t sample)
 Seeks to a specific sample position in the file.
 
virtual size_t sampleCount () const
 Returns the total number of samples in the file.
 

Protected Attributes

Operation _operation
 
String _filename
 
AudioDesc _desc
 
IODevice_device = nullptr
 
bool _ownsDevice = false
 
String _formatHint
 

Detailed Description

Abstract implementation backend for AudioFile.

Subclasses provide format-specific logic for opening, reading, writing, seeking, and closing audio files.

Constructor & Destructor Documentation

◆ Impl()

AudioFile::Impl::Impl ( Operation  op)
inline

Constructs an Impl for the given operation.

Parameters
opThe operation this implementation will perform.

Member Function Documentation

◆ desc()

AudioDesc AudioFile::Impl::desc ( ) const
inline

Returns the audio description (format, channels, sample rate, etc.).

Returns
The AudioDesc for this file.

◆ device()

IODevice * AudioFile::Impl::device ( ) const
inline

Returns the IODevice associated with this audio file.

Returns
The device pointer, or nullptr if none is set.

◆ filename()

const String & AudioFile::Impl::filename ( ) const
inline

Returns the filename associated with this audio file.

Returns
A const reference to the filename string.

◆ formatHint()

const String & AudioFile::Impl::formatHint ( ) const
inline

Returns the format hint (e.g. "wav"), no dot.

Returns
A const reference to the format hint string.

◆ isValid()

bool AudioFile::Impl::isValid ( ) const
inline

Returns true if this implementation has a valid operation.

Returns
true if the operation is not InvalidOperation.

◆ open()

virtual Error AudioFile::Impl::open ( )
virtual

Opens the audio file.

Returns
Error::Ok on success, or an error on failure.

◆ operation()

Operation AudioFile::Impl::operation ( ) const
inline

Returns the operation type for this implementation.

Returns
The Operation value (Reader or Writer).

◆ read()

virtual Error AudioFile::Impl::read ( Audio audio,
size_t  maxSamples 
)
virtual

Reads audio samples from the file.

Parameters
audioThe Audio object to read into.
maxSamplesMaximum number of samples to read.
Returns
Error::Ok on success, or an error on failure.

◆ sampleCount()

virtual size_t AudioFile::Impl::sampleCount ( ) const
virtual

Returns the total number of samples in the file.

Returns
The sample count.

◆ seekToSample()

virtual Error AudioFile::Impl::seekToSample ( size_t  sample)
virtual

Seeks to a specific sample position in the file.

Parameters
sampleThe sample index to seek to.
Returns
Error::Ok on success, or an error on failure.

◆ setDesc()

void AudioFile::Impl::setDesc ( const AudioDesc val)
inline

Sets the audio description for writing.

Parameters
valThe AudioDesc to set.

◆ setDevice()

void AudioFile::Impl::setDevice ( IODevice dev)
inline

Sets the IODevice for this audio file.

The caller retains ownership of the device; it must outlive this Impl.

Parameters
devThe IODevice to use.

◆ setFilename()

void AudioFile::Impl::setFilename ( const String val)
inline

Sets the filename for this audio file.

Parameters
valThe filename to set.

◆ setFormatHint()

void AudioFile::Impl::setFormatHint ( const String val)
inline

Sets the format hint for device-based operation.

Parameters
valThe format hint (e.g. "wav"), no dot.

◆ write()

virtual Error AudioFile::Impl::write ( const Audio audio)
virtual

Writes audio samples to the file.

Parameters
audioThe Audio object containing samples to write.
Returns
Error::Ok on success, or an error on failure.

The documentation for this class was generated from the following file: