HART  0.2.0
High level Audio Regression and Testing
Loading...
Searching...
No Matches
AudioBuffer< SampleType > Class Template Reference

Container for audio data. More...

#include <hart_audio_buffer.hpp>

Public Member Functions

 AudioBuffer (size_t numChannels=0, size_t numFrames=0, double sampleRateHz=nan< double >())
 Creates an audio buffer.
 
 AudioBuffer (const AudioBuffer &other)
 Creates an audio buffer by copying.
 
 AudioBuffer (AudioBuffer &&other) noexcept
 Creates an audio buffer by moving.
 
 ~AudioBuffer ()=default
 The destructor.
 
AudioBufferoperator= (const AudioBuffer &other)
 Creates an audio buffer by copy-assigning.
 
AudioBufferoperator= (AudioBuffer &&other) noexcept
 Creates an audio buffer by move-assigning.
 
const SampleType *const * getArrayOfReadPointers () const
 Gets a raw pointer to the read-only audio data.
 
SampleType *const * getArrayOfWritePointers ()
 Gets a raw pointer to the mutable audio data.
 
size_t getNumChannels () const
 Get number of channels.
 
size_t getNumFrames () const
 Get number of frames (samples)
 
void setNumFrames (size_t newNumFrames)
 Resizes the buffer to hold a new number of frames per channel.
 
bool hasSampleRate () const
 Check if a specific sample rate was assigned to the audio buffer.
 
double getSampleRateHz () const
 Get a sample rate metadata.
 
double getLengthSeconds () const
 Get a duration of the audio buffer.
 
SampleType * operator[] (size_t channel)
 Get a raw pointer to a specific channel's mutable audio data.
 
const SampleType * operator[] (size_t channel) const
 Get a raw pointer to a specific channel's read-only audio data.
 
bool equalsTo (const AudioBuffer &other, SampleType toleranceLinear=(SampleType) 1e-6) const
 Checks whether this buffer contains approximately the same audio as another buffer.
 
bool operator== (const AudioBuffer &other) const
 Checks whether two buffers contain approximately the same audio.
 
bool operator!= (const AudioBuffer &other) const
 Checks whether two buffers differ beyond the default comparison tolerance.
 
void appendFrom (const AudioBuffer< SampleType > &otherBuffer)
 Appends data from another buffer.
 
void erase ()
 Clears the buffer.
 
SampleType getMagnitude (size_t channel, size_t startFrame, size_t numFrames) const
 Get the maximum absolute value in the buffer in a specific channel.
 
SampleType getMagnitude (size_t startFrame, size_t numFrames) const
 Get the maximum absolute value in the buffer across all channels.
 
void copyFrom (size_t destChannel, size_t destStartFrame, const AudioBuffer &source, size_t sourceChannel, size_t sourceStartFrame, size_t numFrames)
 Copies audio from another buffer.
 
void copyFrom (size_t destChannel, size_t destStartFrame, const SampleType *source, size_t numFrames)
 Copies audio from another generic audio buffer.
 
void clear ()
 Clears the entire buffer.
 
void clear (size_t channel, size_t startFrame, size_t numFrames)
 Clears a specific section of a given channel.
 
void represent (std::ostream &stream) const
 Prints readable representation of the audio buffer.
 
AudioBuffer< SampleType > & fillWith (SignalBase< SampleType > &signal, size_t blockSizeFrames=0, Preparation signalPreparation=Preparation::resetAndPrepare) &
 Fills this AudioBuffer by rendering audio from a Signal.
 
AudioBuffer< SampleType > & fillWith (SignalBase< SampleType > &&signal, size_t blockSizeFrames=0, Preparation signalPreparation=Preparation::resetAndPrepare) &
 Fills this AudioBuffer by rendering audio from a Signal.
 
AudioBuffer< SampleType > && fillWith (SignalBase< SampleType > &signal, size_t blockSizeFrames=0, Preparation signalPreparation=Preparation::resetAndPrepare) &&
 Fills this AudioBuffer by rendering audio from a Signal.
 
AudioBuffer< SampleType > && fillWith (SignalBase< SampleType > &&signal, size_t blockSizeFrames=0, Preparation signalPreparation=Preparation::resetAndPrepare) &&
 Fills this AudioBuffer by rendering audio from a Signal.
 
