This is where we tell JUCE what to do when prepareToPlay is called for a single band.
| 45 | |
| 46 | // This is where we tell JUCE what to do when prepareToPlay is called for a single band. |
| 47 | void BandProcessor::prepare(const juce::dsp::ProcessSpec& spec) |
| 48 | { |
| 49 | // Prepare all the DSP modules with the sample rate and block size. |
| 50 | compressor.prepare(spec); |
| 51 | gain.prepare(spec); |
| 52 | juce::dsp::ProcessSpec mixerSpec = spec; |
| 53 | mixerSpec.maximumBlockSize = spec.maximumBlockSize * 4 + 64; |
| 54 | dryWetMixer.prepare(mixerSpec); |
| 55 | shapeMixer.prepare(mixerSpec); |
| 56 | compressorMixer.prepare(mixerSpec); |
| 57 | widthMixer.prepare(mixerSpec); |
| 58 | |
| 59 | // The DC filter needs its coefficients to be calculated. |
| 60 | dcFilter.prepare(spec); |
| 61 | *dcFilter.state = *juce::dsp::IIR::Coefficients<float>::makeHighPass(spec.sampleRate, 20.0f); |
| 62 | |
| 63 | // The oversampling object also needs to be prepared. |
| 64 | oversampling = std::make_unique<juce::dsp::Oversampling<float>>(spec.numChannels, oversampleFactor, juce::dsp::Oversampling<float>::filterHalfBandPolyphaseIIR, false); |
| 65 | oversampling->initProcessing(spec.maximumBlockSize); |
| 66 | |
| 67 | // Reset all smoothed values with the current sample rate and a ramp time. |
| 68 | driveSmoother.reset(spec.sampleRate, 0.05); |
| 69 | biasSmoother.reset(spec.sampleRate, 0.05); |
| 70 | recSmoother.reset(spec.sampleRate, 0.05); |
| 71 | } |
| 72 | |
| 73 | // This is what happens when we need to clear the internal state of a band's processors. |
| 74 | void BandProcessor::reset() |