Hi I’m really new to coding but I am trying to create an overdrive plugin with an input and output gain slider control but whenever I build it, the input and output sliders are stuck at either end and nothing changes with the audio. Any help or suggestions to where I may be going wrong would be really appreciated and apologies for any stupid mistakes.
The input/output sliders where declared in the editor .cpp here:
//Input Slider Porperties
addAndMakeVisible(InputSlider);
InputSlider.setRange(1, 10.0);
InputSlider.setValue(1.0);
InputSlider.setTextValueSuffix(" dB");
InputSlider.addListener (this);
//makes slider logorythmic
InputSlider.setSkewFactorFromMidPoint(50);
//Input Slider Label
addAndMakeVisible(InputLabel);
InputLabel.setText ("Input", juce::dontSendNotification);
InputLabel.attachToComponent(&InputSlider, true);
//Output Slider Porperties
addAndMakeVisible(OutputSlider);
OutputSlider.setRange(1, 100.0);
OutputSlider.setTextValueSuffix(" dB");
OutputSlider.addListener (this);
//Makes slider logarithmic
OutputSlider.setSkewFactorFromMidPoint(50);
//Output Slider Label
addAndMakeVisible(OutputLabel);
OutputLabel.setText ("Output", juce::dontSendNotification);
OutputLabel.attachToComponent(&OutputSlider, true);
In the editor header file here:
public:
OverdriveAudioProcessorEditor (OverdriveAudioProcessor&);
~OverdriveAudioProcessorEditor();
void paint (Graphics&) override;
void resized() override
{
auto sliderLeft = 120;
InputSlider.setBounds (sliderLeft, 100 , getWidth() - sliderLeft - 10, 20);
OutputSlider.setBounds (sliderLeft, 150, getWidth() - sliderLeft - 10, 20);
}
void sliderValueChanged (Slider *slider) override;
void timerCallback() override;
private:
OverdriveAudioProcessor& processor;
Slider threshSlider;
juce::Slider InputSlider;
juce::Label InputLabel;
juce::Slider OutputSlider;
juce::Label OutputLabel;
In the processor header:
// declare slider parameter objects below
AudioParameterFloat *threshParam;
AudioParameterFloat *InputParam;
AudioParameterFloat *OutputParam;
And in the processor .cpp:
// apply processsing to each channel…
for (int channel = 0; channel < totalNumInputChannels; ++channel)
{
float* channelData = buffer.getWritePointer (channel);
for(int sampleNum=0; sampleNum<buffer.getNumSamples(); sampleNum++)
{
channelData[sampleNum] = channelData[sampleNum]*input;
if(channelData[sampleNum] > *threshParam)
channelData[sampleNum] = *threshParam;
else if (channelData[sampleNum] < -*threshParam)
channelData[sampleNum] = -*threshParam;
channelData[sampleNum] = channelData[sampleNum]*output;
}