MCPcopy Create free account
hub / github.com/jerryuhoo/Fire / applyGain

Function applyGain

Source/PluginProcessor.cpp:14–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12#include "PluginEditor.h"
13
14static void applyGain(juce::AudioBuffer<float>& buffer, const ModulatedValueProvider& gainProvider)
15{
16 // If the gain is not modulated, we can use the efficient block-based JUCE gain processor.
17 if (gainProvider.lfoSignal == nullptr)
18 {
19 juce::dsp::Gain<float> gain;
20 gain.setGainDecibels(gainProvider.baseValue);
21 gain.setRampDurationSeconds(0.05f); // Apply smoothing for manual changes
22
23 auto block = juce::dsp::AudioBlock<float>(buffer);
24 auto context = juce::dsp::ProcessContextReplacing<float>(block);
25 gain.process(context);
26 }
27 else // If gain is modulated, we must apply it sample-by-sample.
28 {
29 for (int channel = 0; channel < buffer.getNumChannels(); ++channel)
30 {
31 auto* channelData = buffer.getWritePointer(channel);
32 for (int sample = 0; sample < buffer.getNumSamples(); ++sample)
33 {
34 // The provider does all the complex calculation for us!
35 const float gainDb = gainProvider.get(sample);
36 channelData[sample] *= juce::Decibels::decibelsToGain(gainDb);
37 }
38 }
39 }
40}
41
42//==============================================================================
43// BandProcessor Implementation

Callers 2

processMethod · 0.85
applyGlobalEffectsMethod · 0.85

Calls 2

getMethod · 0.80
processMethod · 0.45

Tested by

no test coverage detected