marvin 0.0.1
Pure C++ audio helper library
 
Loading...
Searching...
No Matches
marvin::containers::BufferView< SampleType > Struct Template Referencefinal

Trivially copyable view into a preallocated SampleType**. More...

#include <marvin_BufferView.h>

Public Member Functions

 BufferView (SampleType *const *samples, size_t nChannels, size_t nSamples)
 
size_t getNumChannels () const noexcept
 
size_t getNumSamples () const noexcept
 
const SampleType *const * getArrayOfReadPointers () const noexcept
 
SampleType *const * getArrayOfWritePointers () noexcept
 
std::span< SampleType > operator[] (size_t channel) noexcept
 
std::span< const SampleType > operator[] (size_t channel) const noexcept
 

Detailed Description

template<FloatType SampleType>
struct marvin::containers::BufferView< SampleType >

Trivially copyable view into a preallocated SampleType**.

Useful as a lightweight and framework agnostic alternative to xframework::AudioBuffer.

Constructor & Destructor Documentation

◆ BufferView()

template<FloatType SampleType>
marvin::containers::BufferView< SampleType >::BufferView ( SampleType *const * samples,
size_t nChannels,
size_t nSamples )

BufferView wraps around an already allocated SampleType**, and doesn't take ownership.

Parameters
samplesA pointer to the md array of samples to wrap around.
nChannelsThe number of channels allocated (the size of the outermost array)
nSamplesThe number of samples allocated per channel (the size of the innermost array)

Member Function Documentation

◆ getArrayOfReadPointers()

template<FloatType SampleType>
const SampleType *const * marvin::containers::BufferView< SampleType >::getArrayOfReadPointers ( ) const
noexcept

Returns a read only pointer to the underlying buffer

Returns
an immutable pointer to the underlying buffer

◆ getArrayOfWritePointers()

template<FloatType SampleType>
SampleType *const * marvin::containers::BufferView< SampleType >::getArrayOfWritePointers ( )
noexcept

Returns a mutable pointer to the underlying buffer

Returns
a mutable pointer to the underlying bufffer.

◆ getNumChannels()

template<FloatType SampleType>
size_t marvin::containers::BufferView< SampleType >::getNumChannels ( ) const
nodiscardnoexcept

Returns the number of channels allocated in the underlying buffer

Returns
The number of channels allocated.

◆ getNumSamples()

template<FloatType SampleType>
size_t marvin::containers::BufferView< SampleType >::getNumSamples ( ) const
nodiscardnoexcept

Returns the number of samples per channel allocated in the underlying buffer

Returns
The number of samples allocated.

◆ operator[]() [1/2]

template<FloatType SampleType>
std::span< const SampleType > marvin::containers::BufferView< SampleType >::operator[] ( size_t channel) const
nodiscardnoexcept

Returns an immutable view into a specific channel of the underlying buffer. In debug, bounds checks with an assert

Parameters
channelThe channel to construct a view into.
Returns
a std::span constructed from the specified channel.

◆ operator[]() [2/2]

template<FloatType SampleType>
std::span< SampleType > marvin::containers::BufferView< SampleType >::operator[] ( size_t channel)
nodiscardnoexcept

Returns a mutable view into a specific channel of the underlying buffer. In debug, bounds checks with an assert

Parameters
channelThe channel to construct a view into.
Returns
a std::span constructed from the specified channel.

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