DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
Loading...
Searching...
No Matches
dspark::AudioBuffer< T, MaxChannels > Class Template Reference

Owning audio buffer with contiguous, 32-byte aligned storage. More...

#include <AudioBuffer.h>

Public Member Functions

 AudioBuffer ()=default
 
 ~AudioBuffer ()
 
 AudioBuffer (const AudioBuffer &)=delete
 
AudioBufferoperator= (const AudioBuffer &)=delete
 
 AudioBuffer (AudioBuffer &&other) noexcept
 C++20 idiomatic move constructor.
 
AudioBufferoperator= (AudioBuffer &&other) noexcept
 C++20 idiomatic move assignment.
 
void resize (int numChannels, int numSamples)
 Allocates the buffer for the given dimensions.
 
AudioBufferView< T, MaxChannels > toView () noexcept
 Returns a non-owning mutable view of this buffer. The view's channel capacity is propagated from MaxChannels, so a buffer wider than the 16-channel view default is never silently truncated (for the default MaxChannels==16 this is exactly AudioBufferView<T>).
 
AudioBufferView< const T, MaxChannels > toView () const noexcept
 Returns a non-owning const view of this buffer.
 
T * getChannel (int ch) noexcept
 Returns a pointer to the sample data.
 
const T * getChannel (int ch) const noexcept
 Const overload.
 
int getNumChannels () const noexcept
 Returns the number of active channels.
 
int getNumSamples () const noexcept
 Returns the number of samples per channel.
 
void clear () noexcept
 Clears all channels, including SIMD alignment padding. Ensures any SIMD over-read will consume pure zeros (no denormals).
 

Detailed Description

template<typename T, int MaxChannels = 16>
class dspark::AudioBuffer< T, MaxChannels >

Owning audio buffer with contiguous, 32-byte aligned storage.

Template Parameters
TSample type (float or double).
MaxChannelsMaximum supported channels.

Definition at line 276 of file AudioBuffer.h.

Constructor & Destructor Documentation

◆ AudioBuffer() [1/3]

template<typename T , int MaxChannels = 16>
dspark::AudioBuffer< T, MaxChannels >::AudioBuffer ( )
default

◆ ~AudioBuffer()

template<typename T , int MaxChannels = 16>
dspark::AudioBuffer< T, MaxChannels >::~AudioBuffer ( )
inline

Definition at line 286 of file AudioBuffer.h.

◆ AudioBuffer() [2/3]

template<typename T , int MaxChannels = 16>
dspark::AudioBuffer< T, MaxChannels >::AudioBuffer ( const AudioBuffer< T, MaxChannels > &  )
delete

◆ AudioBuffer() [3/3]

template<typename T , int MaxChannels = 16>
dspark::AudioBuffer< T, MaxChannels >::AudioBuffer ( AudioBuffer< T, MaxChannels > &&  other)
inlinenoexcept

C++20 idiomatic move constructor.

Definition at line 292 of file AudioBuffer.h.

Member Function Documentation

◆ clear()

template<typename T , int MaxChannels = 16>
void dspark::AudioBuffer< T, MaxChannels >::clear ( )
inlinenoexcept

Clears all channels, including SIMD alignment padding. Ensures any SIMD over-read will consume pure zeros (no denormals).

Definition at line 414 of file AudioBuffer.h.

◆ getChannel() [1/2]

template<typename T , int MaxChannels = 16>
const T * dspark::AudioBuffer< T, MaxChannels >::getChannel ( int  ch) const
inlinenoexcept

Const overload.

Definition at line 396 of file AudioBuffer.h.

◆ getChannel() [2/2]

template<typename T , int MaxChannels = 16>
T * dspark::AudioBuffer< T, MaxChannels >::getChannel ( int  ch)
inlinenoexcept

Returns a pointer to the sample data.

Definition at line 389 of file AudioBuffer.h.

◆ getNumChannels()

template<typename T , int MaxChannels = 16>
int dspark::AudioBuffer< T, MaxChannels >::getNumChannels ( ) const
inlinenoexcept

Returns the number of active channels.

Definition at line 403 of file AudioBuffer.h.

◆ getNumSamples()

template<typename T , int MaxChannels = 16>
int dspark::AudioBuffer< T, MaxChannels >::getNumSamples ( ) const
inlinenoexcept

Returns the number of samples per channel.

Definition at line 406 of file AudioBuffer.h.

◆ operator=() [1/2]

template<typename T , int MaxChannels = 16>
AudioBuffer & dspark::AudioBuffer< T, MaxChannels >::operator= ( AudioBuffer< T, MaxChannels > &&  other)
inlinenoexcept

C++20 idiomatic move assignment.

Definition at line 302 of file AudioBuffer.h.

◆ operator=() [2/2]

template<typename T , int MaxChannels = 16>
AudioBuffer & dspark::AudioBuffer< T, MaxChannels >::operator= ( const AudioBuffer< T, MaxChannels > &  )
delete

◆ resize()

template<typename T , int MaxChannels = 16>
void dspark::AudioBuffer< T, MaxChannels >::resize ( int  numChannels,
int  numSamples 
)
inline

Allocates the buffer for the given dimensions.

Existing contents are NOT preserved: the buffer (including its SIMD padding) is zeroed after every call. Memory is only re-allocated when the request exceeds the current capacity; shrinking reuses it. May throw std::bad_alloc; the buffer stays coherent and reusable after.

Parameters
numChannelsNumber of active channels (must be <= MaxChannels).
numSamplesNumber of audio samples per channel.

Definition at line 330 of file AudioBuffer.h.

◆ toView() [1/2]

template<typename T , int MaxChannels = 16>
AudioBufferView< const T, MaxChannels > dspark::AudioBuffer< T, MaxChannels >::toView ( ) const
inlinenoexcept

Returns a non-owning const view of this buffer.

Definition at line 381 of file AudioBuffer.h.

◆ toView() [2/2]

template<typename T , int MaxChannels = 16>
AudioBufferView< T, MaxChannels > dspark::AudioBuffer< T, MaxChannels >::toView ( )
inlinenoexcept

Returns a non-owning mutable view of this buffer. The view's channel capacity is propagated from MaxChannels, so a buffer wider than the 16-channel view default is never silently truncated (for the default MaxChannels==16 this is exactly AudioBufferView<T>).

Definition at line 375 of file AudioBuffer.h.


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