diff --git a/Augs Synth.jucer b/Augs Synth.jucer index 536a6b6..59926c1 100644 --- a/Augs Synth.jucer +++ b/Augs Synth.jucer @@ -4,6 +4,10 @@ pluginVST3Category="Instrument,Synth" pluginCharacteristicsValue="pluginIsSynth,pluginProducesMidiOut,pluginWantsMidiIn"> + + diff --git a/Source/Defs.h b/Source/Defs.h index f268435..7d13610 100644 --- a/Source/Defs.h +++ b/Source/Defs.h @@ -1,5 +1,5 @@ #pragma once - +#include #define NUM_VOICES 1 diff --git a/Source/ParameterInterpolator.cpp b/Source/ParameterInterpolator.cpp new file mode 100644 index 0000000..51318ae --- /dev/null +++ b/Source/ParameterInterpolator.cpp @@ -0,0 +1,32 @@ +/* + ============================================================================== + + ParameterInterpolator.cpp + Created: 25 Jun 2020 6:07:10pm + Author: August + + ============================================================================== +*/ + +#include "ParameterInterpolator.h" + +void ParameterInterpolator::StartNewBuffer(AudioProcessorValueTreeState& State, int& BuffSize) +{ + for (int i = 0; i < NUM_FLOAT_PARAMS; i++) + { + OldFloatParams[i] = GoalFloatParams[i]; + } + + for (int i = 0; i < NUM_FLOAT_PARAMS; i++) + { + GoalFloatParams[i] = State.getParameterAsValue(FloatParamProps[i].ID).getValue(); + } + + BufferSize = BuffSize; +} + +float ParameterInterpolator::GetFloat(const int& i, const int& SampleIdx) +{ + float Multiplyer = (float)SampleIdx / (float)BufferSize; + return OldFloatParams[i] + Multiplyer*(GoalFloatParams[i] - OldFloatParams[i]); +} \ No newline at end of file diff --git a/Source/ParameterInterpolator.h b/Source/ParameterInterpolator.h new file mode 100644 index 0000000..d603327 --- /dev/null +++ b/Source/ParameterInterpolator.h @@ -0,0 +1,30 @@ +/* + ============================================================================== + + ParameterInterpolator.h + Created: 25 Jun 2020 6:07:10pm + Author: August + + ============================================================================== +*/ + +#pragma once +#include "Defs.h" +#include "JuceHeader.h" + +class ParameterInterpolator +{ +public: + ParameterInterpolator() {} + ~ParameterInterpolator() {} + + void StartNewBuffer(AudioProcessorValueTreeState& State, int& BuffSize); + float GetFloat(const int& i, const int& SampleIdx); + + +private: + int BufferSize = 0; + float OldFloatParams[NUM_FLOAT_PARAMS]; + float GoalFloatParams[NUM_FLOAT_PARAMS]; + +}; \ No newline at end of file diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 98ac75a..c8595ab 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -23,7 +23,7 @@ AugsSynthAudioProcessor::AugsSynthAudioProcessor() #endif .withOutput ("Output", AudioChannelSet::stereo(), true) #endif - ), mParamTree(*this, nullptr, "PARAMS", createParameterLayout()) + ), mParamTree(*this, nullptr, "PARAMS", createParameterLayout()), mIterpolator() #endif { for (auto i = 0; i < NUM_VOICES; ++i) // Define voices @@ -157,7 +157,10 @@ bool AugsSynthAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts void AugsSynthAudioProcessor::processBlock(AudioSampleBuffer& buffer, MidiBuffer& midiMessages) { buffer.clear(); + int Num_Samples = buffer.getNumSamples(); + mKeyState.processNextMidiBuffer(midiMessages, 0, buffer.getNumSamples(), true); + mIterpolator.StartNewBuffer(mParamTree, Num_Samples); double Attack = mParamTree.getParameterAsValue(FloatParamProps[0].ID).getValue(); double Decay = mParamTree.getParameterAsValue(FloatParamProps[1].ID).getValue(); @@ -182,18 +185,25 @@ void AugsSynthAudioProcessor::processBlock(AudioSampleBuffer& buffer, MidiBuffer mSynth.renderNextBlock(buffer, midiMessages, 0, buffer.getNumSamples()); float PowDist = (float)mParamTree.getParameterAsValue(FloatParamProps[6].ID).getValue(); - float TrimDist = 1-(float)mParamTree.getParameterAsValue(FloatParamProps[7].ID).getValue(); - double Volume = mParamTree.getParameterAsValue(FloatParamProps[4].ID).getValue(); + + + - for (int sample = 0; sample < buffer.getNumSamples(); sample++) + for (int sample = 0; sample < Num_Samples; sample++) { for (int channel = 0; channel < buffer.getNumChannels(); channel++) { float MySample = buffer.getSample(channel, sample); - + + //Distortion + float PowDist = mIterpolator.GetFloat(6, sample); + float TrimDist = 1 - mIterpolator.GetFloat(7, sample); ApplyDistort(MySample, PowDist, TrimDist); + //Volume + float Volume = mIterpolator.GetFloat(4, sample); MySample *= Volume; + buffer.setSample(channel, sample, MySample); } } diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index f17d7fb..3504088 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -11,6 +11,7 @@ #pragma once #include +#include "ParameterInterpolator.h" //============================================================================== /** @@ -64,10 +65,11 @@ class AugsSynthAudioProcessor : public AudioProcessor AudioProcessorValueTreeState::ParameterLayout createParameterLayout(); + Synthesiser mSynth; MidiKeyboardState mKeyState; - + ParameterInterpolator mIterpolator; //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AugsSynthAudioProcessor)