RAVENNAKIT
Loading...
Searching...
No Matches
rav::AudioBuffer< T > Class Template Reference

A dynamically sizeable buffer to store non-interleaved audio, along with an array of pointers to the beginning of each channel. More...

#include <audio_buffer.hpp>

Inheritance diagram for rav::AudioBuffer< T >:
rav::AudioBufferView< T >

Public Member Functions

 AudioBuffer ()
 AudioBuffer (const size_t num_channels, const size_t num_frames)
 Constructs an audio buffer with the given number of channels and frames.
 AudioBuffer (const size_t num_channels, const size_t num_frames, T value_to_fill_with)
 Constructs an audio buffer with the given number of channels and frames and fills it with given value.
 AudioBuffer (const AudioBuffer &other)
 Constructs an audio buffer by copying from another buffer.
 AudioBuffer (AudioBuffer &&other) noexcept
 Constructs an audio buffer by moving from another buffer.
AudioBuffer & operator= (const AudioBuffer &other)
 Copies the contents from another audio buffer to this buffer.
AudioBuffer & operator= (AudioBuffer &&other) noexcept
 Moves the contents from another audio buffer to this buffer.
void resize (size_t num_channels, const size_t num_frames)
 Prepares the audio buffer for the given number of channels and frames.
Public Member Functions inherited from rav::AudioBufferView< T >
 AudioBufferView (T *const *channels, const size_t num_channels, const size_t num_frames)
 Constructs an audio buffer view with the given channels, number of channels, and number of frames.
size_t num_channels () const
size_t num_frames () const
const T * operator[] (size_t channel_index) const
 Accesses the channel at the given index.
T * operator[] (size_t channel_index)
 Accesses the channel at the given index Does not perform bounds checking.
const T *const * data () const
T *const * data ()
void set_sample (size_t channel_index, size_t frame_index, T value)
 Sets the value of an individual sample.
void clear () const
 Clears the buffer by setting all samples to zero.
void clear (T value) const
 Clears the buffer by setting all samples to the given value.
void clear (const size_t channel_index, const size_t start_sample, const size_t num_samples_to_clear)
 Clear a range of samples in a channel, without bounds checking.
void copy_from (const size_t dst_start_frame, const size_t num_frames_to_copy, const T *const *src, const size_t src_num_channels, const size_t src_start_frame=0)
 Copies data from all channels of src into all channels of this buffer.
void copy_from (const size_t dst_channel_index, const size_t dst_start_sample, const size_t num_samples_to_copy, const T *src)
 Copies data from src into this buffer, without bounds checking.
void copy_to (const size_t src_start_frame, const size_t num_frames, T *const *dst, const size_t dst_num_channels, const size_t dst_start_frame=0)
 Copies data from all channels of this buffer into dst.
void copy_to (const size_t src_channel_index, const size_t src_start_sample, const size_t num_samples_to_copy, T *dst)
 Copies data from this buffer into dst.
bool add (const AudioBufferView &other)
 Adds the samples of another audio buffer view to this audio buffer view.
bool is_valid () const
T find_max_abs () const
T find_max_abs (const size_t channel_index) const
 @channel_index The index of the channel to find the maximum value for.
AudioBufferView with_num_channels (const size_t num_channels)
 Returns a copy of this view with given number of channels.
AudioBufferView with_num_frames (const size_t num_frames)
 Returns a copy of this view with given number of frames.
AudioBufferView< std::add_const_t< T > > const_view () const

Additional Inherited Members

Protected Member Functions inherited from rav::AudioBufferView< T >
void update (T *const *channels, const size_t num_channels, const size_t num_frames)
 Updates the channel pointers, number of channels and number of frames.

Detailed Description

template<class T>
class rav::AudioBuffer< T >

A dynamically sizeable buffer to store non-interleaved audio, along with an array of pointers to the beginning of each channel.

Template Parameters
TThe sample type.

Definition at line 41 of file audio_buffer.hpp.

Constructor & Destructor Documentation

◆ AudioBuffer() [1/5]

template<class T>
rav::AudioBuffer< T >::AudioBuffer ( )
inline

Definition at line 43 of file audio_buffer.hpp.

◆ AudioBuffer() [2/5]

template<class T>
rav::AudioBuffer< T >::AudioBuffer ( const size_t num_channels,
const size_t num_frames )
inline

Constructs an audio buffer with the given number of channels and frames.

Parameters
num_channelsThe number of channels.
num_framesThe number of frames.

Definition at line 50 of file audio_buffer.hpp.

◆ AudioBuffer() [3/5]

template<class T>
rav::AudioBuffer< T >::AudioBuffer ( const size_t num_channels,
const size_t num_frames,
T value_to_fill_with )
inline

Constructs an audio buffer with the given number of channels and frames and fills it with given value.

Parameters
num_channelsThe number of channels.
num_framesThe number of frames.
value_to_fill_withThe value to fill the buffer with.

Definition at line 60 of file audio_buffer.hpp.

◆ AudioBuffer() [4/5]

template<class T>
rav::AudioBuffer< T >::AudioBuffer ( const AudioBuffer< T > & other)
inline

Constructs an audio buffer by copying from another buffer.

Parameters
otherThe other buffer to copy from.

Definition at line 69 of file audio_buffer.hpp.

◆ AudioBuffer() [5/5]

template<class T>
rav::AudioBuffer< T >::AudioBuffer ( AudioBuffer< T > && other)
inlinenoexcept

Constructs an audio buffer by moving from another buffer.

Parameters
otherThe other buffer to move from.

Definition at line 79 of file audio_buffer.hpp.

Member Function Documentation

◆ operator=() [1/2]

template<class T>
AudioBuffer & rav::AudioBuffer< T >::operator= ( AudioBuffer< T > && other)
inlinenoexcept

Moves the contents from another audio buffer to this buffer.

It does this by swapping, so other will have the contents of this buffer.

Parameters
otherThe other buffer to move from.
Returns
A reference to this buffer.

Definition at line 104 of file audio_buffer.hpp.

◆ operator=() [2/2]

template<class T>
AudioBuffer & rav::AudioBuffer< T >::operator= ( const AudioBuffer< T > & other)
inline

Copies the contents from another audio buffer to this buffer.

Parameters
otherThe other buffer to copy from.
Returns
A reference to this buffer.

Definition at line 91 of file audio_buffer.hpp.

◆ resize()

template<class T>
void rav::AudioBuffer< T >::resize ( size_t num_channels,
const size_t num_frames )
inline

Prepares the audio buffer for the given number of channels and frames.

New space will be zero initialized. Existing data will be kept, except if the number of channels or frames is less than the current number of channels or frames.

Parameters
num_channelsThe number of channels.
num_framesThe number of frames.

Definition at line 119 of file audio_buffer.hpp.


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