AudioBuffer< SampleType > & processWith (DSPBase< SampleType > &dsp, size_t blockSizeFrames=0, Preparation dspPreparation=Preparation::resetAndPrepare) &
 Processes this AudioBuffer by rendering its audio through a provided DSP.
 
AudioBuffer< SampleType > & processWith (DSPBase< SampleType > &&dsp, size_t blockSizeFrames=0, Preparation dspPreparation=Preparation::resetAndPrepare) &
 Processes this AudioBuffer by rendering its audio through a provided DSP.
 
AudioBuffer< SampleType > && processWith (DSPBase< SampleType > &dsp, size_t blockSizeFrames=0, Preparation dspPreparation=Preparation::resetAndPrepare) &&
 Processes this AudioBuffer by rendering its audio through a provided DSP.
 
AudioBuffer< SampleType > && processWith (DSPBase< SampleType > &&dsp, size_t blockSizeFrames=0, Preparation dspPreparation=Preparation::resetAndPrepare) &&
 Processes this AudioBuffer by rendering its audio through a provided DSP.
 
std::pair< size_t, size_t > getFrameIndices (const Slice &slice) const
 Returns a pair of indices representing a provided slice.
 

Static Public Member Functions

static AudioBuffer emptyLike (const AudioBuffer &other)
 Creates an empty audio buffer with the same number of channels, frames and sample rate as the other buffer.
 

Friends

std::ostream & operator<< (std::ostream &stream, const AudioBuffer &audioBuffer)
 Prints readable text representation of the AudioBuffer object into the I/O stream.
 

Detailed Description

template<typename SampleType>
class hart::AudioBuffer< SampleType >

Container for audio data.

Note
This class owns a memory block with audio samples - so it's a container, not a view. Treat it like a heavyweight object.

Definition at line 26 of file hart_audio_buffer.hpp.

Constructor & Destructor Documentation

◆ AudioBuffer() [1/3]

template<typename SampleType >
AudioBuffer ( size_t  numChannels = 0,
size_t  numFrames = 0,
double  sampleRateHz = nan<double>() 
)
inline

Creates an audio buffer.

Parameters
numChannelsInitial number of channels
numFramesNumbers of frames (samples) to be allocated in each channel
sampleRateHzMetadata for sample rate (in Hz) in which the data whould be interpreted, whenever applicable

Definition at line 33 of file hart_audio_buffer.hpp.

◆ AudioBuffer() [2/3]

template<typename SampleType >
AudioBuffer ( const AudioBuffer< SampleType > &  other)
inline

Creates an audio buffer by copying.

Definition at line 44 of file hart_audio_buffer.hpp.

◆ AudioBuffer() [3/3]

template<typename SampleType >
AudioBuffer ( AudioBuffer< SampleType > &&  other)
inlinenoexcept

Creates an audio buffer by moving.

Definition at line 55 of file hart_audio_buffer.hpp.

◆ ~AudioBuffer()

template<typename SampleType >
~AudioBuffer ( )
default

The destructor.

Member Function Documentation

◆ operator=() [1/2]

template<typename SampleType >
AudioBuffer & operator= ( const AudioBuffer< SampleType > &  other)
inline

Creates an audio buffer by copy-assigning.

Definition at line 69 of file hart_audio_buffer.hpp.

◆ operator=() [2/2]

template<typename SampleType >
AudioBuffer & operator= ( AudioBuffer< SampleType > &&  other)
inlinenoexcept

Creates an audio buffer by move-assigning.

Definition at line 87 of file hart_audio_buffer.hpp.

◆ getArrayOfReadPointers()

template<typename SampleType >
const SampleType *const * getArrayOfReadPointers ( ) const
inline

Gets a raw pointer to the read-only audio data.

Returns
A pointer to an array of per-channel read pointers. It is guaranteed that each channel points to a contiguous non-interleaved block of memory.

Definition at line 105 of file hart_audio_buffer.hpp.

◆ getArrayOfWritePointers()

template<typename SampleType >
SampleType *const * getArrayOfWritePointers ( )
inline

