11#include " PluginProcessor.h"
22#include " PluginEditor.h"
3+ #include < JuceHeader.h>
34#include < iostream>
45#include < jonssonic/utils/buffer_utils.h>
56
@@ -20,19 +21,36 @@ ChorusAudioProcessor::ChorusAudioProcessor() : parameterManager(ChorusParams().c
2021 // Register callbacks for parameter changes
2122 using ID = ChorusParams::ID;
2223
23- parameterManager.on (ID::Mix, [this ](float value, bool skipSmoothing) {
24- DBG (" [DEBUG] Mix changed: " + juce::String (value) + " , skipSmoothing: " + (skipSmoothing ? " true" : " false" ));
25- // Call your DSP mix setter here
26- dryWetMixer.setMix (value * 0 .01f ); // We are converting from [0,100] to [0,1]
24+ parameterManager.on (ID::Rate, [this ](float value, bool skipSmoothing) {
25+ DBG (" [DEBUG] Rate changed: " + juce::String (value) + " , skipSmoothing: " + (skipSmoothing ? " true" : " false" ));
26+ chorus.setRate (value, skipSmoothing);
27+ });
28+
29+ parameterManager.on (ID::Depth, [this ](float value, bool skipSmoothing) {
30+ DBG (" [DEBUG] Depth changed: " + juce::String (value) + " , skipSmoothing: " + (skipSmoothing ? " true" : " false" ));
31+ chorus.setDepth (value * 0 .01f , skipSmoothing); // We are converting from [0,100] to [0,1]
32+ });
33+
34+ parameterManager.on (ID::Spread, [this ](float value, bool skipSmoothing) {
35+ DBG (" [DEBUG] Spread changed: " + juce::String (value) +
36+ " , skipSmoothing: " + (skipSmoothing ? " true" : " false" ));
37+ chorus.setSpread (value * 0 .01f , skipSmoothing); // We are converting from [0,100] to [0,1]
2738 });
28- parameterManager.on (ID::Enable, [this ](bool value, bool skipSmoothing) {
29- DBG (" [DEBUG] Enable changed: " + juce::String (value ? " true" : " false" ) +
39+
40+ parameterManager.on (ID::Delay, [this ](float value, bool skipSmoothing) {
41+ DBG (" [DEBUG] Delay changed: " + juce::String (value) + " , skipSmoothing: " + (skipSmoothing ? " true" : " false" ));
42+ chorus.setDelayMs (value, skipSmoothing);
43+ });
44+
45+ parameterManager.on (ID::Feedback, [this ](float value, bool skipSmoothing) {
46+ DBG (" [DEBUG] Feedback changed: " + juce::String (value) +
3047 " , skipSmoothing: " + (skipSmoothing ? " true" : " false" ));
31- // Call your DSP enable setter here
48+ chorus. setFeedback (value * 0 . 01f , skipSmoothing); // We are converting from [0,100] to [0,1]
3249 });
33- parameterManager.on (ID::Mode, [this ](int value, bool skipSmoothing) {
34- DBG (" [DEBUG] Mode changed: " + juce::String (value) + " , skipSmoothing: " + (skipSmoothing ? " true" : " false" ));
35- // Call your DSP mode setter here
50+
51+ parameterManager.on (ID::Mix, [this ](float value, bool skipSmoothing) {
52+ DBG (" [DEBUG] Mix changed: " + juce::String (value) + " , skipSmoothing: " + (skipSmoothing ? " true" : " false" ));
53+ dryWetMixer.setMix (value * 0 .01f ); // We are converting from [0,100] to [0,1]
3654 });
3755}
3856
@@ -43,6 +61,7 @@ void ChorusAudioProcessor::prepareToPlay(double sampleRate, int samplesPerBlock)
4361 // Prepare all DSP objects and buffers here
4462 dryWetMixer.prepare (numChannels, static_cast <float >(sampleRate));
4563 fxBuffer.resize (numChannels, static_cast <size_t >(samplesPerBlock));
64+ chorus.prepare (numChannels, static_cast <float >(sampleRate));
4665
4766 // Initialize DSP with parameter defaults (defined in Params.h) (skip smoothing for instant setup)
4867 parameterManager.syncAll (true );
@@ -52,6 +71,7 @@ void ChorusAudioProcessor::releaseResources() {
5271 // Release DSP resources here
5372 dryWetMixer.reset ();
5473 fxBuffer.resize (0 , 0 );
74+ chorus.reset ();
5575}
5676
5777void ChorusAudioProcessor::processBlock (juce::AudioBuffer<float >& buffer, juce::MidiBuffer& midiMessages) {
@@ -78,7 +98,10 @@ void ChorusAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer, juce::
7898 numOutputChannels,
7999 numSamples);
80100
81- // DSP processing here (this template includes only a dry/wet mixer as an example)
101+ // Process the chorus effect
102+ chorus.processBlock (fxBuffer.readPtrs (), fxBuffer.writePtrs (), static_cast <size_t >(numSamples));
103+
104+ // Dry/wet processing
82105 dryWetMixer.processBlock (buffer.getArrayOfReadPointers (), // dry buffer
83106 fxBuffer.readPtrs (), // wet buffer
84107 buffer.getArrayOfWritePointers (), // final output
0 commit comments