sfFDN
Loading...
Searching...
No Matches
sfFDN::AudioBuffer Class Reference

A class representing an audio buffer with multiple channels of non-interleaved audio data. More...

#include <audio_buffer.h>

Public Member Functions

 AudioBuffer ()
 Constructs an empty audio buffer.
 
 AudioBuffer (std::span< float > buffer)
 Constructs a mono audio buffer.
 
 AudioBuffer (uint32_t frame_size, uint32_t channels, std::span< float > buffer)
 Constructs a multi-channel audio buffer.
 
uint32_t SampleCount () const
 Returns the number of samples in one channel of the audio buffer.
 
uint32_t ChannelCount () const
 Returns the number of channels in the audio buffer.
 
float * Data ()
 Provides direct access to the audio data.
 
const float * Data () const
 Provides direct access to the audio data.
 
std::span< const float > GetChannelSpan (uint32_t channel) const
 Returns a span representing the audio data for a specific channel.
 
std::span< float > GetChannelSpan (uint32_t channel)
 Returns a span representing the audio data for a specific channel.
 
AudioBuffer GetChannelBuffer (uint32_t channel) const
 Returns an AudioBuffer object representing the audio data for a specific channel.
 
AudioBuffer Offset (uint32_t offset, uint32_t frame_size) const
 Returns a new AudioBuffer where every channel is offset by a certain number of samples.
 

Detailed Description

A class representing an audio buffer with multiple channels of non-interleaved audio data.

The AudioBuffer class does not own the underlying data and expects the data to stay valid for the lifetime of the AudioBuffer instance.

Constructor & Destructor Documentation

◆ AudioBuffer()

sfFDN::AudioBuffer::AudioBuffer ( uint32_t frame_size,
uint32_t channels,
std::span< float > buffer )

Constructs a multi-channel audio buffer.

Parameters
frame_sizeThe number of frames (samples) per channel.
channelsThe number of channels.
bufferA span representing the interleaved audio data. The span must be large enough to hold frame_size
  • channels
samples.

Member Function Documentation

◆ ChannelCount()

uint32_t sfFDN::AudioBuffer::ChannelCount ( ) const

Returns the number of channels in the audio buffer.

Returns
The number of channels.

◆ Data() [1/2]

float * sfFDN::AudioBuffer::Data ( )

Provides direct access to the audio data.

Returns
A pointer to the audio data.

◆ Data() [2/2]

const float * sfFDN::AudioBuffer::Data ( ) const

Provides direct access to the audio data.

Returns
A pointer to the audio data.

◆ GetChannelBuffer()

AudioBuffer sfFDN::AudioBuffer::GetChannelBuffer ( uint32_t channel) const

Returns an AudioBuffer object representing the audio data for a specific channel.

Parameters
channelThe index of the channel to access.
Returns
An AudioBuffer object containing the audio data for the specified channel.

◆ GetChannelSpan() [1/2]

std::span< float > sfFDN::AudioBuffer::GetChannelSpan ( uint32_t channel)

Returns a span representing the audio data for a specific channel.

Parameters
channelThe index of the channel to access.
Returns
A span containing the audio data for the specified channel.

◆ GetChannelSpan() [2/2]

std::span< const float > sfFDN::AudioBuffer::GetChannelSpan ( uint32_t channel) const

Returns a span representing the audio data for a specific channel.

Parameters
channelThe index of the channel to access.
Returns
A span containing the audio data for the specified channel.

◆ SampleCount()

uint32_t sfFDN::AudioBuffer::SampleCount ( ) const

Returns the number of samples in one channel of the audio buffer.

Returns
The number of samples in one channel.

The documentation for this class was generated from the following file: