AnalogTapeModel

Physical modelling signal processing for analog tape recording
Log | Files | Refs | Submodules | README | LICENSE

WowProcess.cpp (1369B)


      1 #include "WowProcess.h"
      2 
      3 WowProcess::~WowProcess()
      4 {
      5     depthSlew.clear();
      6 }
      7 
      8 void WowProcess::prepare (double sampleRate, int samplesPerBlock, int numChannels)
      9 {
     10     fs = (float) sampleRate;
     11 
     12     depthSlew.resize ((size_t) numChannels);
     13     for (auto& dSlew : depthSlew)
     14     {
     15         dSlew.reset (sampleRate, 0.05);
     16         dSlew.setCurrentAndTargetValue (depthSlewMin);
     17     }
     18 
     19     phase.resize ((size_t) numChannels, 0.0f);
     20 
     21     amp = 1000.0f * 1000.0f / (float) sampleRate;
     22     wowBuffer.setSize (numChannels, samplesPerBlock);
     23 
     24     ohProc.prepare (sampleRate, samplesPerBlock, numChannels);
     25 }
     26 
     27 void WowProcess::prepareBlock (float curDepth, float wowFreq, float wowVar, float wowDrift, int numSamples, int numChannels)
     28 {
     29     for (auto& dSlew : depthSlew)
     30         dSlew.setTargetValue (jmax (depthSlewMin, curDepth));
     31 
     32     auto freqAdjust = wowFreq * (1.0f + std::pow (driftRand.nextFloat(), 1.25f) * wowDrift);
     33     angleDelta = MathConstants<float>::twoPi * freqAdjust / fs;
     34 
     35     wowBuffer.setSize (numChannels, numSamples, false, false, true);
     36     wowBuffer.clear();
     37     wowPtrs = wowBuffer.getArrayOfWritePointers();
     38 
     39     ohProc.prepareBlock (wowVar, numSamples);
     40 }
     41 
     42 void WowProcess::plotBuffer (foleys::MagicPlotSource* plot)
     43 {
     44     if (shouldTurnOff())
     45         wowBuffer.clear();
     46 
     47     wowBuffer.applyGain (0.83333f / amp);
     48     plot->pushSamples (wowBuffer);
     49 }