Gets a raw pointer to the mutable audio data.

Returns
A pointer to an array of per-channel write pointers. It is guaranteed that each channel points to a contiguous non-interleaved block of memory.

Definition at line 113 of file hart_audio_buffer.hpp.

◆ emptyLike()

template<typename SampleType >
static AudioBuffer emptyLike ( const AudioBuffer< SampleType > &  other)
inlinestatic

Creates an empty audio buffer with the same number of channels, frames and sample rate as the other buffer.

Note
The data from the other buffer will not be copied. Newly allocated samples will be value-initialized.
Parameters
otherReference buffer

Definition at line 121 of file hart_audio_buffer.hpp.

◆ getNumChannels()

template<typename SampleType >
size_t getNumChannels ( ) const
inline

Get number of channels.

Returns
Number of allocated channels

Definition at line 130 of file hart_audio_buffer.hpp.

◆ getNumFrames()

template<typename SampleType >
size_t getNumFrames ( ) const
inline

Get number of frames (samples)

Returns
Number of allocated frames (samples) in every channel

Definition at line 134 of file hart_audio_buffer.hpp.

◆ setNumFrames()

template<typename SampleType >
void setNumFrames ( size_t  newNumFrames)
inline

Resizes the buffer to hold a new number of frames per channel.

Resizing behaviour:

  • If newNumFrames == current size, it won't do anything.
  • If newNumFrames > current size, it will append silence (zeros) at the end.
  • If newNumFrames < current size: it will just truncate, discarding samples from the end. Will always preserve existing channels and sample-rate metadata.
    Attention
    May cause reallocation, thus invalidating previous raw pointers!
    Parameters
    newNumFramesNew number of frames per channel

Definition at line 144 of file hart_audio_buffer.hpp.

◆ hasSampleRate()

template<typename SampleType >
bool hasSampleRate ( ) const
inline

Check if a specific sample rate was assigned to the audio buffer.

Note
Uninitialized buffers, as well as some specific Signal types, will not have a specific sample rate.
Returns
true if there is a specific sample rate value, false otherwise

Definition at line 177 of file hart_audio_buffer.hpp.

◆ getSampleRateHz()

template<typename SampleType >
double getSampleRateHz ( ) const
inline

Get a sample rate metadata.

Note
Call hasSampleRate() if you're not sure if the buffer has a specific sample rate
Returns
Buffer's sample rate in Hz

Definition at line 185 of file hart_audio_buffer.hpp.

◆ getLengthSeconds()

template<typename SampleType >
double getLengthSeconds ( ) const
inline

Get a duration of the audio buffer.

Note
Before calling it, it's a good idea to call hasSampleRate() to check if the buffer has a specific sample rate, otherwise the duration is unknown.
Returns
Duration of the audio buffer in seconds

Definition at line 194 of file hart_audio_buffer.hpp.

◆ operator[]() [1/2]

template<typename SampleType >
SampleType * operator[] ( size_t  channel)
inline

Get a raw pointer to a specific channel's mutable audio data.

Note
The data is guaranteed to have at least getNumFrames() items and to be a contiguous non-interleaved block of memory.
Returns
Pointer to the audio data

Definition at line 207 of file hart_audio_buffer.hpp.

◆ operator[]() [2/2]

template<typename SampleType >
const SampleType * operator[] ( size_t  channel) const
inline

Get a raw pointer to a specific channel's read-only audio data.

Note
The data is guaranteed to have at least getNumFrames() items and to be a contiguous non-interleaved block of memory.
Returns
Pointer to the audio data

Definition at line 215 of file hart_audio_buffer.hpp.

◆ equalsTo()

template<typename SampleType >
bool equalsTo ( const AudioBuffer< SampleType > &  other,
SampleType  toleranceLinear = (SampleType) 1e-6 
) const
inline

Checks whether this buffer contains approximately the same audio as another buffer.

The comparison is relaxed - each pair of corresponding samples must differ by no more than toleranceLinear, but not bit-exact. Both buffers must have the same number of channels and frames. Also, if both buffers have sample-rate metadata, the sample rates must match. If both buffers have no sample-rate metadata assigned, they will still be considered equal as long as their dimensions match, and sample values match within tolerance.

