Represents a single channel (for example left audio channel).
More...
#include <AudioBuffer.h>
|
| SampleType | absoluteMax () const |
| | Channel (AudioBuffers &iBuffers, int32 iChannel) |
| void | clear () |
| | Clears the channel (and sets the silence flag).
|
| tresult | copyFrom (Channel const &fromChannel) |
| | Copy the content of the provided channel to THIS channel (up to num samples).
|
| template<typename UnaryOperation> |
| UnaryOperation | copyFrom (Channel const &iFromChannel, UnaryOperation f) |
| | Copy iFromChannel to this channel, applying f to each sample or in other words, for each sample.
|
| template<typename UnaryOperation> |
| UnaryOperation | copyTo (Channel &oToChannel, UnaryOperation f) const |
| | Same as copyFrom with the roles reversed.
|
| tresult | copyTo (Channel &toChannel) const |
| | Copy the content of THIS channel to the provided channel (up to num samples).
|
| template<typename UnaryFunction> |
| UnaryFunction | forEachSample (UnaryFunction f) |
| | Applies the provided unary function to each sample (if the channel is active).
|
| template<typename UnaryFunction> |
| UnaryFunction | forEachSample (UnaryFunction f) const |
| | Applies the provided unary function to each sample (if the channel is active).
|
| SampleType * | getBuffer () |
| | Note that this pointer is NOT guaranteed to be not null as demonstrated by this piece of logic in the Audio Unit wrapper code:
|
| SampleType const * | getBuffer () const |
| | Note that this pointer is NOT guaranteed to be not null as demonstrated by this piece of logic in the Audio Unit wrapper code:
|
| int32 | getNumSamples () const |
| bool | isActive () const |
| bool | isSilent () const |
| void | setSilenceFlag (bool iSilent) |
| | Sets a single channel silence flag.
|
template<typename SampleType>
class pongasoft::VST::AudioBuffers< SampleType >::Channel
Represents a single channel (for example left audio channel).
Note an instance of this class may represent an invalid/non active channel in which case the various methods will react accordingly (ex: getBuffer returns nullptr, forEachSample doesn't do anything, etc...)
◆ Channel()
template<typename SampleType>
◆ absoluteMax()
template<typename SampleType>
| SampleType absoluteMax |
( |
| ) |
const |
|
inline |
- Returns
- the max sample (absolute) for this channel
◆ clear()
template<typename SampleType>
Clears the channel (and sets the silence flag).
◆ copyFrom() [1/2]
template<typename SampleType>
| tresult copyFrom |
( |
Channel const & | fromChannel | ) |
|
|
inline |
Copy the content of the provided channel to THIS channel (up to num samples).
◆ copyFrom() [2/2]
template<typename SampleType>
template<typename UnaryOperation>
| UnaryOperation copyFrom |
( |
Channel const & | iFromChannel, |
|
|
UnaryOperation | f ) |
|
inline |
Copy iFromChannel to this channel, applying f to each sample or in other words, for each sample.
getBuffer[i] = f(iFromChannel.getBuffer[i]);
This handles properly inactive channels (nothing done if either of the channel is inactive) and channels of different sizes.
Example:
AudioBuffers<SampleType> in(data.inputs[0], data.numSamples);
AudioBuffers<SampleType> out(data.outputs[0], data.numSamples);
double gain = 0.5;
out.getLeftChannel().copyFrom(in.getLeftChannel(), [gain](SampleType iSample) { return iSample * gain; });
- Template Parameters
-
| UnaryOperation | can 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<typename SampleType>
template<typename UnaryOperation>
| UnaryOperation copyTo |
( |
Channel & | oToChannel, |
|
|
UnaryOperation | f ) const |
|
inline |
Same as copyFrom with the roles reversed.
◆ copyTo() [2/2]
template<typename SampleType>
| tresult copyTo |
( |
Channel & | toChannel | ) |
const |
|
inline |
Copy the content of THIS channel to the provided channel (up to num samples).
◆ forEachSample() [1/2]
template<typename SampleType>
template<typename UnaryFunction>
| UnaryFunction forEachSample |
( |
UnaryFunction | f | ) |
|
|
inline |
Applies the provided unary function to each sample (if the channel is active).
Example:
double gain = 0.5;
leftChannel.forEachSample([gain](SampleType &iSample) { iSample *= gain; });
- Template Parameters
-
| UnaryFunction | can be a lambda, a function object (etc...) but should provide an api similar to std::function<void(SampleType)> or std::function<void(SampleType &)> |
- Returns
- the function (similar api as std::for_each)
◆ forEachSample() [2/2]
template<typename SampleType>
template<typename UnaryFunction>
| UnaryFunction forEachSample |
( |
UnaryFunction | f | ) |
const |
|
inline |
Applies the provided unary function to each sample (if the channel is active).
Because the method is const, the unary function cannot modify the elements.
Example:
auto max = leftChannel.forEachSample(AbsoluteMaxOp()).fAbsoluteMax;
- Template Parameters
-
| UnaryFunction | can be a lambda, a function object (etc...) but should provide an api similar to std::function<void(SampleType)> or std::function<void(SampleType const &)> |
- Returns
- the function (similar api as std::for_each)
◆ getBuffer() [1/2]
template<typename SampleType>
| SampleType * getBuffer |
( |
| ) |
|
|
inline |
Note that this pointer is NOT guaranteed to be not null as demonstrated by this piece of logic in the Audio Unit wrapper code:
...
processData.inputs[i].channelBuffers32[channel] =
input->IsActive () ? (Sample32*)input->GetBufferList ().mBuffers[channel].mData : 0;
...
- Returns
- the underlying sample buffer or nullptr if not active
◆ getBuffer() [2/2]
template<typename SampleType>
| SampleType const * getBuffer |
( |
| ) |
const |
|
inline |
Note that this pointer is NOT guaranteed to be not null as demonstrated by this piece of logic in the Audio Unit wrapper code:
...
processData.inputs[i].channelBuffers32[channel] =
input->IsActive () ? (Sample32*)input->GetBufferList ().mBuffers[channel].mData : 0;
...
- Returns
- the underlying sample buffer or nullptr if not active
◆ getNumSamples()
template<typename SampleType>
| int32 getNumSamples |
( |
| ) |
const |
|
inline |
- Returns
- number of samples in the buffer
◆ isActive()
template<typename SampleType>
- Returns
- true if this channel is active, meaning there is such a channel and its buffer is not null
◆ isSilent()
template<typename SampleType>
- Returns
- true if this channel is silent (according to silenceFlags)
◆ setSilenceFlag()
template<typename SampleType>
| void setSilenceFlag |
( |
bool | iSilent | ) |
|
|
inline |
Sets a single channel silence flag.
◆ fBuffers
template<typename SampleType>
◆ fChannel
template<typename SampleType>
The documentation for this class was generated from the following file: