瀏覽代碼

Add files via upload

AlindaEGercek 6 月之前
父節點
當前提交
2628bed941

+ 40 - 0
JUCE/CMLSProject/Source/CMLSDistortion.cpp

@@ -0,0 +1,40 @@
+#include "CMLSDistortion.h"
+
+CMLSDistortion::CMLSDistortion() {}
+
+void CMLSDistortion::prepare(const juce::dsp::ProcessSpec& spec) {
+    inputGain.prepare(spec);
+    outputGain.prepare(spec);
+    inputGain.setGainDecibels(0.0f);
+    outputGain.setGainDecibels(0.0f);
+}
+
+void CMLSDistortion::reset() {
+    inputGain.reset();
+    outputGain.reset();
+}
+
+void CMLSDistortion::process(const juce::dsp::ProcessContextReplacing<float>& context) {
+    auto& block = context.getOutputBlock();
+    inputGain.process(context);
+
+    for (size_t ch = 0; ch < block.getNumChannels(); ++ch) {
+        auto* data = block.getChannelPointer(ch);
+        for (size_t i = 0; i < block.getNumSamples(); ++i) {
+            float dry = data[i];
+            float wet = std::tanh(data[i] * drive);  // soft clipping
+            data[i] = dry * (1.0f - mix) + wet * mix; // apply mix
+        }
+    }
+
+    outputGain.process(context);
+}
+
+void CMLSDistortion::setDrive(float newDrive) {
+    drive = newDrive;
+}
+
+void CMLSDistortion::setMix(float newMix)
+{
+    mix = juce::jlimit(0.0f, 1.0f, newMix); // between 0.0 and 1.0
+}

+ 24 - 0
JUCE/CMLSProject/Source/CMLSDistortion.h

@@ -0,0 +1,24 @@
+#pragma once
+
+#include <JuceHeader.h>
+
+class CMLSDistortion : public juce::dsp::ProcessorBase {
+public:
+    CMLSDistortion();
+    ~CMLSDistortion() override = default;
+
+    void prepare(const juce::dsp::ProcessSpec&) override;
+    void reset() override;
+    void process(const juce::dsp::ProcessContextReplacing<float>&) override;
+
+    void setDrive(float drive); // controls intensity
+    void setMix(float mix);     // controls the dry/wet mix ratio,how much of the distorted signal is mixed with the original signal
+                                // 0.0 = dry, 1.0 = full distortion
+
+private:
+    float drive = 1.0f;
+    float mix = 1.0f;
+
+    juce::dsp::Gain<float> inputGain, outputGain;
+};
+#pragma once

+ 36 - 0
JUCE/CMLSProject/Source/CMLSEqualizer.cpp

@@ -0,0 +1,36 @@
+#include "CMLSEqualizer.h"
+
+CMLSEqualizer::CMLSEqualizer() {}
+
+void CMLSEqualizer::prepare(const juce::dsp::ProcessSpec& spec) {
+    sampleRate = spec.sampleRate;
+
+    lowBand.prepare(spec);
+    highBand.prepare(spec);
+
+    lowBand.reset();
+    highBand.reset();
+
+    setEqLowGain(0.0f);
+    setEqHighGain(0.0f);
+}
+
+void CMLSEqualizer::reset() {
+    lowBand.reset();
+    highBand.reset();
+}
+
+void CMLSEqualizer::process(const juce::dsp::ProcessContextReplacing<float>& context) {
+    lowBand.process(context);
+    highBand.process(context);
+}
+
+void CMLSEqualizer::setEqLowGain(float gain) {
+    *lowBand.state = *juce::dsp::IIR::Coefficients<float>::makeLowShelf(
+        sampleRate, 200.0f, 0.7f, juce::Decibels::decibelsToGain(gain));
+}
+
+void CMLSEqualizer::setEqHighGain(float gain) {
+    *highBand.state = *juce::dsp::IIR::Coefficients<float>::makeHighShelf(
+        sampleRate, 5000.0f, 0.7f, juce::Decibels::decibelsToGain(gain));
+}

+ 21 - 0
JUCE/CMLSProject/Source/CMLSEqualizer.h

@@ -0,0 +1,21 @@
+#pragma once
+
+#include <JuceHeader.h>
+
+class CMLSEqualizer : public juce::dsp::ProcessorBase {
+public:
+    CMLSEqualizer();
+    ~CMLSEqualizer() override = default;
+
+    void prepare(const juce::dsp::ProcessSpec&) override;
+    void reset() override;
+    void process(const juce::dsp::ProcessContextReplacing<float>&) override;
+
+    void setEqLowGain(float);
+    void setEqHighGain(float);
+
+private:
+    double sampleRate = 44100.0; // default, will be updated
+    juce::dsp::ProcessorDuplicator<juce::dsp::IIR::Filter<float>,
+        juce::dsp::IIR::Coefficients<float>> lowBand, highBand;
+};