Parameters
otherBuffer to compare against
toleranceLinearAbsolute sample tolerance in linear domain (not decibels)
Returns
true if the buffers are equal within the specified tolerance, false otherwise

Definition at line 229 of file hart_audio_buffer.hpp.

◆ operator==()

template<typename SampleType >
bool operator== ( const AudioBuffer< SampleType > &  other) const
inline

Checks whether two buffers contain approximately the same audio.

Equivalent to calling AudioBuffer::equalsTo (other) with the default tolerance

Parameters
otherBuffer to compare against
Returns
true if the buffers are equal within the default tolerance, false otherwise

Definition at line 252 of file hart_audio_buffer.hpp.

◆ operator!=()

template<typename SampleType >
bool operator!= ( const AudioBuffer< SampleType > &  other) const
inline

Checks whether two buffers differ beyond the default comparison tolerance.

Equivalent to ! AudioBuffer::equalsTo (other)

Parameters
otherBuffer to compare against
Returns
true if the buffers are not equal within the default tolerance, false otherwise

Definition at line 261 of file hart_audio_buffer.hpp.

◆ appendFrom()

template<typename SampleType >
void appendFrom ( const AudioBuffer< SampleType > &  otherBuffer)
inline

Appends data from another buffer.

Warning
This operation will resize the current buffer and potentially invalidate the previous raw data pointers returned by getArrayOfReadPointers(), getArrayOfWritePointers() and the "`[]`" operator, so make sure to keep those external pointers up to date.
Parameters
otherBufferA buffer to append from

Definition at line 270 of file hart_audio_buffer.hpp.

◆ erase()

template<typename SampleType >
void erase ( )
inline

Clears the buffer.

The number of frames after this operation will be zero, but channel number will persist.

Definition at line 298 of file hart_audio_buffer.hpp.

◆ getMagnitude() [1/2]

template<typename SampleType >
SampleType getMagnitude ( size_t  channel,
size_t  startFrame,
size_t  numFrames 
) const
inline

Get the maximum absolute value in the buffer in a specific channel.

Parameters
channelChannel of which the magnitude should be measured
startFrameThe beginning of the range of the frames to look for magnitude
numFramesNumber of frames, beginning with startFrame, to look for the magnitude
Returns
The maximum value, in linear domain (i.e. not decibels)

Definition at line 317 of file hart_audio_buffer.hpp.

◆ getMagnitude() [2/2]

template<typename SampleType >
SampleType getMagnitude ( size_t  startFrame,
size_t  numFrames 
) const
inline

Get the maximum absolute value in the buffer across all channels.

Parameters
startFrameThe beginning of the range of the frames to look for magnitude
numFramesNumber of frames, beginning with startFrame, to look for the magnitude
Returns
The maximum value, in linear domain (i.e. not decibels)

Definition at line 339 of file hart_audio_buffer.hpp.

◆ copyFrom() [1/2]

template<typename SampleType >
void copyFrom ( size_t  destChannel,
size_t  destStartFrame,
const AudioBuffer< SampleType > &  source,
size_t  sourceChannel,
size_t  sourceStartFrame,
size_t  numFrames 
)
inline

Copies audio from another buffer.

Parameters
destChannelChannel within this buffer to copy the frames to
destStartFrameStart frame within this buffer's channel
sourceSource buffer to read from
sourceChannelChannel within the source buffer to read from
sourceStartFrameOffset within the source buffer's channel to start reading frames from
numFramesNumber of frames to copy

Definition at line 367 of file hart_audio_buffer.hpp.

◆ copyFrom() [2/2]

template<typename SampleType >
void copyFrom ( size_t  destChannel,
size_t  destStartFrame,
const SampleType *  source,
size_t  numFrames 
)
inline

Copies audio from another generic audio buffer.

Parameters
destChannelChannel within this buffer to copy the frames to
destStartFrameStart frame within this buffer's channel
sourcePointer to the source sample data, must contain at least numFrames samples
numFramesNumber of frames to copy

Definition at line 390 of file hart_audio_buffer.hpp.

◆ clear() [1/2]

template<typename SampleType >
void clear ( )
inline

