21#include <pluginterfaces/vst/ivstaudioprocessor.h>
22#include <pongasoft/logging/logging.h>
30using namespace Steinberg;
31using namespace Steinberg::Vst;
42template<
typename SampleType>
150 if(!ptrFrom || !ptrTo)
153 std::copy(ptrFrom, ptrFrom + numSamples, ptrTo);
193 template<
typename UnaryFunction>
218 template<
typename UnaryFunction>
251 template<
typename UnaryOperation>
255 auto inputBuffer = iFromChannel.
getBuffer();
257 if(outputBuffer && inputBuffer)
263 std::transform<decltype(inputBuffer), decltype(outputBuffer), UnaryOperation &>(inputBuffer, inputBuffer + numSamples, outputBuffer, f);
272 template<
typename UnaryOperation>
275 return oToChannel.
copyFrom(*
this, f);
293 return fBuffer.numChannels == 0 ||
fBuffer.silenceFlags == (
static_cast<uint64
>(1) <<
fBuffer.numChannels) - 1;
302 uint64 silenceFlags = 0;
310 auto ptr = buffer[channel];
324 BIT_SET(silenceFlags, channel);
327 fBuffer.silenceFlags = silenceFlags;
381 return Channel{*
this, iChannel};
393 return Channel{*
const_cast<class_type *
>(
this), iChannel};
450 template<
typename UnaryFunction>
473 template<
typename UnaryFunction>
494 auto fromSamples = fromBuffer.
getBuffer();
498 if(fromSamples == toSamples)
502 if(!fromSamples || !toSamples)
508 for(int32 channel = 0; channel < numChannels; channel++)
510 auto ptrFrom = fromSamples[channel];
511 auto ptrTo = toSamples[channel];
514 if(!ptrFrom || !ptrTo)
517 std::copy(ptrFrom, ptrFrom + numSamples, ptrTo);
541 template<
typename UnaryOperation>
546 for(int32 channel = 0; channel < numChannels; channel++)
557 template<
typename UnaryOperation>
#define BIT_TEST(a, b)
Definition AudioUtils.h:34
#define BIT_CLEAR(a, b)
Definition AudioUtils.h:33
#define BIT_SET(a, b)
Definition AudioUtils.h:32
UnaryOperation copyFrom(Channel const &iFromChannel, UnaryOperation f)
Copy iFromChannel to this channel, applying f to each sample or in other words, for each sample.
Definition AudioBuffer.h:252
SampleType const * getBuffer() const
Note that this pointer is NOT guaranteed to be not null as demonstrated by this piece of logic in the...
Definition AudioBuffer.h:108
bool isActive() const
Definition AudioBuffer.h:129
UnaryOperation copyTo(Channel &oToChannel, UnaryOperation f) const
Same as copyFrom with the roles reversed.
Definition AudioBuffer.h:273
bool isSilent() const
Definition AudioBuffer.h:116
void setSilenceFlag(bool iSilent)
Sets a single channel silence flag.
Definition AudioBuffer.h:121
int32 fChannel
Definition AudioBuffer.h:280
SampleType absoluteMax() const
Definition AudioBuffer.h:161
SampleType * getBuffer()
Note that this pointer is NOT guaranteed to be not null as demonstrated by this piece of logic in the...
Definition AudioBuffer.h:92
tresult copyFrom(Channel const &fromChannel)
Copy the content of the provided channel to THIS channel (up to num samples).
Definition AudioBuffer.h:142
int32 getNumSamples() const
Definition AudioBuffer.h:76
UnaryFunction forEachSample(UnaryFunction f)
Applies the provided unary function to each sample (if the channel is active).
Definition AudioBuffer.h:194
UnaryFunction forEachSample(UnaryFunction f) const
Applies the provided unary function to each sample (if the channel is active).
Definition AudioBuffer.h:219
AudioBuffers & fBuffers
Definition AudioBuffer.h:279
void clear()
Clears the channel (and sets the silence flag).
Definition AudioBuffer.h:168
tresult copyTo(Channel &toChannel) const
Copy the content of THIS channel to the provided channel (up to num samples).
Definition AudioBuffer.h:137
Channel(AudioBuffers &iBuffers, int32 iChannel)
Definition AudioBuffer.h:69
Represents all the buffers (example for a stereo channel there is 2 underlying sample buffers).
Definition AudioBuffer.h:44
Channel getRightChannel()
Definition AudioBuffer.h:409
AudioBusBuffers & fBuffer
Definition AudioBuffer.h:581
Channel getLeftChannel()
Definition AudioBuffer.h:399
tresult clear()
Clears the buffer (and sets the silence flag).
Definition AudioBuffer.h:570
Channel getAudioChannel(int32 iChannel)
Return the audio channel for the provided channel.
Definition AudioBuffer.h:379
void setSilenceFlag(int32 iChannel, bool iSilent)
Sets a single channel silence flag.
Definition AudioBuffer.h:341
const Channel getAudioChannel(int32 iChannel) const
Return the audio channel for the provided channel.
Definition AudioBuffer.h:390
bool isSilent(int32 iChannel) const
Definition AudioBuffer.h:364
uint64 getSilenceFlags() const
Definition AudioBuffer.h:333
bool isSilent() const
Definition AudioBuffer.h:291
AudioBusBuffers const & getAudioBusBuffers() const
Returns the AudioBusBuffers original buffer (const version).
Definition AudioBuffer.h:426
AudioBusBuffers & getAudioBusBuffers()
Returns the AudioBusBuffers original buffer.
Definition AudioBuffer.h:423
SampleType absoluteMax() const
Definition AudioBuffer.h:563
tresult copyTo(class_type &toBuffer) const
Copy the content of THIS buffer to the provided buffer (up to num samples).
Definition AudioBuffer.h:487
void clearSilentFlag()
Makes the buffer NON silent (by setting the flag to 0).
Definition AudioBuffer.h:356
int32 getNumSamples() const
Definition AudioBuffer.h:436
void setSilenceFlags(uint64 iFlags) const
Definition AudioBuffer.h:336
SampleType ** getBuffer()
Returns the underlying (sample) buffer.
UnaryFunction forEachSample(UnaryFunction f)
Applies the provided unary function to each sample of each channel.
Definition AudioBuffer.h:451
UnaryFunction forEachSample(UnaryFunction f) const
Applies the provided unary function to each sample of each channel.
Definition AudioBuffer.h:474
const int32 fNumSamples
Definition AudioBuffer.h:582
AudioBuffers< SampleType > class_type
Definition AudioBuffer.h:283
SampleType const *const * getBuffer() const
const Channel getRightChannel() const
Definition AudioBuffer.h:414
int32 getNumChannels() const
Definition AudioBuffer.h:431
tresult copyFrom(class_type const &fromBuffer)
Copy the content of the provided buffer to THIS buffer (up to num samples).
Definition AudioBuffer.h:492
const Channel getLeftChannel() const
Definition AudioBuffer.h:404
UnaryOperation copyTo(class_type &iToBuffer, UnaryOperation f) const
Same as copyFrom with the roles reversed.
Definition AudioBuffer.h:558
AudioBuffers(AudioBusBuffers &buffer, int32 numSamples)
Definition AudioBuffer.h:287
UnaryOperation copyFrom(class_type const &iFromBuffer, UnaryOperation f)
Copy iFromBuffer to this buffer, applying f to each sample for each channel or in other words,...
Definition AudioBuffer.h:542
bool adjustSilenceFlags()
Computes and adjust the silence flags.
Definition AudioBuffer.h:300
constexpr int32 DEFAULT_RIGHT_CHANNEL
Definition AudioBuffer.h:35
bool isSilent(Sample32 value)
Definition AudioUtils.h:63
AudioBuffers< Sample64 > AudioBuffers64
Definition AudioBuffer.h:598
constexpr int32 DEFAULT_LEFT_CHANNEL
Definition AudioBuffer.h:34
AudioBuffers< Sample32 > AudioBuffers32
Definition AudioBuffer.h:597
Unary operator adapter for computing the absolute max.
Definition AudioBuffer.h:50
SampleType fAbsoluteMax
Definition AudioBuffer.h:56
void operator()(SampleType iSample)
Definition AudioBuffer.h:51