+ 100 - 127
JUCE/CMLSProject/Source/PluginEditor.cpp

@@ -1,127 +1,100 @@
-/*
-  ==============================================================================
-
-    This file contains the basic framework code for a JUCE plugin editor.
-
-  ==============================================================================
-*/
-
-#include "PluginProcessor.h"
-#include "PluginEditor.h"
-
-//==============================================================================
-CMLSProjectAudioProcessorEditor::CMLSProjectAudioProcessorEditor (CMLSProjectAudioProcessor& p)
-    : AudioProcessorEditor (&p), audioProcessor (p)
-{
-    // Make sure that before the constructor has finished, you've set the
-    // editor's size to whatever you need it to be.
-    setSize (400, 300);
-
-	// Add aliders to the editor (Chorus)
-    this->chorusDryWetSlider.setRange(0.0, 1.0);
-    this->chorusDryWetSlider.setTextBoxStyle(juce::Slider::TextBoxRight, false, 100, 20);
-    this->chorusDryWetSlider.addListener(this);
-    this->chorusDryWetLabel.setText("Chorus Dry/Wet", juce::dontSendNotification);
-
-    addAndMakeVisible(this->chorusDryWetSlider);
-    addAndMakeVisible(this->chorusDryWetLabel);
-
-    this->chorusAmountSlider.setRange(0.0, 1.0);
-    this->chorusAmountSlider.setTextBoxStyle(juce::Slider::TextBoxRight, false, 100, 20);
-    this->chorusAmountSlider.addListener(this);
-    this->chorusAmountLabel.setText("Chorus Amount", juce::dontSendNotification);
-
-    addAndMakeVisible(this->chorusAmountSlider);
-    addAndMakeVisible(this->chorusAmountLabel);
-
-    // Add sliders to the editor (Reverb)
-    this->reverbDryWetSlider.setRange(0.0, 1.0);
-    this->reverbDryWetSlider.setTextBoxStyle(juce::Slider::TextBoxRight, false, 100, 20);
-    this->reverbDryWetSlider.addListener(this);
-    this->reverbDryWetLabel.setText("Reverb Dry/Wet", juce::dontSendNotification);
-
-    addAndMakeVisible(this->reverbDryWetSlider);
-    addAndMakeVisible(this->reverbDryWetLabel);
-
-    this->reverbRoomSizeSlider.setRange(0.0, 1.0);
-    this->reverbRoomSizeSlider.setTextBoxStyle(juce::Slider::TextBoxRight, false, 100, 20);
-    this->reverbRoomSizeSlider.addListener(this);
-    this->reverbRoomSizeLabel.setText("Reverb Room Size", juce::dontSendNotification);
-
-    addAndMakeVisible(this->reverbRoomSizeSlider);
-    addAndMakeVisible(this->reverbRoomSizeLabel);
-
-	// Add sliders to the editor (Delay)
-    this->delayDryWetSlider.setRange(0.0, 1.0);
-    this->delayDryWetSlider.setTextBoxStyle(juce::Slider::TextBoxRight, false, 100, 20);
-    this->delayDryWetSlider.addListener(this);
-    this->delayDryWetLabel.setText("Delay Dry/Wet", juce::dontSendNotification);
-
-    addAndMakeVisible(this->delayDryWetSlider);
-    addAndMakeVisible(this->delayDryWetLabel);
-
-    this->delayAmountSlider.setRange(0.0, 1.0);
-    this->delayAmountSlider.setTextBoxStyle(juce::Slider::TextBoxRight, false, 100, 20);
-    this->delayAmountSlider.addListener(this);
-    this->delayAmountLabel.setText("Delay Amount", juce::dontSendNotification);
-
-    addAndMakeVisible(this->delayAmountSlider);
-    addAndMakeVisible(this->delayAmountLabel);
-}
-
-CMLSProjectAudioProcessorEditor::~CMLSProjectAudioProcessorEditor()
-{
-}
-
-//==============================================================================
-void CMLSProjectAudioProcessorEditor::paint (juce::Graphics& g)
-{
-    // (Our component is opaque, so we must completely fill the background with a solid colour)
-    g.fillAll (getLookAndFeel().findColour (juce::ResizableWindow::backgroundColourId));
-}
-
-void CMLSProjectAudioProcessorEditor::resized()
-{
-	//titleLabel.setBounds(10, 10, getWidth() - 20, 20);
-	chorusDryWetSlider.setBounds(130, 10, getWidth() - 130, 20);
-    chorusDryWetLabel.setBounds(10, 10, 100, 20);
-    chorusAmountSlider.setBounds(130, 30, getWidth() - 130, 20);
-	chorusAmountLabel.setBounds(10, 30, 100, 20);
-
-    reverbDryWetSlider.setBounds(130, 70, getWidth() - 130, 20);
-	reverbDryWetLabel.setBounds(10, 70, 100, 20);
-    reverbRoomSizeSlider.setBounds(130, 90, getWidth() - 130, 20);
-	reverbRoomSizeLabel.setBounds(10, 90, 100, 20);
-
-    delayDryWetSlider.setBounds(130, 130, getWidth() - 130, 20);
-	delayDryWetLabel.setBounds(10, 130, 100, 20);
-    delayAmountSlider.setBounds(130, 150, getWidth() - 130, 20);
-	delayAmountLabel.setBounds(10, 150, 100, 20);
-}
-
-void CMLSProjectAudioProcessorEditor::sliderValueChanged(juce::Slider* slider){
-	if (slider == &this->chorusDryWetSlider)
-	{
-		this->audioProcessor.setChorusDryWet(slider->getValue());
-	}
-	else if (slider == &this->chorusAmountSlider)
-	{
-		this->audioProcessor.setChorusAmount(slider->getValue());
-	}
-	else if (slider == &this->reverbDryWetSlider)
-	{
-		this->audioProcessor.setReverbDryWet(slider->getValue());
-	}
-	else if (slider == &this->reverbRoomSizeSlider)
-	{
-		this->audioProcessor.setReverbRoomSize(slider->getValue());
-	}
-	else if (slider == &this->delayDryWetSlider)
-	{
-		this->audioProcessor.setDelayDryWet(slider->getValue());
-	}
-	else if (slider == &this->delayAmountSlider)
-	{
-		this->audioProcessor.setDelayAmount(slider->getValue());
-	}
-}
+/*
+  ==============================================================================
+
+    This file contains the basic framework code for a JUCE plugin editor.
+
+  ==============================================================================
+*/
+
+#include "PluginProcessor.h"
+#include "PluginEditor.h"
+
+//==============================================================================
+CMLSProjectAudioProcessorEditor::CMLSProjectAudioProcessorEditor (CMLSProjectAudioProcessor& p)
+    : AudioProcessorEditor (&p), audioProcessor (p)
+{
+    // Make sure that before the constructor has finished, you've set the
+    // editor's size to whatever you need it to be.
+    setSize (400, 300);
+
+
+    // equalizer
+    this->equalizerLowGainSlider.setRange(0.0, 1.0);
+    this->equalizerLowGainSlider.setTextBoxStyle(juce::Slider::TextBoxRight, false, 100, 20);
+    this->equalizerLowGainSlider.addListener(this);
+    this->equalizerLowGainLabel.setText("Equalizer Low Gain", juce::dontSendNotification);
+
+    addAndMakeVisible(this->equalizerLowGainSlider);
+    addAndMakeVisible(this->equalizerLowGainLabel);
+
+    this->equalizerHighGainSlider.setRange(0.0, 1.0);
+    this->equalizerHighGainSlider.setTextBoxStyle(juce::Slider::TextBoxRight, false, 100, 20);
+    this->equalizerHighGainSlider.addListener(this);
+    this->equalizerHighGainLabel.setText("Equalizer High Gain", juce::dontSendNotification);
+
+    addAndMakeVisible(this->equalizerHighGainSlider);
+    addAndMakeVisible(this->equalizerHighGainLabel);
+
+    // distortion
+    this->distortionDriveSlider.setRange(0.0, 1.0);
+    this->distortionDriveSlider.setTextBoxStyle(juce::Slider::TextBoxRight, false, 100, 20);
+    this->distortionDriveSlider.addListener(this);
+    this->distortionDriveLabel.setText("Distortion Drive", juce::dontSendNotification);
+
+    addAndMakeVisible(this->distortionDriveSlider);
+    addAndMakeVisible(this->distortionDriveLabel);
+
+    this->distortionMixSlider.setRange(0.0, 1.0);
+    this->distortionMixSlider.setTextBoxStyle(juce::Slider::TextBoxRight, false, 100, 20);
+    this->distortionMixSlider.addListener(this);
+    this->distortionMixLabel.setText("Distortion Mix", juce::dontSendNotification);
+
+    addAndMakeVisible(this->distortionMixSlider);
+    addAndMakeVisible(this->distortionMixLabel);
+}
+
+CMLSProjectAudioProcessorEditor::~CMLSProjectAudioProcessorEditor()
+{
+}
+
+//==============================================================================
+void CMLSProjectAudioProcessorEditor::paint (juce::Graphics& g)
+{
+    // (Our component is opaque, so we must completely fill the background with a solid colour)
+    g.fillAll (getLookAndFeel().findColour (juce::ResizableWindow::backgroundColourId));
+}
+
+void CMLSProjectAudioProcessorEditor::resized()
+{
+    // This is generally where you'll want to lay out the positions of any
+    // subcomponents in your editor..
+
+    equalizerLowGainSlider.setBounds(130, 10, getWidth() - 130, 20);
+    equalizerLowGainLabel.setBounds(10, 10, 100, 20);
+    equalizerHighGainSlider.setBounds(130, 30, getWidth() - 130, 20);
+    equalizerHighGainLabel.setBounds(10, 30, 100, 20);
+
+    distortionDriveSlider.setBounds(130, 70, getWidth() - 130, 20);
+    distortionDriveLabel.setBounds(10, 70, 100, 20);
+    distortionMixSlider.setBounds(130, 90, getWidth() - 130, 20);
+    distortionMixLabel.setBounds(10, 90, 100, 20);
+}
+
+void CMLSProjectAudioProcessorEditor::sliderValueChanged(juce::Slider* slider) {
+    if (slider == &this->equalizerLowGainSlider)
+    {
+        this->audioProcessor.setEqLowGain(slider->getValue());
+    }
+    else if (slider == &this->equalizerHighGainSlider)
+    {
+        this->audioProcessor.setEqHighGain(slider->getValue());
+    }
+    else if (slider == &this->distortionDriveSlider)
+    {
+        this->audioProcessor.setDistortionDrive(slider->getValue());
+    }
+    else if (slider == &this->distortionMixSlider)
+    {
+        this->audioProcessor.setDistortionMix(slider->getValue());
+    }
+}

