FlutterProcess.cpp (1400B)
1 #include "FlutterProcess.h" 2 3 void FlutterProcess::prepare (double sampleRate, int samplesPerBlock, int numChannels) 4 { 5 fs = (float) sampleRate; 6 7 depthSlew.resize ((size_t) numChannels); 8 for (auto& dSlew : depthSlew) 9 { 10 dSlew.reset (sampleRate, 0.05); 11 dSlew.setCurrentAndTargetValue (depthSlewMin); 12 } 13 14 phase1.resize ((size_t) numChannels, 0.0f); 15 phase2.resize ((size_t) numChannels, 0.0f); 16 phase3.resize ((size_t) numChannels, 0.0f); 17 18 amp1 = -230.0f * 1000.0f / fs; 19 amp2 = -80.0f * 1000.0f / fs; 20 amp3 = -99.0f * 1000.0f / fs; 21 dcOffset = 350.0f * 1000.0f / fs; 22 23 flutterBuffer.setSize (numChannels, samplesPerBlock); 24 } 25 26 void FlutterProcess::prepareBlock (float curDepth, float flutterFreq, int numSamples, int numChannels) 27 { 28 for (auto& dSlew : depthSlew) 29 dSlew.setTargetValue (jmax (depthSlewMin, curDepth)); 30 31 angleDelta1 = MathConstants<float>::twoPi * flutterFreq / fs; 32 angleDelta2 = 2.0f * angleDelta1; 33 angleDelta3 = 3.0f * angleDelta1; 34 35 flutterBuffer.setSize (numChannels, numSamples, false, false, true); 36 flutterBuffer.clear(); 37 flutterPtrs = flutterBuffer.getArrayOfWritePointers(); 38 } 39 40 void FlutterProcess::plotBuffer (foleys::MagicPlotSource* plot) 41 { 42 if (shouldTurnOff()) 43 flutterBuffer.clear(); 44 45 flutterBuffer.applyGain (1.3333f / amp1); 46 plot->pushSamples (flutterBuffer); 47 }