|
@@ -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();
|
|
|
|
|
+}
|