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

Non-owning view over multi-channel audio sample data. More...

#include <buffer.hpp>

Public Member Functions

 BufferView ()=default
 BufferView (SampleType *const *channel_ptrs, std::size_t num_channels, std::size_t num_samples)
 Construct from an array of per-channel pointers.
BufferView slice (std::size_t start, std::size_t length) const
 Create a non-owning slice over this view.
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.
SampleType * channel_ptr (std::size_t index)
 Raw pointer to one channel's sample data.
const SampleType * channel_ptr (std::size_t index) const
 Raw pointer to one channel's sample data.
bool has_valid_channels () const noexcept
 Check channel storage before a caller dereferences a borrowed host view.
std::size_t num_channels () const
std::size_t num_samples () const
bool empty () const
 True if the buffer has zero channels or zero samples.
void clear ()
 Zero-fill all channels.

Detailed Description

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

Non-owning view over multi-channel audio sample data.

This is the primary type passed into Processor::process(). It wraps an array of channel pointers provided by the host or format adapter and does not allocate or own any memory.

Template Parameters
SampleTypeSample format — typically float or const float.
// Wrap host-provided pointers:
float* ptrs[2] = {left_ptr, right_ptr};
// Process samples:
for (auto& s : buf.channel(0)) s *= 0.5f;
Non-owning view over multi-channel audio sample data.
Definition buffer.hpp:30

Constructor & Destructor Documentation

◆ BufferView() [1/2]

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

◆ BufferView() [2/2]

template<typename SampleType = float>
pulp::audio::BufferView< SampleType >::BufferView ( SampleType *const * channel_ptrs,
std::size_t num_channels,
std::size_t num_samples )
inline

Construct from an array of per-channel pointers.

Parameters
channel_ptrsArray of at least num_channels pointers.
num_channelsNumber of audio channels.
num_samplesNumber of samples per channel in this block.

Member Function Documentation

◆ channel() [1/2]

template<typename SampleType = float>
std::span< SampleType > pulp::audio::BufferView< 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::BufferView< SampleType >::channel ( std::size_t index) const
inline

Get a span over all samples in one channel.

Parameters
indexZero-based channel index.

◆ channel_ptr() [1/2]

template<typename SampleType = float>
SampleType * pulp::audio::BufferView< SampleType >::channel_ptr ( std::size_t index)
inline

Raw pointer to one channel's sample data.

◆ channel_ptr() [2/2]

template<typename SampleType = float>
const SampleType * pulp::audio::BufferView< SampleType >::channel_ptr ( std::size_t index) const
inline

Raw pointer to one channel's sample data.

◆ clear()

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

Zero-fill all channels.

◆ empty()

template<typename SampleType = float>
bool pulp::audio::BufferView< SampleType >::empty ( ) const
inline

True if the buffer has zero channels or zero samples.

◆ has_valid_channels()

template<typename SampleType = float>
bool pulp::audio::BufferView< SampleType >::has_valid_channels ( ) const
inlinenoexcept

Check channel storage before a caller dereferences a borrowed host view.

This checks pointer presence, not the lifetime or allocation extent.

◆ num_channels()

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

◆ num_samples()

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

◆ slice()

template<typename SampleType = float>
BufferView pulp::audio::BufferView< SampleType >::slice ( std::size_t start,
std::size_t length ) const
inline

Create a non-owning slice over this view.

The returned view references the same channel-pointer array and is valid for no longer than the source view. start and length are clamped to this view's sample range.


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