+ 52 - 58
JUCE/CMLSProject/Source/PluginEditor.h

@@ -1,58 +1,52 @@
-/*
-  ==============================================================================
-
-    This file contains the basic framework code for a JUCE plugin editor.
-
-  ==============================================================================
-*/
-
-#pragma once
-
-#include <JuceHeader.h>
-#include "PluginProcessor.h"
-
-//==============================================================================
-/**
-*/
-class CMLSProjectAudioProcessorEditor  : public juce::AudioProcessorEditor,
-                                         public juce::Slider::Listener
-{
-public:
-    CMLSProjectAudioProcessorEditor (CMLSProjectAudioProcessor&);
-    ~CMLSProjectAudioProcessorEditor() override;
-
-    //==============================================================================
-    void paint (juce::Graphics&) override;
-    void resized() override;
-
-private:
-    // This reference is provided as a quick way for your editor to
-    // access the processor object that created it.
-    CMLSProjectAudioProcessor& audioProcessor;
-
-    // Title
-	juce::Label titleLabel;
-
-    // Chorus
-    juce::Slider chorusDryWetSlider;
-    juce::Label chorusDryWetLabel;
-    juce::Slider chorusAmountSlider;
-    juce::Label chorusAmountLabel;
-
-    // Reverb
-	juce::Slider reverbDryWetSlider;
-	juce::Label reverbDryWetLabel;
-	juce::Slider reverbRoomSizeSlider;
-	juce::Label reverbRoomSizeLabel;
-
-	// Delay
-	juce::Slider delayDryWetSlider;
-	juce::Label delayDryWetLabel;
-	juce::Slider delayAmountSlider;
-	juce::Label delayAmountLabel;
-
-    // Method to call when the slider value changes
-    void sliderValueChanged(juce::Slider* slider) override;
-
-    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CMLSProjectAudioProcessorEditor)
-};
+/*
+  ==============================================================================
+
+    This file contains the basic framework code for a JUCE plugin editor.
+
+  ==============================================================================
+*/
+
+#pragma once
+
+#include <JuceHeader.h>
+#include "PluginProcessor.h"
+
+//==============================================================================
+/**
+*/
+class CMLSProjectAudioProcessorEditor : public juce::AudioProcessorEditor,
+                                        public juce::Slider::Listener
+{
+public:
+    CMLSProjectAudioProcessorEditor (CMLSProjectAudioProcessor&);
+    ~CMLSProjectAudioProcessorEditor() override;
+
+    //==============================================================================
+    void paint (juce::Graphics&) override;
+    void resized() override;
+
+private:
+    // This reference is provided as a quick way for your editor to
+    // access the processor object that created it.
+    CMLSProjectAudioProcessor& audioProcessor;
+
+    // title
+    juce::Label titleLabel;
+
+    // equalizer
+    juce::Slider equalizerLowGainSlider;
+    juce::Label equalizerLowGainLabel;
+    juce::Slider equalizerHighGainSlider;
+    juce::Label equalizerHighGainLabel;
+
+    // distortion
+    juce::Slider distortionDriveSlider;
+    juce::Label distortionDriveLabel;
+    juce::Slider distortionMixSlider;
+    juce::Label distortionMixLabel;
+
+    // method to call when the slider value changes
+    void sliderValueChanged(juce::Slider* slider) override;
+
+    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CMLSProjectAudioProcessorEditor)
+};

