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 () noexcept SFFDN_NONBLOCKING
 Constructs an empty audio buffer.
 
 AudioBuffer (std::span< float > buffer) noexcept SFFDN_NONBLOCKING
 Constructs a mono audio buffer.
 
 AudioBuffer (uint32_t frame_size, uint32_t channels, std::span< float > buffer) noexcept SFFDN_NONBLOCKING
 Constructs a multi-channel audio buffer.
 
uint32_t SampleCount () const noexcept SFFDN_NONBLOCKING
 Returns the number of samples in one channel of the audio buffer.
 
uint32_t ChannelCount () const noexcept SFFDN_NONBLOCKING
 Returns the number of channels in the audio buffer.
 
float * Data () noexcept SFFDN_NONBLOCKING
 Provides direct access to the audio data.
 
const float * Data () const noexcept SFFDN_NONBLOCKING
 Provides direct access to the audio data.
 
std::span< const float > GetChannelSpan (uint32_t channel) const noexcept SFFDN_NONBLOCKING
 Returns a span representing the audio data for a specific channel.
 
std::span< float > GetChannelSpan (uint32_t channel) noexcept SFFDN_NONBLOCKING
 Returns a span representing the audio data for a specific channel.
 
AudioBuffer GetChannelBuffer (uint32_t channel) const noexcept SFFDN_NONBLOCKING
 Returns an AudioBuffer object representing the audio data for a specific channel.
 
AudioBuffer Offset (uint32_t offset, uint32_t frame_size) const noexcept SFFDN_NONBLOCKING
 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 )
noexcept

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
noexcept

Returns the number of channels in the audio buffer.

Returns
The number of channels.

◆ Data() [1/2]

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

Provides direct access to the audio data.

Returns
A pointer to the audio data.

◆ Data() [2/2]

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

Provides direct access to the audio data.

Returns
A pointer to the audio data.

◆ GetChannelBuffer()

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

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< const float > sfFDN::AudioBuffer::GetChannelSpan ( uint32_t channel) const
noexcept

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< float > sfFDN::AudioBuffer::GetChannelSpan ( uint32_t channel)
noexcept

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
noexcept

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: