#include <samples.hpp>
template<typename T, bool is_planar>
v_1_0_0::SampleSequence class
A sequence of samples represented by 16 or 32 bit integral types.
Template parameters | |
---|---|
T | The sample type to read |
is_planar | TRUE indicates two planar buffers while FALSE indicates an interleaved buffer |
Calculation expects an update represented by two iterators that enumerate the audio input as a sequence of 32 bit unsigned integers of which each represents a pair of 16-bit stereo PCM samples. SampleSequence is a read-only compatibility wrapper for passing sample buffers of an integral sample format with 16 or 32 bit width to Calculation::
The use of a SampleSequence for providing the updates is optional, the caller may decide to provide the required sample format completely without using SampleSequence.
When wrapping the original audio data in a SampleSequence, it must be correctly declared as either interleaved or planar. It is furthermore required to know the size of the input and its channel ordering. If no channel ordering is specified, the default is LEFT/RIGHT.
A SampleSequence can wrap integer buffers of type T by member function wrap_int_buffer(). Regardless for which T the SampleSequence is instantiated, it will always be able to also wrap byte buffers by function wrap_byte_buffer(). While wrap_int_buffer() expects samples of type T, wrap_byte_buffer() accepts a uint8_t typed buffer and converts those bytes to T.
A SampleSequence instance can be reused by just calling wrap_int_buffer() or wrap_byte_buffer() on the existing instance. While channel ordering, size and the actual sample buffers can be changed, it is not possible to correctly wrap samples that are not represented by type T.
Random reading access is provided by operator[] (without bounds check) or at() (providing bounds check). A SampleSequence provides also access via iterators.
The caller is responsible for the lifetime of the wrapped sample buffer: SampleSequence will only provide a compatibility layer, it will not erase the wrapped buffers. A SampleSequence can therefore safely be destroyed without affecting the wrapped buffer.