Inheritance diagram for Exponent::Audio::IAudioFileFormat< TypeName >:
The IAudioFileFormat defines a template interface that should inherited from
during the creation of actual file formats, such as WAVE, AIFF etc.
In use the file format is somewhat complex, but made clearer by looking at code
Below is an example of usage:
READING
// First we open the file TWaveFileFormat<double> waveFileFormat; if (!waveFileFormat.openFile(CFileStream::e_input, myFileName)) { printf("Failed to open file"); return; } // Now we read in the format header TWaveFileFormat<double>::SAudioFileFormat format; if (!waveFileFormat.readHeader(format)) { printf("Failed to read header"); return; } // Now create an initialiase an audio buffer TAudioBuffer<double> audio; audio.initialise(format.m_numberOfSamples, format.m_numberOfChannels); // Now read in the audio data, in range -1 to +1\n if (!waveFileFormat.readData(audio)) { printf("Failed to read data"); return; }
// First we open the file TWaveFileFormat<double> waveFileFormat; if (!waveFileFormat.openFile(CFileStream::e_output, myFileName)) { printf("Failed to open file"); return; } // Now create the format to write to TWaveFileFormat<double>::SAudioFileFormat format; format.m_bitDepth = 16; // OR 8 OR 24 format.m_sampleRate = 44100; // Anything you like format.m_numberOfChannels = 2; // Anything you like format.m_numberOfSamples = 1024; // However many there are! // Now write the header if (!waveFileFormat.writeHeader(format)) { printf("Failed to write file header"); return; } // Now write the data if (!waveFileFormat.writeData(myAudioBuffer)) { printf("FAiled to write audio file"); return; }
Definition at line 109 of file IAudioFileFormat.hpp.
enum Exponent::Audio::IAudioFileFormat::EBitDepth |
Represents currently supported bit depths.
Definition at line 133 of file IAudioFileFormat.hpp.
Exponent::Audio::IAudioFileFormat< TypeName >::IAudioFileFormat | ( | ) | [inline] |
Construction
Definition at line 145 of file IAudioFileFormat.hpp.
virtual Exponent::Audio::IAudioFileFormat< TypeName >::~IAudioFileFormat | ( | ) | [inline, virtual] |
Destruction
Definition at line 150 of file IAudioFileFormat.hpp.
virtual bool Exponent::Audio::IAudioFileFormat< TypeName >::closeFile | ( | ) | [pure virtual] |
Close the file
bool | True if closed properly, false otherwise |
Implemented in Exponent::Audio::TAiffFileFormat< TypeName >, and Exponent::Audio::TWaveFileFormat< TypeName >.
virtual void Exponent::Audio::IAudioFileFormat< TypeName >::getFileExtension | ( | TStringCountedPointerArray & | array | ) | const [pure virtual] |
Get the extension of the file format, each array entry sould contain one string
array | The array to fill in |
Implemented in Exponent::Audio::TAiffFileFormat< TypeName >, and Exponent::Audio::TWaveFileFormat< TypeName >.
virtual bool Exponent::Audio::IAudioFileFormat< TypeName >::isValidFormat | ( | const CSystemString & | filename | ) | const [pure virtual] |
Check if a file is a valid format of this file format
filename | The name of the file to load |
bool | True if the file format matches (checks actual binary data, not just extension |
virtual bool Exponent::Audio::IAudioFileFormat< TypeName >::openFile | ( | CFileStream::EStreamMode | mode, | |
const CSystemString & | filename | |||
) | [pure virtual] |
Open the file
mode | The mode of opening, read or write | |
filename | The name of the file to open |
bool | True if stream is opened |
virtual bool Exponent::Audio::IAudioFileFormat< TypeName >::readData | ( | TAudioBuffer< TypeName > & | data | ) | [pure virtual] |
Read the entire audio file to the provided audio buffer
data | The data buffer to store te samples in |
bool | True if read correctly, false otherwise |
Implemented in Exponent::Audio::TAiffFileFormat< TypeName >, and Exponent::Audio::TWaveFileFormat< TypeName >.
virtual bool Exponent::Audio::IAudioFileFormat< TypeName >::readHeader | ( | SAudioFileFormat & | format | ) | [pure virtual] |
Read the header information and store a copy in the format
format | On return is filled with the values for this audio file |
bool | True if read the header correctly, false otherwise |
virtual bool Exponent::Audio::IAudioFileFormat< TypeName >::writeData | ( | const TAudioBuffer< TypeName > & | data | ) | [pure virtual] |
Write the entire audio file to the provided audio buffer
data | The data buffer to store |
bool | True if written correctly, false otherwise |
Implemented in Exponent::Audio::TAiffFileFormat< TypeName >, and Exponent::Audio::TWaveFileFormat< TypeName >.
virtual bool Exponent::Audio::IAudioFileFormat< TypeName >::writeHeader | ( | const SAudioFileFormat & | format | ) | [pure virtual] |
Write the header information and from the format
format | The format to write in |
bool | True if wrote the header correctly, false otherwise |