16template <
typename SampleType>
29 m_initialGainLinear (initialGainLinear),
30 m_gainLinear (initialGainLinear)
34 void prepare (
double , size_t , size_t , size_t )
override {}
38 const size_t numInputChannels = input.getNumChannels();
39 const size_t numOutputChannels = output.getNumChannels();
40 hassert (output.getNumFrames() == input.getNumFrames());
45 const bool hasGainEnvelope = ! envelopeBuffers.empty() &&
contains (envelopeBuffers
, (
int)
Params::gainLinear
);
50 processConstantGain (input, output, channelsToProcess);
59 if (id ==
Params::gainLinear)
67 if (id ==
Params::gainLinear)
76 return numInputChannels == numOutputChannels;
79 virtual void represent (std::ostream& stream)
const override
81 stream <<
dbPrecision <<
"GainLinear (" << m_initialGainLinear <<
")";
88 return id ==
Params::gainLinear;
92 double m_initialGainLinear;
97 for (size_t channel = 0; channel < input.getNumChannels(); ++channel)
99 if (channelsToProcess
[channel
] ==
true)
101 for (size_t frame = 0; frame < input.getNumFrames(); ++frame)
102 output[channel][frame] = input[channel][frame] * (SampleType) m_gainLinear;
106 for (size_t frame = 0; frame < input.getNumFrames(); ++frame)
107 output[channel][frame] = input[channel][frame];
112 void processEnvelopedGain (
const AudioBuffer<SampleType>& input,
AudioBuffer<SampleType>& output,
const std::vector<
double>& gainEnvelopeValues,
ChannelFlags channelsToProcess)
114 for (size_t channel = 0; channel < input.getNumChannels(); ++channel)
116 if (channelsToProcess
[channel
] ==
true)
118 for (size_t frame = 0; frame < input.getNumFrames(); ++frame)
119 output[channel][frame] = input[channel][frame] * (SampleType) gainEnvelopeValues[frame];
123 for (size_t frame = 0; frame < input.getNumFrames(); ++frame)
124 output[channel][frame] = input[channel][frame];
A set of boolean flags mapped to each audio channel.
std::bitset< m_maxChannels >::reference operator[](size_t channel)
Access the flag value for a specific channel.
Applies linear gain (not decibels) to the signal.
virtual bool supportsChannelLayout(size_t numInputChannels, size_t numOutputChannels) const override
void prepare(double, size_t, size_t, size_t) override
Prepare for processing.
double getValue(int id) const override
virtual void represent(std::ostream &stream) const override
Makes a text representation of this DSP effect for test failure outputs.
void process(const AudioBuffer< SampleType > &input, AudioBuffer< SampleType > &output, const EnvelopeBuffers &envelopeBuffers, ChannelFlags channelsToProcess) override
Processes the audio.
void setValue(int id, double value) override
bool supportsEnvelopeFor(int id) const override
void reset() override
Resets to initial state.
GainLinear(double initialGainLinear=1.0)
Constructor.
std::ostream & dbPrecision(std::ostream &stream)
Sets number of decimal places for values in decibels.
static bool contains(const std::unordered_map< KeyType, ValueType > &map, const KeyType &key)
std::unordered_map::contains() replacement for C++11
#define HART_DSP_DECLARE_ALIASES_FOR(ClassName)
#define HART_THROW_OR_RETURN_VOID(ExceptionType, message)
#define hassert(condition)