AME
ame::AudioBuffer< FloatType, Size > Class Template Reference

An audio buffer that supports multiple channels whose size is determined at compile time. More...

#include <ame_AudioBuffer.hpp>

Public Member Functions

 AudioBuffer (const uint_fast32_t numChannels)
 
void setNumChannels (const uint_fast32_t channels)
 Set the number of channels. More...
 
uint_fast32_t getNumChannels () const noexcept
 Returns the number of channels.
 
uint_fast32_t getNumSamplesPerChannel () const noexcept
 Returns the number of samples per channel.
 
void clear ()
 Set all samples to 0.
 
void applyGain (const float gain)
 Applies a gain multiple to all the audio data.
 
auto makeAudioBlockView (uint_fast32_t offset=0, uint_fast32_t size=Size)
 Returns an AudioBlockView that references N elements from an arbitrary position. More...
 
template<size_t Extent>
void addFrom (const uint_fast32_t destChannel, const uint_fast32_t destStartSample, const AudioBlockView< FloatType, Extent > &source, const uint_fast32_t sourceChannel, const uint_fast32_t sourceStartSample, const uint_fast32_t numSamplesToAdd)
 addBuffer
 
FloatType getPeak (const uint_fast32_t channel) const
 Finds the highest absolute sample value within a region of a channel. More...
 
FloatType getRMSLevel (const uint_fast32_t channel) const
 Returns the root mean squared level for a region of a channel. More...
 

Public Attributes

std::array< FloatType, Size > buffer = {}
 

Detailed Description

template<typename FloatType, size_t Size>
class ame::AudioBuffer< FloatType, Size >

An audio buffer that supports multiple channels whose size is determined at compile time.

Attention
Channel order is interleaved.
Template Parameters
SampleType
SizeTotal length of buffer

Member Function Documentation

◆ getPeak()

template<typename FloatType , size_t Size>
FloatType ame::AudioBuffer< FloatType, Size >::getPeak ( const uint_fast32_t  channel) const
inline

Finds the highest absolute sample value within a region of a channel.

Parameters
channel
Returns
FloatType [0.0, FloatTypeMax]

◆ getRMSLevel()

template<typename FloatType , size_t Size>
FloatType ame::AudioBuffer< FloatType, Size >::getRMSLevel ( const uint_fast32_t  channel) const
inline

Returns the root mean squared level for a region of a channel.

Parameters
channel
Returns
FloatType RMS level [0.0, FloatTypeMax]

◆ makeAudioBlockView()

template<typename FloatType , size_t Size>
auto ame::AudioBuffer< FloatType, Size >::makeAudioBlockView ( uint_fast32_t  offset = 0,
uint_fast32_t  size = Size 
)
inline

Returns an AudioBlockView that references N elements from an arbitrary position.

Parameters
offsetStart location
sizeNumber of elements
Returns
ame::AudioBlockView
See also
std::span::subspan()
ame::AudioBlockView::subView()
Attention
Be careful that size is NOT the number of samples per channel, but the size of std::span.

◆ setNumChannels()

template<typename FloatType , size_t Size>
void ame::AudioBuffer< FloatType, Size >::setNumChannels ( const uint_fast32_t  channels)
inline

Set the number of channels.

Update numSamples (number of samples per channel) based on the buffer length.

Parameters
channelsnumber of channels

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