Sliders snapping to max value bug

This commit is contained in:
Sam Perry
2017-02-25 10:44:16 +00:00
parent 6ec793158a
commit 467f5571c2
5 changed files with 53 additions and 99 deletions
+1 -3
View File
@@ -12,6 +12,7 @@
companyName="SPPlugins" companyEmail="samuel.perry89@gmail.com">
<MAINGROUP id="hyzDI2" name="Assignment1">
<GROUP id="{2A8AB319-B99F-7EC5-7146-4693F6286790}" name="Source">
<FILE id="clPhDV" name="GenericEditor.h" compile="0" resource="0" file="Source/GenericEditor.h"/>
<FILE id="GClbDm" name="Compressor.cpp" compile="1" resource="0" file="Source/Compressor.cpp"/>
<FILE id="KVeY9K" name="Compressor.h" compile="0" resource="0" file="Source/Compressor.h"/>
<FILE id="LmIR2O" name="CrossoverFilter.cpp" compile="1" resource="0"
@@ -22,9 +23,6 @@
file="Source/PluginProcessor.cpp"/>
<FILE id="vzF4H3" name="PluginProcessor.h" compile="0" resource="0"
file="Source/PluginProcessor.h"/>
<FILE id="I9JFHV" name="PluginEditor.cpp" compile="1" resource="0"
file="Source/PluginEditor.cpp"/>
<FILE id="QdvJwy" name="PluginEditor.h" compile="0" resource="0" file="Source/PluginEditor.h"/>
</GROUP>
</MAINGROUP>
<EXPORTFORMATS>
-6
View File
@@ -108,12 +108,6 @@ void CrossoverFilter::makeCrossover(
denominator = convolveCoefficients(denominator, denominator);
}
*/
/* setCoefficients() takes arguments: b0, b1, b2, a0, a1, a2
* It will normalise the filter according to the value of a0
* to allow standard time-domain implementations
*/
}
void CrossoverFilter::applyFilter(float* const samples, const int numSamples) noexcept {
+12 -11
View File
@@ -72,7 +72,7 @@ Assignment1ProcessorEditor::Assignment1ProcessorEditor (Assignment1Processor* ow
addAndMakeVisible (&sliderThreshold);
sliderThreshold.setRange (-60, 0, -60);
sliderThreshold.setSliderStyle (Slider::RotaryVerticalDrag);
sliderThreshold.setTextBoxStyle (Slider::TextBoxBelow, false, 80, 20);
//sliderThreshold.setTextBoxStyle (Slider::TextBoxBelow, false, 80, 20);
sliderThreshold.addListener (this);
addAndMakeVisible (&label2);
@@ -85,7 +85,7 @@ Assignment1ProcessorEditor::Assignment1ProcessorEditor (Assignment1Processor* ow
addAndMakeVisible (&sliderRatio);
sliderRatio.setRange (1, 100, 0.1);
sliderRatio.setSliderStyle (Slider::RotaryVerticalDrag);
sliderRatio.setTextBoxStyle (Slider::TextBoxBelow, false, 80, 20);
//sliderRatio.setTextBoxStyle (Slider::TextBoxBelow, false, 80, 20);
sliderRatio.addListener (this);
addAndMakeVisible (&label3);
@@ -98,7 +98,7 @@ Assignment1ProcessorEditor::Assignment1ProcessorEditor (Assignment1Processor* ow
addAndMakeVisible (&sliderGain);
sliderGain.setRange (0, 40, 1);
sliderGain.setSliderStyle (Slider::RotaryVerticalDrag);
sliderGain.setTextBoxStyle (Slider::TextBoxBelow, false, 80, 20);
//sliderGain.setTextBoxStyle (Slider::TextBoxBelow, false, 80, 20);
sliderGain.addListener (this);
addAndMakeVisible (&label7);
@@ -111,7 +111,7 @@ Assignment1ProcessorEditor::Assignment1ProcessorEditor (Assignment1Processor* ow
addAndMakeVisible (&sliderAttack);
sliderAttack.setRange (0.1, 80, 0.1);
sliderAttack.setSliderStyle (Slider::RotaryVerticalDrag);
sliderAttack.setTextBoxStyle (Slider::TextBoxBelow, false, 80, 20);
//sliderAttack.setTextBoxStyle (Slider::TextBoxBelow, false, 80, 20);
sliderAttack.addListener (this);
addAndMakeVisible (&label5);
@@ -124,7 +124,7 @@ Assignment1ProcessorEditor::Assignment1ProcessorEditor (Assignment1Processor* ow
addAndMakeVisible (&sliderRelease);
sliderRelease.setRange (0.1, 1000, 0.1);
sliderRelease.setSliderStyle (Slider::RotaryVerticalDrag);
sliderRelease.setTextBoxStyle (Slider::TextBoxBelow, false, 80, 20);
//sliderRelease.setTextBoxStyle (Slider::TextBoxBelow, false, 80, 20);
sliderRelease.addListener (this);
addAndMakeVisible (&label6);
@@ -201,23 +201,24 @@ void Assignment1ProcessorEditor::resized()
gainDecibelsSlider_.setBounds(380, 20, 150, 40);
bandwidthLabel_.setBounds(20, 70, 350, 20);
resizer_->setBounds(550, 100, 1000, 1000);
getProcessor()->lastUIWidth_ = getWidth();
getProcessor()->lastUIHeight_ = getHeight();
buttonONOFF.setBounds (17, 55, 125, 25);
label.setBounds (-3, 0, 500, 49);
sliderThreshold.setBounds (533, 182, 175, 98);
sliderThreshold.setBounds (580, 20, 150, 40);
label2.setBounds (588, 152, 91, 24);
sliderRatio.setBounds (5, 182, 175, 98);
sliderRatio.setBounds (780, 20, 150, 40);
label3.setBounds (132, 152, 50, 24);
sliderGain.setBounds (595, 77, 56, 70);
sliderGain.setBounds (595, 77, 150, 40);
label7.setBounds (604, 52, 52, 24);
sliderAttack.setBounds (196, 182, 175, 98);
sliderAttack.setBounds (196, 182, 150, 40);
label5.setBounds (229, 152, 120, 24);
sliderRelease.setBounds (365, 182, 175, 98);
sliderRelease.setBounds (365, 182, 150, 40);
label6.setBounds (391, 152, 120, 24);
resizer_->setBounds(550, 100, 1000, 1000);
}
//==============================================================================
+28 -79
View File
@@ -28,23 +28,40 @@
*/
#include "PluginProcessor.h"
#include "PluginEditor.h"
#include <memory>
#include <string>
//==============================================================================
Assignment1Processor::Assignment1Processor()
{
// Set default values:
centreFrequency_ = 1000.0;
q_ = 2.0;
gainDecibels_ = 0.0;
numXOverPerChannel = 3;
numCompPerChannel = 4;
// Initialise the filters later when we know how many channels
numCrossoverFilters_ = 0;
crossoverFreq.resize(numXOverPerChannel);
compressorThresh.resize(numCompPerChannel);
compressorRatio.resize(numCompPerChannel);
compressorActive.resize(numCompPerChannel);
lastUIWidth_ = 550;
lastUIHeight_ = 100;
for(int i = 0; i < numXOverPerChannel; i++) {
std::string s1 = "crossover" + std::to_string(i+1) + "Freq";
std::string s2 = "Crossover " + std::to_string(i+1) + " Frequency";
addParameter (crossoverFreq[i] = new AudioParameterFloat (s1, s2, NormalisableRange<float>(20.0f, 20000.0f, 0.0f, 0.0f), 1000.0f));
}
for(int i = 0; i < numCompPerChannel; i++) {
std::string s1 = "comp" + std::to_string(i+1) + "thresh";
std::string s2 = "Compressor " + std::to_string(i+1) + " Threshold";
addParameter (compressorThresh[i] = new AudioParameterFloat (s1, s2, 0.0f, 1.0f, 0.5f));
s1 = "comp" + std::to_string(i+1) + "ratio";
s2 = "Compressor " + std::to_string(i+1) + " Ratio";
addParameter (compressorRatio[i] = new AudioParameterFloat (s1, s2, 0.0f, 1.0f, 0.5f));
s1 = "comp" + std::to_string(i+1) + "active";
s2 = "Compressor " + std::to_string(i+1) + " Active";
addParameter (compressorActive[i] = new AudioParameterBool (s1, s2, false));
}
}
Assignment1Processor::~Assignment1Processor()
@@ -57,72 +74,6 @@ const String Assignment1Processor::getName() const
return JucePlugin_Name;
}
int Assignment1Processor::getNumParameters()
{
return kNumParameters;
}
float Assignment1Processor::getParameter (int index)
{
// This method will be called by the host, probably on the audio thread, so
// it's absolutely time-critical. Don't use critical sections or anything
// UI-related, or anything at all that may block in any way!
switch (index)
{
case kCentreFrequencyParam: return centreFrequency_;
case kQParam: return q_;
case kGainDecibelsParam: return gainDecibels_;
case kCompressorONOFF: return compressorONOFF;
default: return 0.0f;
}
}
void Assignment1Processor::setParameter (int index, float newValue)
{
// This method will be called by the host, probably on the audio thread, so
// it's absolutely time-critical. Don't use critical sections or anything
// UI-related, or anything at all that may block in any way!
switch (index)
{
case kCentreFrequencyParam:
centreFrequency_ = newValue;
updateFilter(getSampleRate());
break;
case kQParam:
q_ = newValue;
updateFilter(getSampleRate());
break;
case kGainDecibelsParam:
gainDecibels_ = newValue;
updateFilter(getSampleRate());
break;
case kCompressorONOFF:
compressorONOFF = newValue;
updateCompressor(getSampleRate());
default:
break;
}
}
const String Assignment1Processor::getParameterName (int index)
{
switch (index)
{
case kCentreFrequencyParam: return "centre frequency";
case kQParam: return "Q";
case kGainDecibelsParam: return "gain (dB)";
case kCompressorONOFF: return "compressorONOFF";
default: break;
}
return String::empty;
}
const String Assignment1Processor::getParameterText (int index)
{
return String (getParameter (index), 2);
}
const String Assignment1Processor::getInputChannelName (int channelIndex) const
{
return String (channelIndex + 1);
@@ -283,10 +234,8 @@ bool Assignment1Processor::hasEditor() const
return true; // (change this to false if you choose to not supply an editor)
}
AudioProcessorEditor* Assignment1Processor::createEditor()
{
return new Assignment1ProcessorEditor (this);
}
AudioProcessorEditor* Assignment1Processor::createEditor() { return new GenericEditor (*this); }
//==============================================================================
void Assignment1Processor::getStateInformation (MemoryBlock& destData)
+12
View File
@@ -34,7 +34,9 @@
#include "../JuceLibraryCode/JuceHeader.h"
#include "CrossoverFilter.h"
#include "Compressor.h"
#include "GenericEditor.h"
#include <vector>
#include <array>
//==============================================================================
/**
@@ -59,6 +61,7 @@ public:
//==============================================================================
const String getName() const;
/*
int getNumParameters();
float getParameter (int index);
@@ -66,6 +69,7 @@ public:
const String getParameterName (int index);
const String getParameterText (int index);
*/
const String getInputChannelName (int channelIndex) const;
const String getOutputChannelName (int channelIndex) const;
@@ -112,6 +116,14 @@ private:
std::vector<std::unique_ptr<CrossoverFilter>> crossoverFilters_;
std::vector<std::unique_ptr<Compressor>> compressors_;
int numCompPerChannel;
int numXOverPerChannel;
std::vector<AudioParameterFloat*> crossoverFreq;
std::vector<AudioParameterFloat*> compressorThresh;
std::vector<AudioParameterFloat*> compressorRatio;
std::vector<AudioParameterBool*> compressorActive;
int numCrossoverFilters_;
int numCompressors_;
bool linkwitzRiley_ = true;