37 template <
typename FloatType>
41 Gain() noexcept =
default;
45 void setGainLinear (FloatType newGain) noexcept { gain.setTargetValue (newGain); }
51 FloatType
getGainLinear() const noexcept {
return gain.getTargetValue(); }
59 if (rampDurationSeconds != newDurationSeconds)
61 rampDurationSeconds = newDurationSeconds;
70 bool isSmoothing() const noexcept {
return gain.isSmoothing(); }
76 sampleRate = spec.sampleRate;
84 gain.reset (sampleRate, rampDurationSeconds);
89 template <
typename SampleType>
92 return s * gain.getNextValue();
96 template <
typename ProcessContext>
97 void process (
const ProcessContext& context) noexcept
99 auto&& inBlock = context.getInputBlock();
100 auto&& outBlock = context.getOutputBlock();
102 jassert (inBlock.getNumChannels() == outBlock.getNumChannels());
103 jassert (inBlock.getNumSamples() == outBlock.getNumSamples());
105 auto len = inBlock.getNumSamples();
106 auto numChannels = inBlock.getNumChannels();
108 if (context.isBypassed)
110 gain.skip (
static_cast<int> (len));
112 if (context.usesSeparateInputAndOutputBlocks())
113 outBlock.copyFrom (inBlock);
118 if (numChannels == 1)
120 auto* src = inBlock.getChannelPointer (0);
121 auto* dst = outBlock.getChannelPointer (0);
123 for (
size_t i = 0; i < len; ++i)
124 dst[i] = src[i] * gain.getNextValue();
128 auto* gains =
static_cast<FloatType*
> (alloca (
sizeof (FloatType) * len));
130 for (
size_t i = 0; i < len; ++i)
131 gains[i] = gain.getNextValue();
133 for (
size_t chan = 0; chan < numChannels; ++chan)
135 inBlock.getChannelPointer (chan),
136 gains,
static_cast<int> (len));
143 double sampleRate = 0, rampDurationSeconds = 0;
static void JUCE_CALLTYPE multiply(float *dest, const float *src, int numValues) noexcept
FloatType getGainDecibels() const noexcept
FloatType getGainLinear() const noexcept
void prepare(const ProcessSpec &spec) noexcept
double getRampDurationSeconds() const noexcept
bool isSmoothing() const noexcept
void setGainLinear(FloatType newGain) noexcept
SampleType JUCE_VECTOR_CALLTYPE processSample(SampleType s) noexcept
void process(const ProcessContext &context) noexcept
void setRampDurationSeconds(double newDurationSeconds) noexcept
void setGainDecibels(FloatType newGainDecibels) noexcept