Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::audio::Buffer< SampleType > Class Template Reference

Owning multi-channel audio buffer with contiguous storage. More...

#include <buffer.hpp>

Public Member Functions

 Buffer ()=default
 Buffer (std::size_t num_channels, std::size_t num_samples)
 Allocate a buffer with the given dimensions, zero-filled.
 Buffer (const Buffer &other)
Buffer & operator= (const Buffer &other)
 Buffer (Buffer &&other)
Buffer & operator= (Buffer &&other)
void resize (std::size_t num_channels, std::size_t num_samples)
 Resize the buffer, reallocating if necessary. New samples are zero-filled.
BufferView< SampleType > view ()
 Create a non-owning BufferView over this buffer's data.
BufferView< const SampleType > view () const
 Create a non-owning BufferView over this buffer's data.
std::span< SampleType > channel (std::size_t index)
 Get a span over all samples in one channel.
std::span< const SampleType > channel (std::size_t index) const
 Get a span over all samples in one channel.
std::size_t num_channels () const
std::size_t num_samples () const
std::size_t allocated_sample_capacity () const noexcept
 Number of sample elements retained by the backing allocation.
void release () noexcept
 Release all owned sample and channel-pointer storage.
void clear ()
 Zero-fill all channels.

Detailed Description

template<typename SampleType = float>
class pulp::audio::Buffer< SampleType >

Owning multi-channel audio buffer with contiguous storage.

Allocates and manages its own sample memory. Use for offline rendering, test harnesses, and HeadlessHost — not in real-time audio callbacks where allocation is forbidden. Call view() to get a non-owning BufferView.

Template Parameters
SampleTypeSample format, typically float.

Constructor & Destructor Documentation

◆ Buffer() [1/4]

template<typename SampleType = float>
pulp::audio::Buffer< SampleType >::Buffer ( )
default

◆ Buffer() [2/4]

template<typename SampleType = float>
pulp::audio::Buffer< SampleType >::Buffer ( std::size_t num_channels,
std::size_t num_samples )
inline

Allocate a buffer with the given dimensions, zero-filled.

Parameters
num_channelsNumber of audio channels.
num_samplesNumber of samples per channel.

◆ Buffer() [3/4]

template<typename SampleType = float>
pulp::audio::Buffer< SampleType >::Buffer ( const Buffer< SampleType > & other)
inline

◆ Buffer() [4/4]

template<typename SampleType = float>
pulp::audio::Buffer< SampleType >::Buffer ( Buffer< SampleType > && other)
inline

Member Function Documentation

◆ allocated_sample_capacity()

template<typename SampleType = float>
std::size_t pulp::audio::Buffer< SampleType >::allocated_sample_capacity ( ) const
inlinenoexcept

Number of sample elements retained by the backing allocation.

This can exceed num_channels() * num_samples() after a resize-down.

◆ channel() [1/2]

template<typename SampleType = float>
std::span< SampleType > pulp::audio::Buffer< SampleType >::channel ( std::size_t index)
inline

Get a span over all samples in one channel.

Parameters
indexZero-based channel index.

◆ channel() [2/2]

template<typename SampleType = float>
std::span< const SampleType > pulp::audio::Buffer< SampleType >::channel ( std::size_t index) const
inline

Get a span over all samples in one channel.

Parameters
indexZero-based channel index.

◆ clear()

template<typename SampleType = float>
void pulp::audio::Buffer< SampleType >::clear ( )
inline

Zero-fill all channels.

◆ num_channels()

template<typename SampleType = float>
std::size_t pulp::audio::Buffer< SampleType >::num_channels ( ) const
inline

◆ num_samples()

template<typename SampleType = float>
std::size_t pulp::audio::Buffer< SampleType >::num_samples ( ) const
inline

◆ operator=() [1/2]

template<typename SampleType = float>
Buffer & pulp::audio::Buffer< SampleType >::operator= ( Buffer< SampleType > && other)
inline

◆ operator=() [2/2]

template<typename SampleType = float>
Buffer & pulp::audio::Buffer< SampleType >::operator= ( const Buffer< SampleType > & other)
inline

◆ release()

template<typename SampleType = float>
void pulp::audio::Buffer< SampleType >::release ( )
inlinenoexcept

Release all owned sample and channel-pointer storage.

◆ resize()

template<typename SampleType = float>
void pulp::audio::Buffer< SampleType >::resize ( std::size_t num_channels,
std::size_t num_samples )
inline

Resize the buffer, reallocating if necessary. New samples are zero-filled.

◆ view() [1/2]

template<typename SampleType = float>
BufferView< SampleType > pulp::audio::Buffer< SampleType >::view ( )
inline

Create a non-owning BufferView over this buffer's data.

The view is invalidated if the Buffer is resized or destroyed.

◆ view() [2/2]

template<typename SampleType = float>
BufferView< const SampleType > pulp::audio::Buffer< SampleType >::view ( ) const
inline

Create a non-owning BufferView over this buffer's data.

The view is invalidated if the Buffer is resized or destroyed. Const overload: yields a read-only view. SampleType** converts to const SampleType* const* implicitly (qualification conversion), so no extra pointer array is needed.


The documentation for this class was generated from the following file:
  • /home/runner/work/pulp/pulp/core/audio/include/pulp/audio/buffer.hpp