Audio Tools


Audio I/O (with PortAudio)

Array< SAMPLE > & record (float NUM_SECONDS=5.0, long SAMPLE_RATE=44100)
 Record a signal from the sound card.
template<class T>
void play (Array< T > &t, long SAMPLE_RATE=44100)
 Plays a signal on the sound card.
int getSampleRate (char *fname)
 Reads the samplerate from a sound file.
Array< float > & loadAudio (char *fname, int &sr)
 Reads the audio data from a WAV file.
int writeAudio (char *fname, Array< float > &r, int sr)
 Writes an audio array into a WAV file.
Array< float > & loadAudio (char *fname)
Array< float > & loadAudio (string &fname, int &sr)
Array< float > & loadAudio (string &fname)
int writeAudio (string &fname, Array< float > &r, int sr)

Function Documentation

int getSampleRate ( char *  fname  ) 

Reads the samplerate from a sound file.

This function opens the input file and returns the data of the samplerate.

Parameters:
fname : path of the file to open

Array<float>& loadAudio ( char *  fname,
int &  sr 
)

Reads the audio data from a WAV file.

This function opens the input file and returns the audio data as a 2D float Array.

Parameters:
fname : path of the WAV file to open
sr : optional parameter to read the samplerate as well

template<class T>
void play ( Array< T > &  t,
long  SAMPLE_RATE = 44100 
) [inline]

Plays a signal on the sound card.

This function plays a stereo signal on the sound card.

Parameters:
t : 2D Array containing the left and right channels,
SAMPLE_RATE is given in Hertz.

Array<SAMPLE>& record ( float  NUM_SECONDS = 5.0,
long  SAMPLE_RATE = 44100 
)

Record a signal from the sound card.

This function records a stereo signal from the sound card, and returns it as a 2D float array.

Parameters:
NUM_SECONDS : duration (in seconds),
SAMPLE_RATE is given in Hertz.

int writeAudio ( char *  fname,
Array< float > &  r,
int  sr 
)

Writes an audio array into a WAV file.

This function opens the input file and returns the audio data as a 2D float Array.

Parameters:
fname : path of the file to write in.
r : 2D float array containing the audio data to save.
sr : samplerate expressed in Hertz.


Generated on Fri Oct 24 18:41:59 2008 for IDIL by  doxygen 1.5.5