Clears the entire buffer.

Sets all frames in all channels to zeros, keeping the sample rate value intact

Definition at line 403 of file hart_audio_buffer.hpp.

◆ clear() [2/2]

template<typename SampleType >
void clear ( size_t  channel,
size_t  startFrame,
size_t  numFrames 
)
inline

Clears a specific section of a given channel.

Overwrites a selected section of the channel with zeros

Parameters
channelChannel in which to clear a frame range
startFrameStart of the frame range to clear (inclusive)
numFramesAmount of frames to clear

Definition at line 413 of file hart_audio_buffer.hpp.

◆ represent()

template<typename SampleType >
void represent ( std::ostream &  stream) const
inline

Prints readable representation of the audio buffer.

Parameters
streamString stream to append the representation to

Definition at line 426 of file hart_audio_buffer.hpp.

◆ fillWith() [1/4]

template<typename SampleType >
AudioBuffer< SampleType > & fillWith ( SignalBase< SampleType > &  signal,
size_t  blockSizeFrames = 0,
Preparation  signalPreparation = Preparation::resetAndPrepare 
) &
inline

Fills this AudioBuffer by rendering audio from a Signal.

This method uses the supplied Signal and renders audio into this buffer, replacing all existing samples. The Signal is not consumed and can be re-used after rendering completes.

The buffer's sample rate and channel layout are used as the hosting configuration. If the Signal does not support the current channel count or sample rate, an exception is raised.

Rendering is performed block-by-block when blockSizeFrames is smaller than the buffer length. The final block may be shorter than the requested block size.

Parameters
signalA reusable Signal object to render from.
blockSizeFramesNumber of frames to render per block. Pass 0 to render the whole buffer in one go.
signalPreparationControls whether the Signal should be reset and/or prepared before rendering.
Returns
A reference to this AudioBuffer for chaining further operations.
Exceptions
hart::SampleRateErrorif Sample rate of this buffer is undefined, or unsupported by the Signal.
hart::ChannelLayoutErrorif this buffer has no channels allocated, or number of channels is unsupported by the Signal
hart::SizeErroris this buffer has no frames allocated

Definition at line 454 of file hart_audio_buffer.hpp.

◆ fillWith() [2/4]

template<typename SampleType >
AudioBuffer< SampleType > & fillWith ( SignalBase< SampleType > &&  signal,
size_t  blockSizeFrames = 0,
Preparation  signalPreparation = Preparation::resetAndPrepare 
) &
inline

Fills this AudioBuffer by rendering audio from a Signal.

This method uses the supplied Signal and renders audio into this buffer, replacing all existing samples.

The buffer's sample rate and channel layout are used as the hosting configuration. If the Signal does not support the current channel count or sample rate, an exception is raised.

Rendering is performed block-by-block when blockSizeFrames is smaller than the buffer length. The final block may be shorter than the requested block size.

Parameters
signalA temporary Signal instance to render from.
blockSizeFramesNumber of frames to render per block. Pass 0 to render the whole buffer in one go.
signalPreparationControls whether the Signal should be reset and/or prepared before rendering.
Returns
A reference to this AudioBuffer for chaining further operations.
Exceptions
hart::SampleRateErrorif Sample rate of this buffer is undefined, or unsupported by the Signal.
hart::ChannelLayoutErrorif this buffer has no channels allocated, or number of channels is unsupported by the Signal
hart::SizeErroris this buffer has no frames allocated

Definition at line 477 of file hart_audio_buffer.hpp.

◆ fillWith() [3/4]

template<typename SampleType >
AudioBuffer< SampleType > && fillWith ( SignalBase< SampleType > &  signal,
size_t  blockSizeFrames = 0,
Preparation  signalPreparation = Preparation::resetAndPrepare 
) &&
inline

Fills this AudioBuffer by rendering audio from a Signal.

This method uses the supplied Signal and renders audio into this buffer, replacing all existing samples. The Signal is not consumed and can be re-used after rendering completes.

The buffer's sample rate and channel layout are used as the hosting configuration. If the Signal does not support the current channel count or sample rate, an exception is raised.

Rendering is performed block-by-block when blockSizeFrames is smaller than the buffer length. The final block may be shorter than the requested block size.

