AudioBuffer¶
class AudioBuffer
Represents an audio buffer containing multiple channels.
An AudioBuffer
is a de-interleaved memory storage used to store and manipulate audio data, such as audio samples or Ambisonics sound fields, in a flexible and efficient manner. Accessing a channel data will return an AudioBufferChannel
object, which is a view to the memory range storing that channel.
- See
- AudioBufferChannel
Operators¶
Name | Description |
---|---|
operator[] | Gets the AudioBufferChannel at the specified index. |
operator[] | Gets the AudioBufferChannel at the specified index. |
operator= | Copies the audio buffer data from the provided AudioBuffer . |
operator+= | Accumulates the audio buffer data from the provided AudioBuffer . |
operator-= | Subtracts the audio buffer data from the provided AudioBuffer . |
operator*= | Point-wise multiplies the audio buffer data with the provided AudioBuffer . |
operator*= | Point-wise multiplies this channel with the provided scalar. |
Functions¶
Name | Description |
---|---|
Copy | Copies the given number of frames from the source buffer to the destination buffer. |
AudioBuffer | Creates an empty audio buffer. |
AudioBuffer | Creates an audio buffer with the specified number of frames and channels. |
AudioBuffer | Explicitly deletes the audio buffer copy to avoid unintended usage. |
AudioBuffer | Moves the given audio buffer data in this one. |
~AudioBuffer | Destroys the audio buffer data and release allocated memory. |
IsEmpty | Check if the audio buffer is empty. |
GetFrameCount | Gets the number of frames in the buffer. |
GetChannelCount | Gets the number of channels in the buffer. |
Clear | Sets the entire audio buffer data to zero. |
GetData | Gets the wrapped audio buffer data. |
GetChannel | Gets the AudioBufferChannel at the specified index. |
GetChannel | Gets the AudioBufferChannel at the specified index. |
Clone | Clones the audio buffer and returns a new instance. |
Operator Details¶
operator*=¶
AudioBuffer& operator*=(const AudioBuffer& buffer)
Point-wise multiplies the audio buffer data with the provided AudioBuffer
.
- Parameter
buffer
- The buffer to multiply with this one.
- Return
- This instance with the multiplied audio buffer data.
AudioBuffer& operator*=(AmReal32 scalar)
Point-wise multiplies this channel with the provided scalar.
- Parameter
scalar
- The scalar to multiply with.
- Return
- A reference to the modified channel.
operator+=¶
AudioBuffer& operator+=(const AudioBuffer& buffer)
Accumulates the audio buffer data from the provided AudioBuffer
.
- Parameter
buffer
- The buffer to add in this one.
- Return
- This instance with the added audio buffer data.
operator-=¶
AudioBuffer& operator-=(const AudioBuffer& buffer)
Subtracts the audio buffer data from the provided AudioBuffer
.
- Parameter
buffer
- The buffer to subtract from this one.
- Return
- This instance with the subtracted audio buffer data.
operator=¶
AudioBuffer& operator=(const AudioBuffer& buffer)
Copies the audio buffer data from the provided AudioBuffer
.
- Parameter
buffer
- The other audio buffer to copy.
- Return
- This instance with the copied audio buffer data.
operator[]¶
Gets the AudioBufferChannel
at the specified index.
- Parameter
index
- The channel index.
- Return
- The
AudioBufferChannel
at the specified index.
[[nodiscard]] const AudioBufferChannel& operator const
Gets the AudioBufferChannel
at the specified index.
- Parameter
index
- The channel index.
- Return
- The
AudioBufferChannel
at the specified index.
Function Details¶
AudioBuffer¶
AudioBuffer()
Creates an empty audio buffer.
AudioBuffer(AmSize numFrames, AmSize numChannels)
Creates an audio buffer with the specified number of frames and channels.
- Parameter
numFrames
- The number of frames in the buffer.
- Parameter
numChannels
- The number of channels in the buffer.
AudioBuffer(const AudioBuffer& buffer) = delete
Explicitly deletes the audio buffer copy to avoid unintended usage.
- Parameter
buffer
- The other audio buffer to copy.
Note
Use the assignment operator to copy the audio buffer.
AudioBuffer(AudioBuffer&& buffer) noexcept
Moves the given audio buffer data in this one.
- Parameter
buffer
- The other audio buffer to move.
Clear¶
void Clear()
Sets the entire audio buffer data to zero.
Clone¶
AudioBuffer Clone() const
Clones the audio buffer and returns a new instance.
- Return
- A new instance with a cloned copy of the audio buffer data.
Copy¶
static void Copy( const AudioBuffer& source, AmSize sourceOffset, AudioBuffer& destination, AmSize destinationOffset, AmSize numFrames)
Copies the given number of frames from the source buffer to the destination buffer.
- Parameter
source
- The source buffer to copy.
- Parameter
sourceOffset
- The offset in the source buffer.
- Parameter
destination
- The destination buffer to copy to.
- Parameter
destinationOffset
- The offset in the destination buffer.
- Parameter
numFrames
- The number of frames to copy.
GetChannel¶
AudioBufferChannel& GetChannel(AmSize index)
Gets the AudioBufferChannel
at the specified index.
- Parameter
index
- The channel index.
- Return
- The
AudioBufferChannel
at the specified index.
[[nodiscard]] const AudioBufferChannel& GetChannel(AmSize index) const
Gets the AudioBufferChannel
at the specified index.
- Parameter
index
- The channel index.
- Return
- The
AudioBufferChannel
at the specified index.
GetChannelCount¶
[[nodiscard]] AmSize GetChannelCount() const
Gets the number of channels in the buffer.
- Return
- The number of channels in the buffer.
GetData¶
[[nodiscard]] const AmAlignedReal32Buffer& GetData() const
Gets the wrapped audio buffer data.
- Return
- The wrapped audio buffer data.
GetFrameCount¶
[[nodiscard]] AmSize GetFrameCount() const
Gets the number of frames in the buffer.
- Return
- The number of frames in the buffer.
IsEmpty¶
[[nodiscard]] bool IsEmpty() const
Check if the audio buffer is empty.
- Return
true
if the audio buffer is empty,false
otherwise.
~AudioBuffer¶
~AudioBuffer()
Destroys the audio buffer data and release allocated memory.