Exponent::Audio::IAudioFileFormat< TypeName > Interface Template Reference

Inheritance diagram for Exponent::Audio::IAudioFileFormat< TypeName >:

Exponent::Audio::TAiffFileFormat< TypeName > Exponent::Audio::TWaveFileFormat< TypeName > List of all members.

Detailed Description

template<typename TypeName>
interface Exponent::Audio::IAudioFileFormat< TypeName >

Interface to an audio file format.

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;
 }


WRITING

 // 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;
 }

Date:
13/04/2006
Author:
Paul Chana
Version:
1.0.0 Initial version
Note:
All contents of this source code are copyright 2005 Exp Digital Uk.
This source file is covered by the licence conditions of the Infinity API. You should have recieved a copy
with the source code. If you didnt, please refer to http://www.expdigital.co.uk All content is the Intellectual property of Exp Digital Uk.
Certain sections of this code may come from other sources. They are credited where applicable.
If you have comments, suggestions or bug reports please visit http://support.expdigital.co.uk
Id
IAudioFileFormat.hpp,v 1.6 2007/02/08 21:08:09 paul Exp

Definition at line 109 of file IAudioFileFormat.hpp.

Public Types

Public Member Functions

Classes


Member Enumeration Documentation

template<typename TypeName>
enum Exponent::Audio::IAudioFileFormat::EBitDepth

Represents currently supported bit depths.

IAudioFileFormat.hpp

Enumerator:
e_eightBit  8 bit
e_sixteenBit  16 bit
e_twentyFourBit  24 bit

Definition at line 133 of file IAudioFileFormat.hpp.


Constructor & Destructor Documentation

template<typename TypeName>
Exponent::Audio::IAudioFileFormat< TypeName >::IAudioFileFormat (  )  [inline]

Construction

Definition at line 145 of file IAudioFileFormat.hpp.

template<typename TypeName>
virtual Exponent::Audio::IAudioFileFormat< TypeName >::~IAudioFileFormat (  )  [inline, virtual]

Destruction

Definition at line 150 of file IAudioFileFormat.hpp.


Member Function Documentation

template<typename TypeName>
virtual bool Exponent::Audio::IAudioFileFormat< TypeName >::closeFile (  )  [pure virtual]

Close the file

Return values:
bool True if closed properly, false otherwise

Implemented in Exponent::Audio::TAiffFileFormat< TypeName >, and Exponent::Audio::TWaveFileFormat< TypeName >.

template<typename 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

Parameters:
array The array to fill in

Implemented in Exponent::Audio::TAiffFileFormat< TypeName >, and Exponent::Audio::TWaveFileFormat< TypeName >.

template<typename 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

Parameters:
filename The name of the file to load
Return values:
bool True if the file format matches (checks actual binary data, not just extension

template<typename TypeName>
virtual bool Exponent::Audio::IAudioFileFormat< TypeName >::openFile ( CFileStream::EStreamMode  mode,
const CSystemString filename 
) [pure virtual]

Open the file

Parameters:
mode The mode of opening, read or write
filename The name of the file to open
Return values:
bool True if stream is opened

template<typename TypeName>
virtual bool Exponent::Audio::IAudioFileFormat< TypeName >::readData ( TAudioBuffer< TypeName > &  data  )  [pure virtual]

Read the entire audio file to the provided audio buffer

Parameters:
data The data buffer to store te samples in
Return values:
bool True if read correctly, false otherwise

Implemented in Exponent::Audio::TAiffFileFormat< TypeName >, and Exponent::Audio::TWaveFileFormat< TypeName >.

template<typename TypeName>
virtual bool Exponent::Audio::IAudioFileFormat< TypeName >::readHeader ( SAudioFileFormat format  )  [pure virtual]

Read the header information and store a copy in the format

Parameters:
format On return is filled with the values for this audio file
Return values:
bool True if read the header correctly, false otherwise

template<typename TypeName>
virtual bool Exponent::Audio::IAudioFileFormat< TypeName >::writeData ( const TAudioBuffer< TypeName > &  data  )  [pure virtual]

Write the entire audio file to the provided audio buffer

Parameters:
data The data buffer to store
Return values:
bool True if written correctly, false otherwise

Implemented in Exponent::Audio::TAiffFileFormat< TypeName >, and Exponent::Audio::TWaveFileFormat< TypeName >.

template<typename TypeName>
virtual bool Exponent::Audio::IAudioFileFormat< TypeName >::writeHeader ( const SAudioFileFormat format  )  [pure virtual]

Write the header information and from the format

Parameters:
format The format to write in
Return values:
bool True if wrote the header correctly, false otherwise


Infinity API - Exponent::Audio::IAudioFileFormat< TypeName > Interface Template Reference generated on 7 Mar 2007