MCPcopy Create free account
hub / github.com/LabSound/LabSound / process

Method process

src/internal/src/DynamicsCompressorKernel.cpp:187–452  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187void DynamicsCompressorKernel::process(ContextRenderLock & r,
188 const float * sourceChannels[],
189 float * destinationChannels[],
190 unsigned numberOfChannels,
191 int framesToProcess,
192 float dbThreshold,
193 float dbKnee,
194 float ratio,
195 float attackTime,
196 float releaseTime,
197 float preDelayTime,
198 float dbPostGain,
199 float effectBlend, /* equal power crossfade */
200 float releaseZone1,
201 float releaseZone2,
202 float releaseZone3,
203 float releaseZone4)
204{
205 ASSERT(m_preDelayBuffers.size() == numberOfChannels);
206
207 float sampleRate = r.context()->sampleRate();
208
209 m_meteringReleaseK = static_cast<float>(discreteTimeConstantForSampleRate(meteringReleaseTimeConstant, sampleRate));
210
211 float dryMix = 1 - effectBlend;
212 float wetMix = effectBlend;
213
214 float k = updateStaticCurveParameters(dbThreshold, dbKnee, ratio);
215
216 // Makeup gain.
217 float fullRangeGain = saturate(1, k);
218 float fullRangeMakeupGain = 1 / fullRangeGain;
219
220 // Empirical/perceptual tuning.
221 fullRangeMakeupGain = powf(fullRangeMakeupGain, 0.6f);
222
223 float masterLinearGain = decibelsToLinear(dbPostGain) * fullRangeMakeupGain;
224
225 // Attack parameters.
226 attackTime = max(0.001f, attackTime);
227 float attackFrames = attackTime * sampleRate;
228
229 // Release parameters.
230 float releaseFrames = sampleRate * releaseTime;
231
232 // Detector release time.
233 float satReleaseTime = 0.0025f;
234 float satReleaseFrames = satReleaseTime * sampleRate;
235
236 // Create a smooth function which passes through four points.
237
238 // Polynomial of the form
239 // y = a + b*x + c*x^2 + d*x^3 + e*x^4;
240
241 float y1 = releaseFrames * releaseZone1;
242 float y2 = releaseFrames * releaseZone2;
243 float y3 = releaseFrames * releaseZone3;
244 float y4 = releaseFrames * releaseZone4;

Callers

nothing calls this directly

Calls 4

sizeMethod · 0.80
sampleRateMethod · 0.45
contextMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected