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

Method process

Source/PluginProcessor.cpp:93–197  ·  view source on GitHub ↗

============================================================================== This is the new, self-contained processing function for a single band. It replaces the old `processOneBand` and `processDistortion` functions. ==============================================================================

Source from the content-addressed store, hash-verified

91// It replaces the old `processOneBand` and `processDistortion` functions.
92//==============================================================================
93void BandProcessor::process(juce::AudioBuffer<float>& buffer,
94 const BandProcessingParameters& params,
95 const juce::AudioBuffer<float>& lfoOutputs)
96{
97 // 1. Preparation
98 const float mixVal = params.mixVal;
99 juce::AudioBuffer<float> dryBuffer;
100 dryBuffer.makeCopyOf(buffer);
101 auto block = juce::dsp::AudioBlock<float>(buffer);
102 auto paramsForProcessing = params; // Create a mutable copy
103
104 // 2. Core Distortion Processing
105 if (params.isHQ)
106 {
107 auto oversampledBlock = oversampling->processSamplesUp(block);
108
109 // --- LFO Upsampling ---
110 juce::AudioBuffer<float> upsampledLfoOutputs(lfoOutputs.getNumChannels(), oversampledBlock.getNumSamples());
111 if (lfoOutputs.getNumSamples() > 1 && upsampledLfoOutputs.getNumSamples() > 1)
112 {
113 for (int channel = 0; channel < lfoOutputs.getNumChannels(); ++channel)
114 {
115 auto* dest = upsampledLfoOutputs.getWritePointer(channel);
116 const auto* src = lfoOutputs.getReadPointer(channel);
117 const float step = (float) (lfoOutputs.getNumSamples() - 1) / (float) (upsampledLfoOutputs.getNumSamples() - 1);
118 for (int i = 0; i < upsampledLfoOutputs.getNumSamples(); ++i)
119 {
120 const float sourcePos = (float) i * step;
121 const int index0 = (int) sourcePos;
122 const int index1 = juce::jmin(index0 + 1, lfoOutputs.getNumSamples() - 1);
123 const float frac = sourcePos - (float) index0;
124 dest[i] = src[index0] * (1.0f - frac) + src[index1] * frac;
125 }
126 }
127 }
128
129 // Bind the upsampled LFO signals to the providers
130 if (params.driveLfoSourceIndex != -1)
131 paramsForProcessing.driveVal.lfoSignal = upsampledLfoOutputs.getReadPointer(params.driveLfoSourceIndex);
132 if (params.biasLfoSourceIndex != -1)
133 paramsForProcessing.biasVal.lfoSignal = upsampledLfoOutputs.getReadPointer(params.biasLfoSourceIndex);
134 if (params.recLfoSourceIndex != -1)
135 paramsForProcessing.recVal.lfoSignal = upsampledLfoOutputs.getReadPointer(params.recLfoSourceIndex);
136 if (params.outputLfoSourceIndex != -1)
137 paramsForProcessing.outputVal.lfoSignal = upsampledLfoOutputs.getReadPointer(params.outputLfoSourceIndex);
138
139 processDistortion(oversampledBlock, dryBuffer, paramsForProcessing);
140 oversampling->processSamplesDown(block);
141 }
142 else
143 {
144 // Bind the original LFO signals to the providers
145 if (params.driveLfoSourceIndex != -1)
146 paramsForProcessing.driveVal.lfoSignal = lfoOutputs.getReadPointer(params.driveLfoSourceIndex);
147 if (params.biasLfoSourceIndex != -1)
148 paramsForProcessing.biasVal.lfoSignal = lfoOutputs.getReadPointer(params.biasLfoSourceIndex);
149 if (params.recLfoSourceIndex != -1)
150 paramsForProcessing.recVal.lfoSignal = lfoOutputs.getReadPointer(params.recLfoSourceIndex);

Callers 6

applyGainFunction · 0.45
processDistortionMethod · 0.45
processGainMethod · 0.45
splitBandsMethod · 0.45
processMultiBandMethod · 0.45
applyGlobalEffectsMethod · 0.45

Calls 1

applyGainFunction · 0.85

Tested by

no test coverage detected