Parameters
signalA reusable Signal object to render from.
blockSizeFramesNumber of frames to render per block. Pass 0 to render the whole buffer in one go.
signalPreparationControls whether the Signal should be reset and/or prepared before rendering.
Returns
An rvalue reference to this AudioBuffer, allowing fluent chaining with temporary buffers.
Exceptions
hart::SampleRateErrorif Sample rate of this buffer is undefined, or unsupported by the Signal.
hart::ChannelLayoutErrorif this buffer has no channels allocated, or number of channels is unsupported by the Signal
hart::SizeErroris this buffer has no frames allocated

Definition at line 501 of file hart_audio_buffer.hpp.

◆ fillWith() [4/4]

template<typename SampleType >
AudioBuffer< SampleType > && fillWith ( SignalBase< SampleType > &&  signal,
size_t  blockSizeFrames = 0,
Preparation  signalPreparation = Preparation::resetAndPrepare 
) &&
inline

Fills this AudioBuffer by rendering audio from a Signal.

This method uses the supplied Signal and renders audio into this buffer, replacing all existing samples.

The buffer's sample rate and channel layout are used as the hosting configuration. If the Signal does not support the current channel count or sample rate, an exception is raised.

Rendering is performed block-by-block when blockSizeFrames is smaller than the buffer length. The final block may be shorter than the requested block size.

Parameters
signalA temporary Signal instance to render from.
blockSizeFramesNumber of frames to render per block. Pass 0 to render the whole buffer in one go.
signalPreparationControls whether the Signal should be reset and/or prepared before rendering.
Returns
An rvalue reference to this AudioBuffer, allowing fluent chaining with temporary buffers.
Exceptions
hart::SampleRateErrorif Sample rate of this buffer is undefined, or unsupported by the Signal.
hart::ChannelLayoutErrorif this buffer has no channels allocated, or number of channels is unsupported by the Signal
hart::SizeErroris this buffer has no frames allocated

Definition at line 524 of file hart_audio_buffer.hpp.

◆ processWith() [1/4]

template<typename SampleType >
AudioBuffer< SampleType > & processWith ( DSPBase< SampleType > &  dsp,
size_t  blockSizeFrames = 0,
Preparation  dspPreparation = Preparation::resetAndPrepare 
) &
inline

Processes this AudioBuffer by rendering its audio through a provided DSP.

This method uses the supplied DSP and renders audio from this buffer, replacing all existing samples. The DSP is not consumed and can be re-used after rendering completes.

The buffer's sample rate and channel layout are used as the hosting configuration. If the DSP does not support the current channel count or sample rate, an exception is raised.

Rendering is performed block-by-block when blockSizeFrames is smaller than the buffer length. The final block may be shorter than the requested block size.

Parameters
signalA reusable hart::DSP object to render from
blockSizeFramesNumber of frames to render per block. Pass 0 to render the whole buffer in one go
signalPreparationControls whether the DSP object should be reset and/or prepared before rendering
Returns
A reference to this AudioBuffer for chaining further operations
Exceptions
hart::SampleRateErrorif Sample rate of this buffer is undefined, or unsupported by the DSP object
hart::ChannelLayoutErrorif this buffer has no channels allocated, or number of channels is unsupported by the DSP object
hart::SizeErroris this buffer has no frames allocated

Definition at line 548 of file hart_audio_buffer.hpp.

◆ processWith() [2/4]

template<typename SampleType >
AudioBuffer< SampleType > & processWith ( DSPBase< SampleType > &&  dsp,
size_t  blockSizeFrames = 0,
Preparation  dspPreparation = Preparation::resetAndPrepare 
) &
inline

Processes this AudioBuffer by rendering its audio through a provided DSP.

This method uses the supplied DSP and renders audio from this buffer, replacing all existing samples

The buffer's sample rate and channel layout are used as the hosting configuration. If the DSP does not support the current channel count or sample rate, an exception is raised.

Rendering is performed block-by-block when blockSizeFrames is smaller than the buffer length The final block may be shorter than the requested block size

