Switchboard SDK
|
Provides an abstraction around raw audio buffers stored in memory. More...
#include <AudioBuffer.hpp>
Public Member Functions | |
WASM | AudioBuffer (uint numberOfChannels, uint numberOfFrames, bool isInterleaved, uint sampleRate, T **data) |
Creates an AudioBuffer instance from already allocated memory. | |
AudioBuffer (uint numberOfChannels, uint numberOfFrames, uint sampleRate, T *data) | |
Creates a mono or interleaved AudioBuffer instance from already allocated memory. | |
WASM uint | getNumberOfChannels () const |
Returns the number of channels stored in the audio buffer. | |
WASM uint | getNumberOfFrames () const |
Returns the number of frames stored in the audio buffer. | |
WASM void | setNumberOfFrames (const uint newNumberOfFrames) |
Sets the number of frames in the buffer. | |
WASM bool | getIsInterleaved () const |
Returns whether the audio buffer contains interleaved or non-interleaved data. Always false if the audio buffer is mono. | |
WASM uint | getSampleRate () const |
Gets the sample rate of the audio buffer. | |
WASM void | setSampleRate (const uint newSampleRate) |
Sets the sample rate of the audio buffer. | |
WASM bool | isMono () const |
Returns whether the audio buffer is mono. | |
WASM T | getSample (uint channel, uint sampleIndex) const |
Returns a sample value from the audio buffer. | |
WASM void | setSample (uint channel, uint sampleIndex, T value) |
Sets a sample value in the audio buffer. | |
WASM const T * | getReadPointer (uint channel) const |
Returns a read pointer to the data for a channel in the audio buffer. | |
WASM T * | getWritePointer (uint channel) |
Returns a write pointer to the data for a channel in the audio buffer. | |
const T ** | getReadPointer () const |
Returns a read pointer to the data in the audio buffer. | |
T ** | getWritePointer () |
Returns a write pointer to the data in the audio buffer. | |
void | copyFrom (const AudioBuffer< T > &srcBuffer) |
Copies data from another AudioBuffer instance. | |
void | clear () |
Sets all audio sample values to zero. | |
Provides an abstraction around raw audio buffers stored in memory.
AudioBuffer template class.
Can be used with multiple data types such as AudioBuffer<float> or AudioBuffer<int16>.
switchboard::AudioBuffer< T >::AudioBuffer | ( | uint | numberOfChannels, |
uint | numberOfFrames, | ||
bool | isInterleaved, | ||
uint | sampleRate, | ||
T ** | data ) |
Creates an AudioBuffer instance from already allocated memory.
numberOfChannels | The number of channels. |
numberOfFrames | The number of frames. |
isInterleaved | Flag indicating whether audio data should be interleaved or non-interleaved. Only effective when numberOfChannels > 1. |
sampleRate | The sample rate of the audio buffer. |
data | Pointer to the pre-allocated stacked audio memory location. |
switchboard::AudioBuffer< T >::AudioBuffer | ( | uint | numberOfChannels, |
uint | numberOfFrames, | ||
uint | sampleRate, | ||
T * | data ) |
Creates a mono or interleaved AudioBuffer instance from already allocated memory.
numberOfChannels | The number of channels. |
numberOfFrames | The number of frames. |
sampleRate | The sample rate of the audio buffer. |
data | Pointer to the pre-allocated mono or interleaved memory location. |
void switchboard::AudioBuffer< T >::copyFrom | ( | const AudioBuffer< T > & | srcBuffer | ) |
Copies data from another AudioBuffer instance.
Number of channels, number of frames and interleavedness have to be identical in the two audio buffers.
srcBuffer | The source buffer to copy data from. |
bool switchboard::AudioBuffer< T >::getIsInterleaved | ( | ) | const |
Returns whether the audio buffer contains interleaved or non-interleaved data. Always false if the audio buffer is mono.
uint switchboard::AudioBuffer< T >::getNumberOfChannels | ( | ) | const |
Returns the number of channels stored in the audio buffer.
uint switchboard::AudioBuffer< T >::getNumberOfFrames | ( | ) | const |
Returns the number of frames stored in the audio buffer.
const T ** switchboard::AudioBuffer< T >::getReadPointer | ( | ) | const |
Returns a read pointer to the data in the audio buffer.
const T * switchboard::AudioBuffer< T >::getReadPointer | ( | uint | channel | ) | const |
Returns a read pointer to the data for a channel in the audio buffer.
channel | The index of the channel. |
T switchboard::AudioBuffer< T >::getSample | ( | uint | channel, |
uint | sampleIndex ) const |
Returns a sample value from the audio buffer.
channel | The index of the channel. |
sampleIndex | The index of the sample. |
uint switchboard::AudioBuffer< T >::getSampleRate | ( | ) | const |
Gets the sample rate of the audio buffer.
T ** switchboard::AudioBuffer< T >::getWritePointer | ( | ) |
Returns a write pointer to the data in the audio buffer.
T * switchboard::AudioBuffer< T >::getWritePointer | ( | uint | channel | ) |
Returns a write pointer to the data for a channel in the audio buffer.
channel | The index of the channel. |
bool switchboard::AudioBuffer< T >::isMono | ( | ) | const |
Returns whether the audio buffer is mono.
void switchboard::AudioBuffer< T >::setNumberOfFrames | ( | const uint | newNumberOfFrames | ) |
Sets the number of frames in the buffer.
newNumberOfFrames | The new number of frames. |
void switchboard::AudioBuffer< T >::setSample | ( | uint | channel, |
uint | sampleIndex, | ||
T | value ) |
Sets a sample value in the audio buffer.
channel | The index of the channel. |
sampleIndex | The index of the sample. |
value | The sample value to set. |
void switchboard::AudioBuffer< T >::setSampleRate | ( | const uint | newSampleRate | ) |
Sets the sample rate of the audio buffer.
newSampleRate | The new sample rate. |