Jamba C++ API 8.0.0
Loading...
Searching...
No Matches
AudioBuffers< SampleType > Class Template Reference

Represents all the buffers (example for a stereo channel there is 2 underlying sample buffers). More...

#include <AudioBuffer.h>

Classes

struct  AbsoluteMaxOp
 Unary operator adapter for computing the absolute max. More...
class  Channel
 Represents a single channel (for example left audio channel). More...

Public Types

typedef AudioBuffers class_type

Public Member Functions

SampleType absoluteMax () const
bool adjustSilenceFlags ()
 Computes and adjust the silence flags.
 AudioBuffers (AudioBusBuffers &buffer, int32 numSamples)
tresult clear ()
 Clears the buffer (and sets the silence flag).
void clearSilentFlag ()
 Makes the buffer NON silent (by setting the flag to 0).
tresult copyFrom (class_type const &fromBuffer)
 Copy the content of the provided buffer to THIS buffer (up to num samples).
template<UnaryTransformer< SampleType > F>
copyFrom (class_type const &iFromBuffer, F f)
 Copy iFromBuffer to this buffer, applying f to each sample for each channel or in other words, for each channel c and each sample i.
template<UnaryTransformer< SampleType > F>
copyTo (class_type &iToBuffer, F f) const
 Same as copyFrom with the roles reversed.
tresult copyTo (class_type &toBuffer) const
 Copy the content of THIS buffer to the provided buffer (up to num samples).
template<UnaryModifier< SampleType > F>
forEachSample (F f)
 Applies the provided unary function to each sample of each channel.
template<UnaryFunction< SampleType > F>
forEachSample (F f) const
 Applies the provided unary function to each sample of each channel.
AudioBusBuffers & getAudioBusBuffers ()
 Returns the AudioBusBuffers original buffer.
AudioBusBuffers const & getAudioBusBuffers () const
 Returns the AudioBusBuffers original buffer (const version).
Channel getAudioChannel (int32 iChannel)
 Return the audio channel for the provided channel.
Channel getAudioChannel (int32 iChannel) const
 Return the audio channel for the provided channel.
Sample64 ** getBuffer ()
Sample32 ** getBuffer ()
SampleType ** getBuffer ()
 Returns the underlying (sample) buffer.
Sample64 const *const * getBuffer () const
Sample32 const *const * getBuffer () const
SampleType const *const * getBuffer () const
Channel getLeftChannel ()
Channel getLeftChannel () const
int32 getNumChannels () const
int32 getNumSamples () const
Channel getRightChannel ()
Channel getRightChannel () const
uint64 getSilenceFlags () const
bool isSilent () const
bool isSilent (int32 iChannel) const
void setSilenceFlag (int32 iChannel, bool iSilent)
 Sets a single channel silence flag.
void setSilenceFlags (uint64 iFlags)

Private Attributes

AudioBusBuffers & fBuffer
const int32 fNumSamples

Detailed Description

template<std::floating_point SampleType>
class pongasoft::VST::AudioBuffers< SampleType >

Represents all the buffers (example for a stereo channel there is 2 underlying sample buffers).

Template Parameters
SampleType

Member Typedef Documentation

◆ class_type

template<std::floating_point SampleType>
typedef AudioBuffers class_type

Constructor & Destructor Documentation

◆ AudioBuffers()

template<std::floating_point SampleType>
AudioBuffers ( AudioBusBuffers & buffer,
int32 numSamples )
inline

Member Function Documentation

◆ absoluteMax()

template<std::floating_point SampleType>
SampleType absoluteMax ( ) const
inline
Returns
the max sample (absolute) across all channels

◆ adjustSilenceFlags()

template<std::floating_point SampleType>
bool adjustSilenceFlags ( )
inline

Computes and adjust the silence flags.

Returns
true if the buffer is silent (meaning all channels are silent)

◆ clear()

template<std::floating_point SampleType>
tresult clear ( )
inline

Clears the buffer (and sets the silence flag).

◆ clearSilentFlag()

template<std::floating_point SampleType>
void clearSilentFlag ( )
inline

Makes the buffer NON silent (by setting the flag to 0).

A flag is set to 1 when silent, so when set to 0 it is non silent...

◆ copyFrom() [1/2]

template<std::floating_point SampleType>
tresult copyFrom ( class_type const & fromBuffer)
inline

Copy the content of the provided buffer to THIS buffer (up to num samples).

◆ copyFrom() [2/2]

template<std::floating_point SampleType>
template<UnaryTransformer< SampleType > F>
F copyFrom ( class_type const & iFromBuffer,
F f )
inline

Copy iFromBuffer to this buffer, applying f to each sample for each channel or in other words, for each channel c and each sample i.

getChannel(c).getBuffer[i] = f(iFromBuffer.getChannel(c).getBuffer[i]);

Example:

AudioBuffers<SampleType> in(data.inputs[0], data.numSamples);
AudioBuffers<SampleType> out(data.outputs[0], data.numSamples);

double gain = 0.5;
out.copyFrom(in, [gain](SampleType iSample) { return iSample * gain; });
Template Parameters
Fcan be a lambda, a function object (etc...) but should provide an api similar to std::function<SampleType(SampleType)>
Returns
the function provided