Parameters
signalA temporary hart::DSP object to process AudioBuffer's contents with
blockSizeFramesNumber of frames to render per block. Pass 0 to render the whole buffer in one go.
signalPreparationControls whether the DSP object should be reset and/or prepared before rendering
Returns
A reference to this AudioBuffer for chaining further operations
Exceptions
hart::SampleRateErrorif Sample rate of this buffer is undefined, or unsupported by the DSP object
hart::ChannelLayoutErrorif this buffer has no channels allocated, or number of channels is unsupported by the DSP object
hart::SizeErroris this buffer has no frames allocated

Definition at line 571 of file hart_audio_buffer.hpp.

◆ processWith() [3/4]

template<typename SampleType >
AudioBuffer< SampleType > && processWith ( DSPBase< SampleType > &  dsp,
size_t  blockSizeFrames = 0,
Preparation  dspPreparation = Preparation::resetAndPrepare 
) &&
inline

Processes this AudioBuffer by rendering its audio through a provided DSP.

This method uses the supplied DSP and renders audio from this buffer, replacing all existing samples. The DSP is not consumed and can be re-used after rendering completes.

The buffer's sample rate and channel layout are used as the hosting configuration. If the DSP does not support the current channel count or sample rate, an exception is raised.

Rendering is performed block-by-block when blockSizeFrames is smaller than the buffer length. The final block may be shorter than the requested block size.

Parameters
signalA reusable hart::DSP object to render from
blockSizeFramesNumber of frames to render per block. Pass 0 to render the whole buffer in one go.
signalPreparationControls whether the DSP object should be reset and/or prepared before rendering.
Returns
An rvalue reference to this AudioBuffer, allowing fluent chaining with temporary buffers
Exceptions
hart::SampleRateErrorif Sample rate of this buffer is undefined, or unsupported by the DSP object
hart::ChannelLayoutErrorif this buffer has no channels allocated, or number of channels is unsupported by the DSP object
hart::SizeErroris this buffer has no frames allocated

Definition at line 595 of file hart_audio_buffer.hpp.

◆ processWith() [4/4]

template<typename SampleType >
AudioBuffer< SampleType > && processWith ( DSPBase< SampleType > &&  dsp,
size_t  blockSizeFrames = 0,
Preparation  dspPreparation = Preparation::resetAndPrepare 
) &&
inline

Processes this AudioBuffer by rendering its audio through a provided DSP.

This method uses the supplied DSP and renders audio from this buffer, replacing all existing samples.

The buffer's sample rate and channel layout are used as the hosting configuration. If the DSP does not support the current channel count or sample rate, an exception is raised.

Rendering is performed block-by-block when blockSizeFrames is smaller than the buffer length. The final block may be shorter than the requested block size.

Parameters
signalA temporary hart::DSP object to process AudioBuffer's contents with
blockSizeFramesNumber of frames to render per block. Pass 0 to render the whole buffer in one go.
signalPreparationControls whether the DSP object should be reset and/or prepared before rendering
Returns
An rvalue reference to this AudioBuffer, allowing fluent chaining with temporary buffers
Exceptions
hart::SampleRateErrorif Sample rate of this buffer is undefined, or unsupported by the DSP object
hart::ChannelLayoutErrorif this buffer has no channels allocated, or number of channels is unsupported by the DSP object
hart::SizeErroris this buffer has no frames allocated

Definition at line 618 of file hart_audio_buffer.hpp.

◆ getFrameIndices()

template<typename SampleType >
std::pair< size_t, size_t > getFrameIndices ( const Slice slice) const
inline

Returns a pair of indices representing a provided slice.

Parameters
sliceA Slice instance. Valid slice types are Slice::Type::whole Slice::Type::frames and Slice::Type::time
Return values
firstIndex representing the beginning of the range, inclusive
secondIndex representing the end of the range, non-inclusive

Definition at line 629 of file hart_audio_buffer.hpp.

Friends And Related Symbol Documentation

◆ operator<<

template<typename SampleType >
std::ostream & operator<< ( std::ostream &  stream,
const AudioBuffer< SampleType > &  audioBuffer 
)
friend

Prints readable text representation of the AudioBuffer object into the I/O stream.

Definition at line 685 of file hart_audio_buffer.hpp.


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