MCPcopy Create free account
hub / github.com/VCVRack/Befaco / processBottomSection

Method processBottomSection

src/NoisePlethora.cpp:378–417  ·  view source on GitHub ↗

process section C

Source from the content-addressed store, hash-verified

376
377 // process section C
378 void processBottomSection(const ProcessArgs& args) {
379
380 float gritCv = rescale(clamp(inputs[GRIT_INPUT].getVoltage(), -10.f, 10.f), -10.f, 10.f, -1.f, 1.f);
381 float gritAmount = clamp(params[GRIT_PARAM].getValue() + gritCv, 0.f, 1.f);
382 float gritFrequency = 0.1 + std::pow(gritAmount, 2) * 20000;
383 gritNoiseSource.setDensity(gritFrequency);
384 float gritNoise = gritNoiseSource.process(args.sampleTime);
385 outputs[GRITTY_OUTPUT].setVoltage(gritNoise * 5.f);
386
387 float whiteNoise = whiteNoiseSource.process();
388 outputs[WHITE_OUTPUT].setVoltage(whiteNoise * 5.f);
389
390 float out = 0.f;
391 if (outputs[FILTERED_OUTPUT].isConnected() && !bypassFilters) {
392
393 const float freqCV = std::pow(params[CUTOFF_CV_C_PARAM].getValue(), 2) * inputs[CUTOFF_C_INPUT].getVoltage();
394 const float pitch = rescale(params[CUTOFF_C_PARAM].getValue(), 0, 1, -5.f, +6.4f) + freqCV;
395 const float cutoff = clamp(dsp::FREQ_C4 * std::pow(2.f, pitch), 1.f, 44100. / 2.f);
396 const float cutoffNormalised = clamp(cutoff / args.sampleRate, 0.f, 0.49f);
397 const float Q = 0.5 + std::pow(params[RES_C_PARAM].getValue(), 2) * 20.f;
398 const FilterMode mode = typeMappingSVF[(int) params[FILTER_TYPE_C_PARAM].getValue()];
399 svfFilterC.setParameters(cutoffNormalised, Q);
400
401 float toFilter = params[SOURCE_C_PARAM].getValue() ? whiteNoise : gritNoise;
402 out = svfFilterC.process(toFilter, mode);
403
404 // assymetric saturator, to get those lovely even harmonics
405 out = Saturator<float>::process(out + 0.33);
406
407 if (blockDC) {
408 // cascaded Biquad (4th order highpass at ~20Hz)
409 out = blockDCFilter[SECTION_C].process(out);
410 }
411 }
412 else if (bypassFilters) {
413 out = params[SOURCE_C_PARAM].getValue() ? whiteNoise : gritNoise;
414 }
415
416 outputs[FILTERED_OUTPUT].setVoltage(out * 5.f);
417 }
418
419 // set which text NoisePlethoraWidget should display on the 7 segment display
420 void updateDataForLEDDisplay() {

Callers

nothing calls this directly

Calls 4

getValueMethod · 0.80
setDensityMethod · 0.80
processMethod · 0.45
setParametersMethod · 0.45

Tested by

no test coverage detected