==============================================================================
| 514 | |
| 515 | //============================================================================== |
| 516 | void FireAudioProcessor::prepareToPlay(double sampleRate, int samplesPerBlock) |
| 517 | { |
| 518 | // Use this method as the place to do any pre-playback |
| 519 | // initialisation that you need.. |
| 520 | auto channels = static_cast<juce::uint32>(juce::jmin(getMainBusNumInputChannels(), getMainBusNumOutputChannels())); |
| 521 | juce::dsp::ProcessSpec spec { sampleRate, static_cast<juce::uint32>(samplesPerBlock), channels }; |
| 522 | |
| 523 | for (int i = 0; i < 4; ++i) |
| 524 | { |
| 525 | if (auto* band = bands[i].get()) |
| 526 | { |
| 527 | // Call the newly simplified prepare method |
| 528 | band->prepare(spec); |
| 529 | |
| 530 | // ** THIS IS THE CRUCIAL ADDITION ** |
| 531 | // Initialize smoothed values here, from the treeState |
| 532 | // TODO: need to use new drive logic instead of ParameterID::driveIds[i]) |
| 533 | // band->newDriveSmoother.setCurrentAndTargetValue(*treeState.getRawParameterValue(ParameterID::driveIds[i])); |
| 534 | band->recSmoother.setCurrentAndTargetValue(*treeState.getRawParameterValue(ParameterIDAndName::getIDString(REC_ID, i))); |
| 535 | band->biasSmoother.setCurrentAndTargetValue(*treeState.getRawParameterValue(ParameterIDAndName::getIDString(BIAS_ID, i))); |
| 536 | } |
| 537 | } |
| 538 | |
| 539 | lfoManager->prepare(spec); |
| 540 | |
| 541 | // historyArray init |
| 542 | for (int i = 0; i < samplesPerBlock; i++) |
| 543 | { |
| 544 | historyArrayL.add(0); |
| 545 | historyArrayR.add(0); |
| 546 | } |
| 547 | |
| 548 | // dry wet buffer init |
| 549 | // mDryBuffer.setSize(getTotalNumInputChannels(), samplesPerBlock); |
| 550 | // mDryBuffer.clear(); |
| 551 | delayMatchedDryBuffer.setSize(getTotalNumOutputChannels(), samplesPerBlock); |
| 552 | delayMatchedDryBuffer.clear(); |
| 553 | |
| 554 | mWetBuffer.setSize(getTotalNumInputChannels(), samplesPerBlock); |
| 555 | mWetBuffer.clear(); |
| 556 | |
| 557 | // oversampling init |
| 558 | for (size_t i = 0; i < 4; i++) |
| 559 | { |
| 560 | oversamplingHQ[i]->reset(); |
| 561 | oversamplingHQ[i]->initProcessing(static_cast<size_t>(samplesPerBlock)); |
| 562 | } |
| 563 | mDelay.reset(0); |
| 564 | |
| 565 | const float rampTimeSeconds = 0.0005f; |
| 566 | |
| 567 | lowcutFreqSmoother.reset(sampleRate, rampTimeSeconds); |
| 568 | lowcutFreqSmoother.setCurrentAndTargetValue(*treeState.getRawParameterValue(LOWCUT_FREQ_ID)); |
| 569 | lowcutGainSmoother.reset(sampleRate, rampTimeSeconds); |
| 570 | lowcutGainSmoother.setCurrentAndTargetValue(*treeState.getRawParameterValue(LOWCUT_GAIN_ID)); |
| 571 | lowcutQualitySmoother.reset(sampleRate, rampTimeSeconds); |
| 572 | lowcutQualitySmoother.setCurrentAndTargetValue(*treeState.getRawParameterValue(LOWCUT_Q_ID)); |
| 573 |