commit 55dc2210ffcdb19507cda711b6f801cb8493d245
parent f4014f9b6cadd047c497859f927b398666292192
Author: Keith <smartguitarml@gmail.com>
Date: Tue, 30 Aug 2022 18:20:24 -0500
Updated EQ and cleaned comments
Diffstat:
5 files changed, 41 insertions(+), 98 deletions(-)
diff --git a/src/Eq4Band.cpp b/src/Eq4Band.cpp
@@ -13,27 +13,29 @@ Eq4Band::Eq4Band()
setParameters(0.0, 0.0, 0.0, 0.0);
}
-void Eq4Band::process (AudioBuffer<float>& buffer,
+void Eq4Band::process (const float* inData, float* outData,
MidiBuffer& midiMessages,
const int numSamples,
- const int numInputChannels)
+ const int numInputChannels,
+ const int sampleRate)
{
- for (int channel = 0; channel < numInputChannels; ++channel) {
- float* channelData = buffer.getWritePointer(channel);
- // For each sample in the block of audio, apply filter
- for (int sample = 0; sample < numSamples; ++sample) {
- spl0 = channelData[sample];
- s0 = spl0;
- low0 = (tmplMID = a0MID * s0 - b1MID * tmplMID + cDenorm);
- spl0 = (tmplLOW = a0LOW * low0 - b1LOW * tmplLOW + cDenorm);
- lowS0 = low0 - spl0;
- hi0 = s0 - low0;
- midS0 = (tmplHI = a0HI * hi0 - b1HI * tmplHI + cDenorm);
- highS0 = hi0 - midS0;
- spl0 = (spl0 * lVol + lowS0 * lmVol + midS0 * hmVol + highS0 * hVol);// * outVol;
+ // Reset params if new sampleRate detected
+ if (srate != sampleRate) {
+ srate = sampleRate;
+ resetSampleRate();
+ }
+ for (int sample = 0; sample < numSamples; ++sample) {
+ spl0 = inData[sample];
+ s0 = spl0;
+ low0 = (tmplMID = a0MID * s0 - b1MID * tmplMID + cDenorm);
+ spl0 = (tmplLOW = a0LOW * low0 - b1LOW * tmplLOW + cDenorm);
+ lowS0 = low0 - spl0;
+ hi0 = s0 - low0;
+ midS0 = (tmplHI = a0HI * hi0 - b1HI * tmplHI + cDenorm);
+ highS0 = hi0 - midS0;
+ spl0 = (spl0 * lVol + lowS0 * lmVol + midS0 * hmVol + highS0 * hVol);// * outVol;
- channelData[sample] = spl0;
- }
+ outData[sample] = spl0;
}
}
@@ -56,4 +58,19 @@ void Eq4Band::setParameters(float bass_slider, float mid_slider, float treble_sl
xLOW = exp(-2.0 * pi * bass_frequency / srate);
a0LOW = 1.0 - xLOW;
b1LOW = -xLOW;
+}
+
+void Eq4Band::resetSampleRate()
+{
+ xHI = exp(-2.0 * pi * treble_frequency / srate);
+ a0HI = 1.0 - xHI;
+ b1HI = -xHI;
+
+ xMID = exp(-2.0 * pi * mid_frequency / srate);
+ a0MID = 1.0 - xMID;
+ b1MID = -xMID;
+
+ xLOW = exp(-2.0 * pi * bass_frequency / srate);
+ a0LOW = 1.0 - xLOW;
+ b1LOW = -xLOW;
}
\ No newline at end of file
diff --git a/src/Eq4Band.h b/src/Eq4Band.h
@@ -17,8 +17,9 @@ class Eq4Band
{
public:
Eq4Band();
- void process (AudioBuffer<float>& buffer, MidiBuffer& midiMessages, const int numSamples, const int numInputChannels);
+ void process (const float* inData, float* outData, MidiBuffer& midiMessages, const int numSamples, const int numInputChannels, const int sampleRate);
void setParameters(float bass_slider, float mid_slider, float treble_slider, float presence_slider);
+ void resetSampleRate();
private:
// Tone Knob related variables
@@ -30,7 +31,7 @@ private:
int treble_frequency = 5000;
//int presence_frequency = 5500;
- int srate = 44100; //TODO set from input
+ int srate = 44100; // Set default
float pi = 3.1415926;
diff --git a/src/PluginEditor.cpp b/src/PluginEditor.cpp
@@ -29,15 +29,6 @@ WaveNetVaAudioProcessorEditor::WaveNetVaAudioProcessorEditor (WaveNetVaAudioProc
addAndMakeVisible(ampOnButton);
ampOnButton.addListener(this);
- //addAndMakeVisible(loadButton);
- //loadButton.setButtonText("Load Tone");
- //loadButton.addListener(this);
-
- //addAndMakeVisible(modelLabel);
- //modelLabel.setText(processor.loaded_tone_name, juce::NotificationType::dontSendNotification);
- //modelLabel.setJustificationType(juce::Justification::left);
- //modelLabel.setColour(juce::Label::textColourId, juce::Colours::black);
-
ampCleanLeadButton.setImages(true, true, true,
ImageCache::getFromMemory(BinaryData::power_switch_up_png, BinaryData::power_switch_up_pngSize), 1.0, Colours::transparentWhite,
Image(), 1.0, Colours::transparentWhite,
@@ -57,122 +48,86 @@ WaveNetVaAudioProcessorEditor::WaveNetVaAudioProcessorEditor (WaveNetVaAudioProc
addAndMakeVisible(ampPresenceKnob);
ampPresenceKnob.setLookAndFeel(&SilverKnobLAF);
ampPresenceKnob.addListener(this);
- //ampPresenceKnob.setSkewFactorFromMidPoint(1000.0); // Not working because of custom lookAndFeel class
- //ampPresenceKnob.setRange(-10.0, 10.0);
- //ampPresenceKnob.setValue(processor.ampPresenceKnobState);
ampPresenceKnob.setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag);
ampPresenceKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, false, 75, 20);
- //ampPresenceKnob.setNumDecimalPlacesToDisplay(1);
ampPresenceKnob.setDoubleClickReturnValue(true, 0.0);
cleanBassSliderAttach = std::make_unique<AudioProcessorValueTreeState::SliderAttachment>(processor.treeState, CLEAN_BASS_ID, ampCleanBassKnob);
addAndMakeVisible(ampCleanBassKnob);
ampCleanBassKnob.setLookAndFeel(&SilverKnobLAF);
ampCleanBassKnob.addListener(this);
- //ampCleanBassKnob.setRange(-8.0, 8.0);
- //ampCleanBassKnob.setValue(processor.ampCleanBassKnobState);
ampCleanBassKnob.setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag);
ampCleanBassKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, false, 50, 20);
- //ampCleanBassKnob.setNumDecimalPlacesToDisplay(1);
ampCleanBassKnob.setDoubleClickReturnValue(true, 0.0);
cleanMidSliderAttach = std::make_unique<AudioProcessorValueTreeState::SliderAttachment>(processor.treeState, CLEAN_MID_ID, ampCleanMidKnob);
addAndMakeVisible(ampCleanMidKnob);
ampCleanMidKnob.setLookAndFeel(&SilverKnobLAF);
ampCleanMidKnob.addListener(this);
- //ampCleanMidKnob.setRange(-8.0, 8.0);
- //ampCleanMidKnob.setValue(processor.ampCleanMidKnobState);
ampCleanMidKnob.setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag);
ampCleanMidKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, false, 50, 20);
- //ampCleanMidKnob.setNumDecimalPlacesToDisplay(1);
ampCleanMidKnob.setDoubleClickReturnValue(true, 0.0);
cleanTrebleSliderAttach = std::make_unique<AudioProcessorValueTreeState::SliderAttachment>(processor.treeState, CLEAN_TREBLE_ID, ampCleanTrebleKnob);
addAndMakeVisible(ampCleanTrebleKnob);
ampCleanTrebleKnob.setLookAndFeel(&SilverKnobLAF);
ampCleanTrebleKnob.addListener(this);
- //ampCleanTrebleKnob.setRange(-8.0, 8.0);
- //ampCleanTrebleKnob.setValue(processor.ampCleanTrebleKnobState);
ampCleanTrebleKnob.setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag);
ampCleanTrebleKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, false, 50, 20);
- //ampCleanTrebleKnob.setNumDecimalPlacesToDisplay(1);
ampCleanTrebleKnob.setDoubleClickReturnValue(true, 0.0);
cleanGainSliderAttach = std::make_unique<AudioProcessorValueTreeState::SliderAttachment>(processor.treeState, CLEAN_GAIN_ID, ampCleanGainKnob);
addAndMakeVisible(ampCleanGainKnob);
ampCleanGainKnob.setLookAndFeel(&SilverKnobLAF);
ampCleanGainKnob.addListener(this);
- //ampCleanGainKnob.setRange(0.0, 20.0);
- //ampCleanGainKnob.setValue(processor.ampCleanGainKnobState);
ampCleanGainKnob.setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag);
ampCleanGainKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, false, 50, 20);
- //ampCleanGainKnob.setNumDecimalPlacesToDisplay(1);
ampCleanGainKnob.setDoubleClickReturnValue(true, 0.5);
leadBassSliderAttach = std::make_unique<AudioProcessorValueTreeState::SliderAttachment>(processor.treeState, LEAD_BASS_ID, ampLeadBassKnob);
addAndMakeVisible(ampLeadBassKnob);
ampLeadBassKnob.setLookAndFeel(&SilverKnobLAF);
ampLeadBassKnob.addListener(this);
- //ampLeadBassKnob.setRange(-8.0, 8.0);
- //ampLeadBassKnob.setValue(processor.ampLeadBassKnobState);
ampLeadBassKnob.setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag);
ampLeadBassKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, false, 50, 20);
- //ampLeadBassKnob.setNumDecimalPlacesToDisplay(1);
ampLeadBassKnob.setDoubleClickReturnValue(true, 0.0);
leadMidSliderAttach = std::make_unique<AudioProcessorValueTreeState::SliderAttachment>(processor.treeState, LEAD_MID_ID, ampLeadMidKnob);
addAndMakeVisible(ampLeadMidKnob);
ampLeadMidKnob.setLookAndFeel(&SilverKnobLAF);
ampLeadMidKnob.addListener(this);
- //ampLeadMidKnob.setRange(-8.0, 8.0);
- //ampLeadMidKnob.setValue(processor.ampLeadMidKnobState);
ampLeadMidKnob.setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag);
- ampLeadMidKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, false, 50, 20);
- //ampLeadMidKnob.setNumDecimalPlacesToDisplay(1);
+ ampLeadMidKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, false, 50, 20);;
ampLeadMidKnob.setDoubleClickReturnValue(true, 0.0);
leadTrebleSliderAttach = std::make_unique<AudioProcessorValueTreeState::SliderAttachment>(processor.treeState, LEAD_TREBLE_ID, ampLeadTrebleKnob);
addAndMakeVisible(ampLeadTrebleKnob);
ampLeadTrebleKnob.setLookAndFeel(&SilverKnobLAF);
ampLeadTrebleKnob.addListener(this);
- //ampLeadTrebleKnob.setRange(-8.0, 8.0);
- //ampLeadTrebleKnob.setValue(processor.ampLeadTrebleKnobState);
ampLeadTrebleKnob.setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag);
ampLeadTrebleKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, false, 50, 20);
- //ampLeadTrebleKnob.setNumDecimalPlacesToDisplay(1);
ampLeadTrebleKnob.setDoubleClickReturnValue(true, 0.0);
leadGainSliderAttach = std::make_unique<AudioProcessorValueTreeState::SliderAttachment>(processor.treeState, LEAD_GAIN_ID, ampLeadGainKnob);
addAndMakeVisible(ampLeadGainKnob);
ampLeadGainKnob.setLookAndFeel(&SilverKnobLAF);
ampLeadGainKnob.addListener(this);
- //ampLeadGainKnob.setRange(0.0, 20.0);
- //ampLeadGainKnob.setValue(processor.ampLeadGainKnobState);
ampLeadGainKnob.setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag);
ampLeadGainKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, false, 50, 20);
- //ampLeadGainKnob.setNumDecimalPlacesToDisplay(1);
ampLeadGainKnob.setDoubleClickReturnValue(true, 0.5);
masterSliderAttach = std::make_unique<AudioProcessorValueTreeState::SliderAttachment>(processor.treeState, MASTER_ID, ampMasterKnob);
addAndMakeVisible(ampMasterKnob);
ampMasterKnob.setLookAndFeel(&SilverKnobLAF);
ampMasterKnob.addListener(this);
- //ampMasterKnob.setRange(-24.0, 0.0);
- //ampMasterKnob.setValue(processor.ampMasterKnobState);
ampMasterKnob.setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag);
ampMasterKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, false, 50, 20 );
- //ampMasterKnob.setNumDecimalPlacesToDisplay(1);
ampMasterKnob.setDoubleClickReturnValue(true, 0.5);
// Size of plugin GUI
setSize (1085, 540);
- // Load the preset wavenet json model from the project resources
- //if (processor.custom_tone == 0) {
processor.loadConfigAmp();
- //} else {
- // processor.loadConfig(processor.loaded_tone);
- //}
resetImages();
}
@@ -228,8 +183,6 @@ void WaveNetVaAudioProcessorEditor::resized()
ampLED.setBounds(975, 40, 15, 25);
}
-
-
void WaveNetVaAudioProcessorEditor::buttonClicked(juce::Button* button)
{
if (button == &OnButton) {
@@ -239,7 +192,6 @@ void WaveNetVaAudioProcessorEditor::buttonClicked(juce::Button* button)
}
}
-
void WaveNetVaAudioProcessorEditor::ampOnButtonClicked() {
if (processor.amp_state == 0) {
processor.amp_state = 1;
@@ -250,7 +202,6 @@ void WaveNetVaAudioProcessorEditor::ampOnButtonClicked() {
resetImages();
}
-
void WaveNetVaAudioProcessorEditor::ampCleanLeadButtonClicked() {
if (processor.amp_lead == 1) {
processor.amp_lead = 0;
@@ -273,14 +224,10 @@ void WaveNetVaAudioProcessorEditor::sliderValueChanged(Slider* slider)
if (slider == &CleanBassKnob || slider == &CleanMidKnob || slider == &CleanTrebleKnob) {
if (processor.amp_lead == 0)
processor.set_ampEQ(ampCleanBassKnob.getValue(), ampCleanMidKnob.getValue(), ampCleanTrebleKnob.getValue(), ampPresenceKnob.getValue());
- // Set knob states for saving positions when closing/reopening GUI
-
}
else if (slider == &LeadBassKnob || slider == &LeadMidKnob || slider == &LeadTrebleKnob) {
if (processor.amp_lead == 1)
- processor.set_ampEQ(ampLeadBassKnob.getValue(), ampLeadMidKnob.getValue(), ampLeadTrebleKnob.getValue(), ampPresenceKnob.getValue());
- // Set knob states for saving positions when closing/reopening GUI
-
+ processor.set_ampEQ(ampLeadBassKnob.getValue(), ampLeadMidKnob.getValue(), ampLeadTrebleKnob.getValue(), ampPresenceKnob.getValue());
}
else if (slider == &PresenceKnob) {
if (processor.amp_lead == 0)
diff --git a/src/PluginProcessor.cpp b/src/PluginProcessor.cpp
@@ -180,16 +180,10 @@ void WaveNetVaAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuff
// Setup Audio Data
const int numSamples = buffer.getNumSamples();
const int numInputChannels = getTotalNumInputChannels();
+ const int sampleRate = getSampleRate();
auto cleanGainValue = static_cast<float> (cleanGainParam->load());
- auto cleanBassValue = static_cast<float> (cleanBassParam->load());
- auto cleanMidValue = static_cast<float> (cleanMidParam->load());
- auto cleanTrebleValue = static_cast<float> (cleanTrebleParam->load());
-
auto leadGainValue = static_cast<float> (leadGainParam->load());
- auto leadBassValue = static_cast<float> (leadBassParam->load());
- auto leadMidValue = static_cast<float> (leadMidParam->load());
- auto leadTrebleValue = static_cast<float> (leadTrebleParam->load());
auto presenceValue = static_cast<float> (presenceParam->load());
auto masterValue = static_cast<float> (masterParam->load());
@@ -207,7 +201,7 @@ void WaveNetVaAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuff
// Wavenet, load json for waveNet2 based on lead/clean switch
waveNet.process(buffer.getArrayOfReadPointers(), buffer.getArrayOfWritePointers(), buffer.getNumSamples());
- eq4band.process(buffer, midiMessages, numSamples, numInputChannels);
+ eq4band.process(buffer.getReadPointer(0), buffer.getWritePointer(0), midiMessages, numSamples, numInputChannels, sampleRate);
// Master Volume
buffer.applyGain(masterValue);
diff --git a/src/PluginProcessor.h b/src/PluginProcessor.h
@@ -84,18 +84,8 @@ public:
void setStateInformation (const void* data, int sizeInBytes) override;
void loadConfigAmp();
- //void loadConfig(File configFile);
-
- // Overdrive Pedal
- //float convertLogScale(float in_value, float x_min, float x_max, float y_min, float y_max);
-
- // Amp
- //void set_ampCleanDrive(float db_ampCleanDrive);
- //void set_ampLeadDrive(float db_ampLeadDrive);
- //void set_ampMaster(float db_ampMaster);
void set_ampEQ(float bass_slider, float mid_slider, float treble_slider, float presence_slider);
- //float decibelToLinear(float dbValue);
// Pedal/amp states
int amp_state = 1; // 0 = off, 1 = on
@@ -125,12 +115,6 @@ private:
float previousGainValue = 0.5;
float previousMasterValue = 0.5;
-
- // Amp
- //float ampCleanDrive = 1.0;
- //float ampLeadDrive = 1.0;
- //float ampMaster = 1.0;
-
var dummyVar;
//==============================================================================