AudioBuffer is a buffer of audio data. More...
#include <Audio/AudioBuffer.H>
Public Member Functions | |
Constructors, destructors, assignment | |
AudioBuffer (const T *data, const uint nsampl, const uint nchan, const float freq) | |
Constructor from raw data. | |
AudioBuffer (const uint nsampl, const uint nchan, const float freq, InitPolicy init) | |
Allocate memory for future data. | |
AudioBuffer (const AudioBuffer< T > &A) | |
Copy constructor. | |
AudioBuffer< T > & | operator= (const AudioBuffer< T > &A) |
Assigment operator. | |
AudioBuffer () | |
Empty constructor. | |
~AudioBuffer () | |
Destructor. | |
Access functions | |
uint | nsamples () const |
Get number of samples. | |
uint | nchans () const |
Get number of channels. | |
float | freq () const |
Get sampling frequency in samples/s. | |
void | setFreq (const float f) |
Set sampling frequency in samples/s. | |
const T & | getVal (const uint sample, const uint channel) |
Get a sample. | |
uint | size () const |
Get total data size in number of T's. | |
uint | sizeBytes () const |
Get total data size in bytes. | |
const T * | getDataPtr () const |
Get a read-only pointer to the raw data. | |
T * | getDataPtr () |
Get a read/write pointer to the raw data. |
AudioBuffer is a buffer of audio data.
AudioBuffer has copy-on-write/ref-counting semantics and automatic memory management, just like Image does. The template argument specifies the type of the audio data (typically, byte, or int16).
Definition at line 48 of file AudioBuffer.H.
AudioBuffer< T >::AudioBuffer | ( | const T * | data, | |
const uint | nsampl, | |||
const uint | nchan, | |||
const float | freq | |||
) | [inline] |
Constructor from raw data.
Definition at line 122 of file AudioBuffer.H.
AudioBuffer< T >::AudioBuffer | ( | const uint | nsampl, | |
const uint | nchan, | |||
const float | freq, | |||
InitPolicy | init | |||
) | [inline] |
Allocate memory for future data.
Definition at line 130 of file AudioBuffer.H.
AudioBuffer< T >::AudioBuffer | ( | const AudioBuffer< T > & | A | ) | [inline] |
Copy constructor.
Definition at line 138 of file AudioBuffer.H.
AudioBuffer< T >::AudioBuffer | ( | ) | [inline] |
Empty constructor.
Definition at line 155 of file AudioBuffer.H.
AudioBuffer< T >::~AudioBuffer | ( | ) | [inline] |
Destructor.
Definition at line 162 of file AudioBuffer.H.
float AudioBuffer< T >::freq | ( | ) | const [inline] |
Get sampling frequency in samples/s.
Definition at line 177 of file AudioBuffer.H.
T * AudioBuffer< T >::getDataPtr | ( | ) | [inline] |
Get a read/write pointer to the raw data.
Definition at line 210 of file AudioBuffer.H.
const T * AudioBuffer< T >::getDataPtr | ( | ) | const [inline] |
Get a read-only pointer to the raw data.
Definition at line 205 of file AudioBuffer.H.
Referenced by AudioGrabber::grab(), readAudioWavFile(), and RadioDecoder::run().
const T & AudioBuffer< T >::getVal | ( | const uint | sample, | |
const uint | channel | |||
) | [inline] |
Get a sample.
Definition at line 187 of file AudioBuffer.H.
References ASSERT, AudioBuffer< T >::nchans(), and AudioBuffer< T >::nsamples().
Referenced by plotData(), and saveData().
uint AudioBuffer< T >::nchans | ( | ) | const [inline] |
Get number of channels.
Definition at line 172 of file AudioBuffer.H.
Referenced by AudioBuffer< T >::getVal(), AudioBuffer< T >::size(), and AudioBuffer< T >::sizeBytes().
uint AudioBuffer< T >::nsamples | ( | ) | const [inline] |
Get number of samples.
Definition at line 167 of file AudioBuffer.H.
Referenced by AudioBuffer< T >::getVal(), RadioDecoder::run(), saveData(), AudioBuffer< T >::size(), and AudioBuffer< T >::sizeBytes().
AudioBuffer< T > & AudioBuffer< T >::operator= | ( | const AudioBuffer< T > & | A | ) | [inline] |
Assigment operator.
Definition at line 145 of file AudioBuffer.H.
void AudioBuffer< T >::setFreq | ( | const float | f | ) | [inline] |
Set sampling frequency in samples/s.
Definition at line 182 of file AudioBuffer.H.
uint AudioBuffer< T >::size | ( | ) | const [inline] |
Get total data size in number of T's.
This is nsamples * nchans
Definition at line 195 of file AudioBuffer.H.
References AudioBuffer< T >::nchans(), and AudioBuffer< T >::nsamples().
uint AudioBuffer< T >::sizeBytes | ( | ) | const [inline] |
Get total data size in bytes.
This is nsamples * nchans * sizeof(T)
Definition at line 200 of file AudioBuffer.H.
References AudioBuffer< T >::nchans(), and AudioBuffer< T >::nsamples().
Referenced by AudioGrabber::grab().