◆ copyTo() [1/2]

template<std::floating_point SampleType>
template<UnaryTransformer< SampleType > F>
F copyTo ( class_type & iToBuffer,
F f ) const
inline

Same as copyFrom with the roles reversed.

◆ copyTo() [2/2]

template<std::floating_point SampleType>
tresult copyTo ( class_type & toBuffer) const
inline

Copy the content of THIS buffer to the provided buffer (up to num samples).

◆ forEachSample() [1/2]

template<std::floating_point SampleType>
template<UnaryModifier< SampleType > F>
F forEachSample ( F f)
inline

Applies the provided unary function to each sample of each channel.

Example:

double gain = 0.5;
out.forEachSample([gain](SampleType &iSample) { iSample *= gain; });
Template Parameters
Fcan be a lambda, a function object (etc...) but should provide an api similar to std::function<ignored(SampleType)> or std::function<ignored(SampleType &)>
Returns
the function (similar api as std::for_each)

◆ forEachSample() [2/2]

template<std::floating_point SampleType>
template<UnaryFunction< SampleType > F>
F forEachSample ( F f) const
inline

Applies the provided unary function to each sample of each channel.

Because the method is const, the unary function cannot modify the elements.

Example:

auto max = out.forEachSample(AbsoluteMaxOp()).fAbsoluteMax;
Template Parameters
Fcan be a lambda, a function object (etc...) but should provide an api similar to std::function<ignored(SampleType)> or std::function<ignored(SampleType const &)>
Returns
the function (similar api as std::for_each)

◆ getAudioBusBuffers() [1/2]

template<std::floating_point SampleType>
AudioBusBuffers & getAudioBusBuffers ( )
inline

Returns the AudioBusBuffers original buffer.

◆ getAudioBusBuffers() [2/2]

template<std::floating_point SampleType>
AudioBusBuffers const & getAudioBusBuffers ( ) const
inline

Returns the AudioBusBuffers original buffer (const version).

◆ getAudioChannel() [1/2]

template<std::floating_point SampleType>
Channel getAudioChannel ( int32 iChannel)
inline

Return the audio channel for the provided channel.

Note that this method never fails and will return an object where Channel::isActive returns false in the event the channel is not active.

Returns
the audio channel provided its channel

◆ getAudioChannel() [2/2]

template<std::floating_point SampleType>
Channel getAudioChannel ( int32 iChannel) const
inline

Return the audio channel for the provided channel.

Note that this method never fails and will return an object where Channel::isActive returns false in the event the channel is not active.

Returns
the audio channel provided its channel

◆ getBuffer() [1/6]

Sample64 ** getBuffer ( )
inline

◆ getBuffer() [2/6]

Sample32 ** getBuffer ( )
inline

◆ getBuffer() [3/6]

template<std::floating_point SampleType>
SampleType ** getBuffer ( )

Returns the underlying (sample) buffer.

◆ getBuffer() [4/6]

Sample64 const *const * getBuffer ( ) const
inline

◆ getBuffer() [5/6]

Sample32 const *const * getBuffer ( ) const
inline

◆ getBuffer() [6/6]

template<std::floating_point SampleType>
SampleType const *const * getBuffer ( ) const

◆ getLeftChannel() [1/2]

template<std::floating_point SampleType>
Channel getLeftChannel ( )
inline
Returns
the left channel (using the fact that the left channel is 0)

◆ getLeftChannel() [2/2]

template<std::floating_point SampleType>
Channel getLeftChannel ( ) const
inline
Returns
the left channel (using the fact that the left channel is 0)

◆ getNumChannels()

template<std::floating_point SampleType>
int32 getNumChannels ( ) const
inline
Returns
number of channels (2 for stereo) of the underlying buffer

◆ getNumSamples()

template<std::floating_point SampleType>
int32 getNumSamples ( ) const
inline
Returns
number of samples in the buffer

◆ getRightChannel() [1/2]

template<std::floating_point SampleType>
Channel getRightChannel ( )
inline
Returns
the right channel (using the fact that the left channel is 1)

◆ getRightChannel() [2/2]

template<std::floating_point SampleType>
Channel getRightChannel ( ) const
inline
Returns
the right channel (using the fact that the left channel is 1)

◆ getSilenceFlags()

template<std::floating_point SampleType>
uint64 getSilenceFlags ( ) const
inline

◆ isSilent() [1/2]

template<std::floating_point SampleType>
bool isSilent ( ) const
inline

◆ isSilent() [2/2]

template<std::floating_point SampleType>
bool isSilent ( int32 iChannel) const
inline
Returns
true if the channel is silent (according to silenceFlags)

◆ setSilenceFlag()

template<std::floating_point SampleType>
void setSilenceFlag ( int32 iChannel,
bool iSilent )
inline

Sets a single channel silence flag.

◆ setSilenceFlags()

template<std::floating_point SampleType>
void setSilenceFlags ( uint64 iFlags)
inline

Member Data Documentation

◆ fBuffer

template<std::floating_point SampleType>
AudioBusBuffers& fBuffer
private

◆ fNumSamples

template<std::floating_point SampleType>
const int32 fNumSamples
private

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