diff --git a/src/dsp/SVF/SVFProcessor.cpp b/src/dsp/SVF/SVFProcessor.cpp index adb8361..126e87b 100644 --- a/src/dsp/SVF/SVFProcessor.cpp +++ b/src/dsp/SVF/SVFProcessor.cpp @@ -3,6 +3,12 @@ namespace dsp::svf { +SVFProcessor::SVFProcessor (const Params& svfParams, const ExtraState& extraState) + : params (svfParams), extraState (extraState) +{ + postSpectrumAnalyserTask.spectrumAnalyserUITask.setDBRange (-45, 24); +} + void SVFProcessor::prepare (const juce::dsp::ProcessSpec& spec) { chowdsp::TupleHelpers::forEachInTuple ([&spec] (auto& filter, size_t) @@ -27,7 +33,6 @@ void SVFProcessor::prepare (const juce::dsp::ProcessSpec& spec) std::fill (playingNotes.begin(), playingNotes.end(), -1); - preSpectrumAnalyserTask.prepareToPlay (spec.sampleRate, (int) spec.maximumBlockSize, (int) spec.numChannels); postSpectrumAnalyserTask.prepareToPlay (spec.sampleRate, (int) spec.maximumBlockSize, (int) spec.numChannels); } @@ -126,9 +131,6 @@ constexpr bool IsOneOfFilters = std::disjunction& buffer, const juce::MidiBuffer& midi) noexcept { - if (extraState.isEditorOpen.load() && extraState.showPreSpectrum.get()) - preSpectrumAnalyserTask.processBlockInput (buffer.toAudioBuffer()); - if (params.keytrack->get()) processKeytracking (midi); else @@ -151,7 +153,7 @@ void SVFProcessor::processBlock (const chowdsp::BufferView& buffer, const numSamplesRemaining -= samplesToProcess; } - if (extraState.isEditorOpen.load() && extraState.showPostSpectrum.get()) + if (extraState.isEditorOpen.load() && extraState.showSpectrum.get()) postSpectrumAnalyserTask.processBlockInput (buffer.toAudioBuffer()); } diff --git a/src/dsp/SVF/SVFProcessor.h b/src/dsp/SVF/SVFProcessor.h index 46f9baa..cf58255 100644 --- a/src/dsp/SVF/SVFProcessor.h +++ b/src/dsp/SVF/SVFProcessor.h @@ -175,18 +175,13 @@ struct Params : public chowdsp::ParamHolder struct ExtraState { std::atomic isEditorOpen { false }; - chowdsp::StateValue showPreSpectrum { "svf_show_pre_spectrum", true }; - chowdsp::StateValue showPostSpectrum { "svf_show_post_spectrum", true }; + chowdsp::StateValue showSpectrum { "svf_show_spectrum", true }; }; class SVFProcessor { public: - explicit SVFProcessor (const Params& svfParams, const ExtraState& extraState) : params (svfParams), extraState (extraState) - { - preSpectrumAnalyserTask.spectrumAnalyserUITask.setDBRange (-45, 24); - postSpectrumAnalyserTask.spectrumAnalyserUITask.setDBRange (-45, 24); - } + explicit SVFProcessor (const Params& svfParams, const ExtraState& extraState); void prepare (const juce::dsp::ProcessSpec& spec); void reset(); @@ -196,7 +191,7 @@ class SVFProcessor gui::SpectrumAnalyserTask::PrePostPair getSpectrumAnalyserTasks() { - return { std::ref (preSpectrumAnalyserTask.spectrumAnalyserUITask), std::ref (postSpectrumAnalyserTask.spectrumAnalyserUITask) }; + return { std::nullopt, std::ref (postSpectrumAnalyserTask.spectrumAnalyserUITask) }; } private: @@ -224,7 +219,6 @@ class SVFProcessor chowdsp::WernerFilter wernerFilter; chowdsp::Gain driveInGain, driveOutGain; - gui::SpectrumAnalyserTask preSpectrumAnalyserTask; gui::SpectrumAnalyserTask postSpectrumAnalyserTask; static constexpr size_t maxPolyphony = 32; diff --git a/src/gui/AnalogEQ/AnalogEQPlot.cpp b/src/gui/AnalogEQ/AnalogEQPlot.cpp index 3834dfa..444d80f 100644 --- a/src/gui/AnalogEQ/AnalogEQPlot.cpp +++ b/src/gui/AnalogEQ/AnalogEQPlot.cpp @@ -60,8 +60,14 @@ AnalogEQPlot::AnalogEQPlot (State& pluginState, chyron (pluginState, *pluginState.params.analogEQParams, hcp), spectrumAnalyser (*this, spectrumAnalyserTasks) { - addMouseListener (this, true); extraState.isEditorOpen.store (true); + spectrumAnalyser.preEQDrawOptions.drawFill = true; + spectrumAnalyser.preEQDrawOptions.drawLine = false; + spectrumAnalyser.preEQDrawOptions.gradientStartColour = juce::Colour { 0xff282828 }; + spectrumAnalyser.preEQDrawOptions.gradientEndColour = spectrumAnalyser.preEQDrawOptions.gradientStartColour; + spectrumAnalyser.postEQDrawOptions.drawFill = false; + spectrumAnalyser.postEQDrawOptions.drawLine = true; + spectrumAnalyser.postEQDrawOptions.lineColour = juce::Colour { 0xff6a6a6a }; spectrumAnalyser.setShouldShowPreEQ (extraState.showPreSpectrum.get()); spectrumAnalyser.setShouldShowPostEQ (extraState.showPostSpectrum.get()); callbacks += { @@ -114,6 +120,20 @@ AnalogEQPlot::AnalogEQPlot (State& pluginState, { setSelectedBand (BandID::High_Boost); }), }; + plotPainter.painter = [this] (juce::Graphics& g) + { + drawMagnitudeLabels (g, *this, { -20.0f, -15.0f, -10.0f, -5.0f, 0.0f, 5.0f, 10.0f, 15.0f, 20.0f }); + drawFrequencyLabels (g, *this, { 100.0f, 1000.0f, 10'000.0f }, 20.0f); + + gui::drawFrequencyLines (*this, g, { 100.0f, 1000.0f, 10'000.0f }, colours::majorLinesColour, colours::minorLinesColour); + gui::drawMagnitudeLines (*this, g, { -20.0f, -15.0f, -10.0f, -5.0f, 5.0f, 10.0f, 15.0f, 20.0f }, { 0.0f }, colours::majorLinesColour, colours::minorLinesColour); + + g.setColour (juce::Colours::red); + g.strokePath (filterPlotter.getPath(), juce::PathStrokeType { 1.5f }); + }; + plotPainter.setInterceptsMouseClicks (false, false); + addAndMakeVisible (plotPainter); + auto& lfControl = make_unique_component (lowFreqControl, *pultecParams.bassFreqParam, pluginState, @@ -231,7 +251,6 @@ AnalogEQPlot::AnalogEQPlot (State& pluginState, AnalogEQPlot::~AnalogEQPlot() { - removeMouseListener (this); extraState.isEditorOpen.store (false); } @@ -257,18 +276,6 @@ void AnalogEQPlot::setSelectedBand (BandID band) } } -void AnalogEQPlot::paint (juce::Graphics& g) -{ - drawMagnitudeLabels (g, *this, { -20.0f, -15.0f, -10.0f, -5.0f, 0.0f, 5.0f, 10.0f, 15.0f, 20.0f }); - drawFrequencyLabels (g, *this, { 100.0f, 1000.0f, 10'000.0f }, 20.0f); - - gui::drawFrequencyLines (*this, g, { 100.0f, 1000.0f, 10'000.0f }, colours::majorLinesColour, colours::minorLinesColour); - gui::drawMagnitudeLines (*this, g, { -20.0f, -15.0f, -10.0f, -5.0f, 5.0f, 10.0f, 15.0f, 20.0f }, { 0.0f }, colours::majorLinesColour, colours::minorLinesColour); - - g.setColour (juce::Colours::red); - g.strokePath (filterPlotter.getPath(), juce::PathStrokeType { 1.5f }); -} - void AnalogEQPlot::resized() { updatePlot(); @@ -287,6 +294,7 @@ void AnalogEQPlot::resized() chyronWidth, chyronHeight); spectrumAnalyser.setBounds (getLocalBounds()); + plotPainter.setBounds (getLocalBounds()); } void AnalogEQPlot::mouseDown (const juce::MouseEvent& event) diff --git a/src/gui/AnalogEQ/AnalogEQPlot.h b/src/gui/AnalogEQ/AnalogEQPlot.h index fdefd47..de7620a 100644 --- a/src/gui/AnalogEQ/AnalogEQPlot.h +++ b/src/gui/AnalogEQ/AnalogEQPlot.h @@ -19,7 +19,6 @@ class AnalogEQPlot : public chowdsp::SpectrumPlotBase SpectrumAnalyserTask::PrePostPair spectrumAnalyserTasks); ~AnalogEQPlot() override; - void paint (juce::Graphics& g) override; void resized() override; enum class BandID @@ -52,6 +51,12 @@ class AnalogEQPlot : public chowdsp::SpectrumPlotBase std::unique_ptr highBoostFullControl; std::unique_ptr highCutFullControl; + struct PlotPainter : juce::Component + { + std::function painter; + void paint (juce::Graphics& g) override { painter (g); } + } plotPainter; + EQChyron chyron; SpectrumAnalyser spectrumAnalyser; diff --git a/src/gui/BandSplitter/BandSplitterPlot.cpp b/src/gui/BandSplitter/BandSplitterPlot.cpp index 4e9bed2..1115c13 100644 --- a/src/gui/BandSplitter/BandSplitterPlot.cpp +++ b/src/gui/BandSplitter/BandSplitterPlot.cpp @@ -101,7 +101,6 @@ BandSplitterPlot::BandSplitterPlot (State& pluginState, spectrumTasks (splitterSpectrumTasks), chyron (pluginState, bandSplitParams, hcp) { - addMouseListener (this, true); extraState.isEditorOpen.store (true); addAndMakeVisible (cutoffSlider); @@ -184,7 +183,6 @@ BandSplitterPlot::BandSplitterPlot (State& pluginState, BandSplitterPlot::~BandSplitterPlot() { - removeMouseListener (this); extraState.isEditorOpen.store (false); } diff --git a/src/gui/Brickwall/BrickwallEditor.h b/src/gui/Brickwall/BrickwallEditor.h index 2a1cfa7..e8870d5 100644 --- a/src/gui/Brickwall/BrickwallEditor.h +++ b/src/gui/Brickwall/BrickwallEditor.h @@ -14,7 +14,7 @@ class BrickwallEditor : public juce::Component const chowdsp::HostContextProvider& hcp, std::pair spectrumAnalyserTasks); - ~BrickwallEditor(); + ~BrickwallEditor() override; void paint (juce::Graphics& g) override; void resized() override; diff --git a/src/gui/Brickwall/BrickwallPlot.cpp b/src/gui/Brickwall/BrickwallPlot.cpp index 420125a..a9b5048 100644 --- a/src/gui/Brickwall/BrickwallPlot.cpp +++ b/src/gui/Brickwall/BrickwallPlot.cpp @@ -106,7 +106,8 @@ BrickwallPlot::BrickwallPlot (State& pluginState, .minFrequencyHz = (float) minFrequency, .maxFrequencyHz = (float) maxFrequency, .minMagnitudeDB = -60.0f, - .maxMagnitudeDB = 6.0f }), + .maxMagnitudeDB = 6.0f, + }), filterPlotter (*this, chowdsp::GenericFilterPlotter::Params { .sampleRate = sampleRate, .fftOrder = fftOrder, @@ -117,16 +118,18 @@ BrickwallPlot::BrickwallPlot (State& pluginState, chyron (pluginState, brickwallParams, hcp), cutoffSlider (*brickwallParams.cutoff, *this, pluginState, hcp) { - addMouseListener (this, true); extraState.isEditorOpen.store (true); spectrumAnalyser.setShouldShowPostEQ (extraState.showSpectrum.get()); + spectrumAnalyser.postEQDrawOptions.gradientStartColour = juce::Colour { 0xff008080 }.withAlpha (0.5f); + spectrumAnalyser.postEQDrawOptions.gradientEndColour = juce::Colour { 0xff00008b }.withAlpha (0.5f); callbacks += { - extraState.showSpectrum.changeBroadcaster.connect ([this] - { - spectrumAnalyser.setShouldShowPostEQ(extraState.showSpectrum.get()); - spectrumAnalyser.repaint(); }), + extraState.showSpectrum.changeBroadcaster.connect ( + [this] + { + spectrumAnalyser.setShouldShowPostEQ (extraState.showSpectrum.get()); + spectrumAnalyser.repaint(); + }), }; - addAndMakeVisible (spectrumAnalyser); brickwall.prepare ({ sampleRate, (uint32_t) blockSize, 1 }); @@ -160,7 +163,6 @@ BrickwallPlot::BrickwallPlot (State& pluginState, BrickwallPlot::~BrickwallPlot() { - removeMouseListener (this); extraState.isEditorOpen.store (false); } diff --git a/src/gui/Brickwall/BrickwallPlot.h b/src/gui/Brickwall/BrickwallPlot.h index e2318c8..08a2f24 100644 --- a/src/gui/Brickwall/BrickwallPlot.h +++ b/src/gui/Brickwall/BrickwallPlot.h @@ -16,7 +16,7 @@ class BrickwallPlot : public chowdsp::SpectrumPlotBase const chowdsp::HostContextProvider& hcp, std::pair spectrumAnalyserTasks); - ~BrickwallPlot(); + ~BrickwallPlot() override; void paint (juce::Graphics& g) override; void resized() override; void mouseDown (const juce::MouseEvent& event) override; diff --git a/src/gui/EQ/EQEditor.cpp b/src/gui/EQ/EQEditor.cpp index 836eeb4..3f37df6 100644 --- a/src/gui/EQ/EQEditor.cpp +++ b/src/gui/EQ/EQEditor.cpp @@ -21,8 +21,14 @@ EQEditor::EQEditor (State& pluginState, drawCheckButton ("Vector/square-check-regular.svg", colours::linesColour, colours::linesColour), drawXButton ("Vector/rectangle-xmark-regular.svg", colours::linesColour, colours::linesColour) { - addMouseListener (this, true); extraState.isEditorOpen.store (true); + spectrumAnalyser.preEQDrawOptions.drawFill = true; + spectrumAnalyser.preEQDrawOptions.drawLine = false; + spectrumAnalyser.preEQDrawOptions.gradientStartColour = juce::Colour { 0xff282828 }; + spectrumAnalyser.preEQDrawOptions.gradientEndColour = spectrumAnalyser.preEQDrawOptions.gradientStartColour; + spectrumAnalyser.postEQDrawOptions.drawFill = false; + spectrumAnalyser.postEQDrawOptions.drawLine = true; + spectrumAnalyser.postEQDrawOptions.lineColour = juce::Colour { 0xff6a6a6a }; spectrumAnalyser.setShouldShowPreEQ (extraState.showPreSpectrum.get()); spectrumAnalyser.setShouldShowPostEQ (extraState.showPostSpectrum.get()); callbacks += { @@ -77,7 +83,6 @@ EQEditor::EQEditor (State& pluginState, EQEditor::~EQEditor() { - removeMouseListener (this); extraState.isEditorOpen.store (false); } diff --git a/src/gui/SVF/SVFPlot.cpp b/src/gui/SVF/SVFPlot.cpp index 9889707..ddba97b 100644 --- a/src/gui/SVF/SVFPlot.cpp +++ b/src/gui/SVF/SVFPlot.cpp @@ -52,19 +52,17 @@ SVFPlot::SVFPlot (State& pluginState, spectrumAnalyser (*this, spectrumAnalyserTasks), chyron (pluginState, svfParams, hcp) { - addMouseListener (this, true); extraState.isEditorOpen.store (true); - spectrumAnalyser.setShouldShowPreEQ (extraState.showPreSpectrum.get()); - spectrumAnalyser.setShouldShowPostEQ (extraState.showPostSpectrum.get()); + spectrumAnalyser.setShouldShowPostEQ (extraState.showSpectrum.get()); + spectrumAnalyser.postEQDrawOptions.gradientStartColour = juce::Colour { 0xff008080 }.withAlpha (0.5f); + spectrumAnalyser.postEQDrawOptions.gradientEndColour = juce::Colour { 0xff00008b }.withAlpha (0.5f); callbacks += { - extraState.showPreSpectrum.changeBroadcaster.connect ([this] - { - spectrumAnalyser.setShouldShowPreEQ(extraState.showPreSpectrum.get()); - spectrumAnalyser.repaint(); }), - extraState.showPostSpectrum.changeBroadcaster.connect ([this] - { - spectrumAnalyser.setShouldShowPostEQ(extraState.showPostSpectrum.get()); - spectrumAnalyser.repaint(); }), + extraState.showSpectrum.changeBroadcaster.connect ( + [this] + { + spectrumAnalyser.setShouldShowPostEQ (extraState.showSpectrum.get()); + spectrumAnalyser.repaint(); + }), }; freqSlider.setColour (juce::Slider::thumbColourId, colours::boxColour); @@ -192,21 +190,12 @@ void SVFPlot::mouseDown (const juce::MouseEvent& event) chowdsp::SharedLNFAllocator lnfAllocator; juce::PopupMenu menu; - juce::PopupMenu::Item preSpectrumItem; - preSpectrumItem.itemID = 100; - preSpectrumItem.text = extraState.showPreSpectrum.get() ? "Disable Pre-Filter Visualizer" : "Enable Pre-Filter Visualizer"; - preSpectrumItem.action = [this] - { - extraState.showPreSpectrum.set (! extraState.showPreSpectrum.get()); - }; - menu.addItem (preSpectrumItem); - juce::PopupMenu::Item postSpectrumItem; postSpectrumItem.itemID = 101; - postSpectrumItem.text = extraState.showPostSpectrum.get() ? "Disable Post-Filter Visualizer" : "Enable Post-Filter Visualizer"; + postSpectrumItem.text = extraState.showSpectrum.get() ? "Disable Spectrum Visualizer" : "Enable Spectrum Visualizer"; postSpectrumItem.action = [this] { - extraState.showPostSpectrum.set (! extraState.showPostSpectrum.get()); + extraState.showSpectrum.set (! extraState.showSpectrum.get()); }; menu.addItem (postSpectrumItem); diff --git a/src/gui/Shared/SpectrumAnalyser.cpp b/src/gui/Shared/SpectrumAnalyser.cpp index 1dda2e7..e741538 100644 --- a/src/gui/Shared/SpectrumAnalyser.cpp +++ b/src/gui/Shared/SpectrumAnalyser.cpp @@ -9,6 +9,8 @@ SpectrumAnalyser::SpectrumAnalyser (const chowdsp::SpectrumPlotBase& eqPlot, { minFrequencyHz.store (eqPlot.params.minFrequencyHz); maxFrequencyHz.store (eqPlot.params.maxFrequencyHz); + + setInterceptsMouseClicks (false, false); } SpectrumAnalyser::~SpectrumAnalyser() @@ -40,7 +42,7 @@ void SpectrumAnalyser::paint (juce::Graphics& g) if (drawOptions.drawLine) { g.setColour (drawOptions.lineColour); - g.strokePath (path, juce::PathStrokeType (1)); + g.strokePath (path, juce::PathStrokeType { 1.1f }); } }; diff --git a/src/state/PluginState.cpp b/src/state/PluginState.cpp index 542460a..bb03849 100644 --- a/src/state/PluginState.cpp +++ b/src/state/PluginState.cpp @@ -61,8 +61,7 @@ PluginExtraState::PluginExtraState() &eqExtraState->showPreSpectrum, &eqExtraState->showPostSpectrum, &brickwallExtraState->showSpectrum, - &svfExtraState->showPreSpectrum, - &svfExtraState->showPostSpectrum, + &svfExtraState->showSpectrum, &bandSplitterExtraState->showSpectrum, &editorBounds }); }