+ 171 - 216
JUCE/CMLSProject/Source/PluginProcessor.cpp

@@ -1,216 +1,171 @@
-/*
-  ==============================================================================
-
-    This file contains the basic framework code for a JUCE plugin processor.
-
-  ==============================================================================
-*/
-
-#include "PluginProcessor.h"
-#include "PluginEditor.h"
-
-//==============================================================================
-CMLSProjectAudioProcessor::CMLSProjectAudioProcessor()
-#ifndef JucePlugin_PreferredChannelConfigurations
-     : AudioProcessor (BusesProperties()
-                     #if ! JucePlugin_IsMidiEffect
-                      #if ! JucePlugin_IsSynth
-                       .withInput  ("Input",  juce::AudioChannelSet::stereo(), true)
-                      #endif
-                       .withOutput ("Output", juce::AudioChannelSet::stereo(), true)
-                     #endif
-                       )
-#endif
-{
-    // Chaining the effects
-    this->processorChain.reset();
-    //this->processorChain.addNode<CMLSDelay>(2);
-}
-
-CMLSProjectAudioProcessor::~CMLSProjectAudioProcessor()
-{
-}
-
-//==============================================================================
-const juce::String CMLSProjectAudioProcessor::getName() const
-{
-    return JucePlugin_Name;
-}
-
-bool CMLSProjectAudioProcessor::acceptsMidi() const
-{
-   #if JucePlugin_WantsMidiInput
-    return true;
-   #else
-    return false;
-   #endif
-}
-
-bool CMLSProjectAudioProcessor::producesMidi() const
-{
-   #if JucePlugin_ProducesMidiOutput
-    return true;
-   #else
-    return false;
-   #endif
-}
-
-bool CMLSProjectAudioProcessor::isMidiEffect() const
-{
-   #if JucePlugin_IsMidiEffect
-    return true;
-   #else
-    return false;
-   #endif
-}
-
-double CMLSProjectAudioProcessor::getTailLengthSeconds() const
-{
-    return 0.0;
-}
-
-int CMLSProjectAudioProcessor::getNumPrograms()
-{
-    return 1;   // NB: some hosts don't cope very well if you tell them there are 0 programs,
-                // so this should be at least 1, even if you're not really implementing programs.
-}
-
-int CMLSProjectAudioProcessor::getCurrentProgram()
-{
-    return 0;
-}
-
-void CMLSProjectAudioProcessor::setCurrentProgram (int index)
-{
-}
-
-const juce::String CMLSProjectAudioProcessor::getProgramName (int index)
-{
-    return {};
-}
-
-void CMLSProjectAudioProcessor::changeProgramName (int index, const juce::String& newName)
-{
-}
-
-//==============================================================================
-void CMLSProjectAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
-{
-    // Use this method as the place to do any pre-playback
-    // initialisation that you need..
-    juce::dsp::ProcessSpec spec;
-    spec.maximumBlockSize = samplesPerBlock;
-    spec.numChannels = getTotalNumOutputChannels();
-    spec.sampleRate = sampleRate;
-
-	this->processorChain.prepare(spec);
-}
-
-void CMLSProjectAudioProcessor::releaseResources()
-{
-    // When playback stops, you can use this as an opportunity to free up any
-    // spare memory, etc.
-}
-
-#ifndef JucePlugin_PreferredChannelConfigurations
-bool CMLSProjectAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
-{
-  #if JucePlugin_IsMidiEffect
-    juce::ignoreUnused (layouts);
-    return true;
-  #else
-    // This is the place where you check if the layout is supported.
-    // In this template code we only support mono or stereo.
-    // Some plugin hosts, such as certain GarageBand versions, will only
-    // load plugins that support stereo bus layouts.
-    if (layouts.getMainOutputChannelSet() != juce::AudioChannelSet::mono()
-     && layouts.getMainOutputChannelSet() != juce::AudioChannelSet::stereo())
-        return false;
-
-    // This checks if the input layout matches the output layout
-   #if ! JucePlugin_IsSynth
-    if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
-        return false;
-   #endif
-
-    return true;
-  #endif
-}
-#endif
-
-void CMLSProjectAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midiMessages)
-{
-    juce::ScopedNoDenormals noDenormals;
-    auto totalNumInputChannels  = getTotalNumInputChannels();
-    auto totalNumOutputChannels = getTotalNumOutputChannels();
-
-    const auto numChannels = juce::jmax(totalNumInputChannels, totalNumOutputChannels);
-
-    auto audioBlock = juce::dsp::AudioBlock<float>(buffer).getSubsetChannelBlock(0, (int)numChannels);
-    auto context = juce::dsp::ProcessContextReplacing<float>(audioBlock);
-
-    /* Processing */
-	this->processorChain.process(context);
-}
-
-//==============================================================================
-bool CMLSProjectAudioProcessor::hasEditor() const
-{
-    return true; // (change this to false if you choose to not supply an editor)
-}
-
-juce::AudioProcessorEditor* CMLSProjectAudioProcessor::createEditor()
-{
-    return new CMLSProjectAudioProcessorEditor (*this);
-}
-
-//==============================================================================
-void CMLSProjectAudioProcessor::getStateInformation (juce::MemoryBlock& destData)
-{
-    // You should use this method to store your parameters in the memory block.
-    // You could do that either as raw data, or use the XML or ValueTree classes
-    // as intermediaries to make it easy to save and load complex data.
-}
-
-void CMLSProjectAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
-{
-    // You should use this method to restore your parameters from this memory block,
-    // whose contents will have been created by the getStateInformation() call.
-}
-
-void CMLSProjectAudioProcessor::setChorusDryWet(float value) {
-    auto& instance = this->processorChain.template get<0>();
-	instance.setDryWet(value);
-}
-
-void CMLSProjectAudioProcessor::setChorusAmount(float value) {
-	auto& instance = this->processorChain.template get<0>();
-	instance.setAmount(value);
-}
-
-void CMLSProjectAudioProcessor::setReverbDryWet(float value) {
-	auto& instance = this->processorChain.template get<1>();
-	instance.setDryWet(value);
-}
-
-void CMLSProjectAudioProcessor::setReverbRoomSize(float value) {
-	auto& instance = this->processorChain.template get<1>();
-	instance.setRoomSize(value);
-}
-
-void CMLSProjectAudioProcessor::setDelayDryWet(float value) {
-	auto& instance = this->processorChain.template get<2>();
-	instance.setDryWet(value);
-}
-
-void CMLSProjectAudioProcessor::setDelayAmount(float value) {
-	auto& instance = this->processorChain.template get<2>();
-	instance.setAmount(value);
-}
-
-//==============================================================================
-// This creates new instances of the plugin..
-juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter()
-{
-    return new CMLSProjectAudioProcessor();
-}
+#include "PluginProcessor.h"
+#include "PluginEditor.h"
+
+//==============================================================================
+CMLSProjectAudioProcessor::CMLSProjectAudioProcessor()
+#ifndef JucePlugin_PreferredChannelConfigurations
+    : AudioProcessor(BusesProperties()
+        #if ! JucePlugin_IsMidiEffect
+            #if ! JucePlugin_IsSynth
+             .withInput("Input", juce::AudioChannelSet::stereo(), true)
+            #endif
+             .withOutput("Output", juce::AudioChannelSet::stereo(), true)
+        #endif
+    )
+#endif
+{
+    // chaining the effects
+    this->processorChain.reset();
+}
+
+CMLSProjectAudioProcessor::~CMLSProjectAudioProcessor() {}
+
+//==============================================================================
+const juce::String CMLSProjectAudioProcessor::getName() const
+{
+    return JucePlugin_Name;
+}
+
+bool CMLSProjectAudioProcessor::acceptsMidi() const
+{
+    #if JucePlugin_WantsMidiInput
+        return true;
+    #else
+        return false;
+    #endif
+}
+
+bool CMLSProjectAudioProcessor::producesMidi() const
+{
+    #if JucePlugin_ProducesMidiOutput
+        return true;
+    #else
+        return false;
+    #endif
+}
+
+bool CMLSProjectAudioProcessor::isMidiEffect() const
+{
+    #if JucePlugin_IsMidiEffect
+        return true;
+    #else
+        return false;
+    #endif
+}
+
+double CMLSProjectAudioProcessor::getTailLengthSeconds() const
+{
+    return 0.0;
+}
+
+int CMLSProjectAudioProcessor::getNumPrograms() { return 1; }
+int CMLSProjectAudioProcessor::getCurrentProgram() { return 0; }
+void CMLSProjectAudioProcessor::setCurrentProgram(int index) {}
+const juce::String CMLSProjectAudioProcessor::getProgramName(int index) { return {}; }
+void CMLSProjectAudioProcessor::changeProgramName(int index, const juce::String& newName) {}
+
+//==============================================================================
+void CMLSProjectAudioProcessor::prepareToPlay(double sampleRate, int samplesPerBlock)
+{
+    // the place to do any pre-playback & initialisation
+    juce::dsp::ProcessSpec spec;
+    spec.sampleRate = sampleRate;
+    spec.maximumBlockSize = samplesPerBlock;
+    spec.numChannels = getTotalNumOutputChannels();
+
+    this->processorChain.prepare(spec);
+}
+
+void CMLSProjectAudioProcessor::releaseResources() {}
+
+#ifndef JucePlugin_PreferredChannelConfigurations
+bool CMLSProjectAudioProcessor::isBusesLayoutSupported(const BusesLayout& layouts) const
+{
+    #if JucePlugin_IsMidiEffect
+        juce::ignoreUnused(layouts);
+        return true;
+    #else
+        // This is the place where you check if the layout is supported.
+        // In this template code we only support mono or stereo.
+        if (layouts.getMainOutputChannelSet() != juce::AudioChannelSet::mono()
+         && layouts.getMainOutputChannelSet() != juce::AudioChannelSet::stereo())
+            return false;
+        // This checks if the input layout matches the output layout.
+    #if ! JucePlugin_IsSynth
+        if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
+            return false;
+    #endif
+
+        return true;
+    #endif
+}
+#endif
+
+void CMLSProjectAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midiMessages)
+{
+    juce::ScopedNoDenormals noDenormals;
+
+    auto totalNumInputChannels = getTotalNumInputChannels();
+    auto totalNumOutputChannels = getTotalNumOutputChannels();
+
+    for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
+        buffer.clear(i, 0, buffer.getNumSamples());     // clear any output channels that don't have input data
+
+    const auto numChannels = juce::jmax(totalNumInputChannels, totalNumOutputChannels);
+    auto audioBlock = juce::dsp::AudioBlock<float>(buffer).getSubsetChannelBlock(0, (int)numChannels);
+    auto context = juce::dsp::ProcessContextReplacing<float>(audioBlock);
+
+    this->processorChain.process(context);
+}
+
+//==============================================================================
+bool CMLSProjectAudioProcessor::hasEditor() const 
+{ 
+    return true; 
+}
+
+juce::AudioProcessorEditor* CMLSProjectAudioProcessor::createEditor()
+{
+    return new CMLSProjectAudioProcessorEditor(*this);
+}
+
+//==============================================================================
+void CMLSProjectAudioProcessor::getStateInformation(juce::MemoryBlock& destData) 
+{
+}
+
+void CMLSProjectAudioProcessor::setStateInformation(const void* data, int sizeInBytes)
+{
+}
+
+//==============================================================================
+void CMLSProjectAudioProcessor::setEqLowGain(float value)
+{
+    auto& instance = this->processorChain.template get<0>();
+    instance.setEqLowGain(value);
+}
+
+void CMLSProjectAudioProcessor::setEqHighGain(float value)
+{
+    auto& instance = this->processorChain.template get<0>();
+    instance.setEqHighGain(value);
+}
+
+void CMLSProjectAudioProcessor::setDistortionDrive(float value)
+{
+    auto& instance = this->processorChain.template get<1>();
+    instance.setDrive(value);
+}
+
+void CMLSProjectAudioProcessor::setDistortionMix(float value)
+{
+    auto& instance = this->processorChain.template get<1>();
+    instance.setMix(value);
+}
+
+//==============================================================================
+// This creates new instances of the plugin.
+juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter()
+{
+    return new CMLSProjectAudioProcessor();
+}

