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;
94 double m_initialGainLinear;
99 for (size_t channel = 0; channel < input.getNumChannels(); ++channel)
101 if (channelsToProcess
[channel
] ==
true)
103 for (size_t frame = 0; frame < input.getNumFrames(); ++frame)
104 output[channel][frame] = input[channel][frame] * (SampleType) m_gainLinear;
108 for (size_t frame = 0; frame < input.getNumFrames(); ++frame)
109 output[channel][frame] = input[channel][frame];
114 void processEnvelopedGain (
const AudioBuffer<SampleType>& input,
AudioBuffer<SampleType>& output,
const std::vector<
double>& gainEnvelopeValues,
ChannelFlags channelsToProcess)
116 for (size_t channel = 0; channel < input.getNumChannels(); ++channel)
118 if (channelsToProcess
[channel
] ==
true)
120 for (size_t frame = 0; frame < input.getNumFrames(); ++frame)
121 output[channel][frame] = input[channel][frame] * (SampleType) gainEnvelopeValues[frame];
125 for (size_t frame = 0; frame < input.getNumFrames(); ++frame)
126 output[channel][frame] = input[channel][frame];
Container for audio data.
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.
Thrown when a numbers of channels is mismatched.
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.
#define HART_DSP_COPYABLE(ClassName)
Implements a generic hart::DSP::copy() method.
#define HART_THROW_OR_RETURN_VOID(ExceptionType, message)
Throws an exception if HART_DO_NOT_THROW_EXCEPTIONS is set, prints a message and returns otherwise.
#define hassert(condition)
Triggers a HartAssertException if the condition is false
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)