+ 64 - 81
JUCE/CMLSProject/Source/PluginProcessor.h

@@ -1,81 +1,64 @@
-/*
-  ==============================================================================
-
-    This file contains the basic framework code for a JUCE plugin processor.
-
-  ==============================================================================
-*/
-
-#pragma once
-
-#include <JuceHeader.h>
-#include "CMLSReverb.h"
-#include "CMLSDelay.h"
-#include "CMLSChorus.h"
-
-//==============================================================================
-/**
-*/
-class CMLSProjectAudioProcessor  : public juce::AudioProcessor
-{
-public:
-    //==============================================================================
-    CMLSProjectAudioProcessor();
-    ~CMLSProjectAudioProcessor() override;
-
-    //==============================================================================
-    void prepareToPlay (double sampleRate, int samplesPerBlock) override;
-    void releaseResources() override;
-
-   #ifndef JucePlugin_PreferredChannelConfigurations
-    bool isBusesLayoutSupported (const BusesLayout& layouts) const override;
-   #endif
-
-    void processBlock (juce::AudioBuffer<float>&, juce::MidiBuffer&) override;
-
-    //==============================================================================
-    juce::AudioProcessorEditor* createEditor() override;
-    bool hasEditor() const override;
-
-    //==============================================================================
-    const juce::String getName() const override;
-
-    bool acceptsMidi() const override;
-    bool producesMidi() const override;
-    bool isMidiEffect() const override;
-    double getTailLengthSeconds() const override;
-
-    //==============================================================================
-    int getNumPrograms() override;
-    int getCurrentProgram() override;
-    void setCurrentProgram (int index) override;
-    const juce::String getProgramName (int index) override;
-    void changeProgramName (int index, const juce::String& newName) override;
-
-    //==============================================================================
-    void getStateInformation (juce::MemoryBlock& destData) override;
-    void setStateInformation (const void* data, int sizeInBytes) override;
-
-    // Parameter controls
-	void setChorusDryWet(float value);
-	void setChorusAmount(float value);
-
-	void setReverbDryWet(float value);
-	void setReverbRoomSize(float value);
-
-	void setDelayDryWet(float value);
-	void setDelayAmount(float value);
-
-private:
-    //==============================================================================
-    
-    // OSC message receiver
-	juce::OSCReceiver oscReceiver;
-
-    // Buffer for the incoming audio from the generators
-
-    // Effects processing chain
-	juce::dsp::ProcessorChain<CMLSChorus, CMLSReverb, CMLSDelay> processorChain;
-
-    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CMLSProjectAudioProcessor)
-};
+#pragma once
+
+#include <JuceHeader.h>
+#include "CMLSEqualizer.h"
+#include "CMLSDistortion.h"
+
+//==============================================================================
+class CMLSProjectAudioProcessor : public juce::AudioProcessor
+{
+public:
+    //==============================================================================
+    CMLSProjectAudioProcessor();
+    ~CMLSProjectAudioProcessor() override;
+
+    //==============================================================================
+    void prepareToPlay(double sampleRate, int samplesPerBlock) override;
+    void releaseResources() override;
+
+#ifndef JucePlugin_PreferredChannelConfigurations
+    bool isBusesLayoutSupported(const BusesLayout& layouts) const override;
+#endif
+
+    void processBlock(juce::AudioBuffer<float>&, juce::MidiBuffer&) override;
+
+    //==============================================================================
+    juce::AudioProcessorEditor* createEditor() override;
+    bool hasEditor() const override;
+
+    //==============================================================================
+    const juce::String getName() const override;
+
+    bool acceptsMidi() const override;
+    bool producesMidi() const override;
+    bool isMidiEffect() const override;
+    double getTailLengthSeconds() const override;
+
+    //==============================================================================
+    int getNumPrograms() override;
+    int getCurrentProgram() override;
+    void setCurrentProgram(int index) override;
+    const juce::String getProgramName(int index) override;
+    void changeProgramName(int index, const juce::String& newName) override;
+
+    //==============================================================================
+    void getStateInformation(juce::MemoryBlock& destData) override;
+    void setStateInformation(const void* data, int sizeInBytes) override;
+
+    //==============================================================================
+    // parameter control functions
+    void setEqLowGain(float value);
+    void setEqHighGain(float value);
+
+    void setDistortionDrive(float value);
+    void setDistortionMix(float value);
+
+private:
+    //==============================================================================
+        
+    juce::OSCReceiver oscReceiver; // OSC message receiver
+
+    juce::dsp::ProcessorChain<CMLSEqualizer, CMLSDistortion> processorChain;
+
+    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CMLSProjectAudioProcessor)
+};