Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating colours for most visualizers #36

Merged
merged 3 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/dsp/SVF/SVFProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
}

Expand Down Expand Up @@ -126,9 +131,6 @@ constexpr bool IsOneOfFilters = std::disjunction<std::is_same<FilterType, TestFi

void SVFProcessor::processBlock (const chowdsp::BufferView<float>& buffer, const juce::MidiBuffer& midi) noexcept
{
if (extraState.isEditorOpen.load() && extraState.showPreSpectrum.get())
preSpectrumAnalyserTask.processBlockInput (buffer.toAudioBuffer());

if (params.keytrack->get())
processKeytracking (midi);
else
Expand All @@ -151,7 +153,7 @@ void SVFProcessor::processBlock (const chowdsp::BufferView<float>& buffer, const
numSamplesRemaining -= samplesToProcess;
}

if (extraState.isEditorOpen.load() && extraState.showPostSpectrum.get())
if (extraState.isEditorOpen.load() && extraState.showSpectrum.get())
postSpectrumAnalyserTask.processBlockInput (buffer.toAudioBuffer());
}

Expand Down
12 changes: 3 additions & 9 deletions src/dsp/SVF/SVFProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,18 +175,13 @@ struct Params : public chowdsp::ParamHolder
struct ExtraState
{
std::atomic<bool> isEditorOpen { false };
chowdsp::StateValue<std::atomic_bool, bool> showPreSpectrum { "svf_show_pre_spectrum", true };
chowdsp::StateValue<std::atomic_bool, bool> showPostSpectrum { "svf_show_post_spectrum", true };
chowdsp::StateValue<std::atomic_bool, bool> 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();
Expand All @@ -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:
Expand Down Expand Up @@ -224,7 +219,6 @@ class SVFProcessor
chowdsp::WernerFilter wernerFilter;

chowdsp::Gain<float> driveInGain, driveOutGain;
gui::SpectrumAnalyserTask preSpectrumAnalyserTask;
gui::SpectrumAnalyserTask postSpectrumAnalyserTask;

static constexpr size_t maxPolyphony = 32;
Expand Down
36 changes: 22 additions & 14 deletions src/gui/AnalogEQ/AnalogEQPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 += {
Expand Down Expand Up @@ -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<minFrequency, maxFrequency> (*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<SelectableDotSlider> (lowFreqControl,
*pultecParams.bassFreqParam,
pluginState,
Expand Down Expand Up @@ -231,7 +251,6 @@ AnalogEQPlot::AnalogEQPlot (State& pluginState,

AnalogEQPlot::~AnalogEQPlot()
{
removeMouseListener (this);
extraState.isEditorOpen.store (false);
}

Expand All @@ -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<minFrequency, maxFrequency> (*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();
Expand All @@ -287,6 +294,7 @@ void AnalogEQPlot::resized()
chyronWidth,
chyronHeight);
spectrumAnalyser.setBounds (getLocalBounds());
plotPainter.setBounds (getLocalBounds());
}

void AnalogEQPlot::mouseDown (const juce::MouseEvent& event)
Expand Down
7 changes: 6 additions & 1 deletion src/gui/AnalogEQ/AnalogEQPlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -52,6 +51,12 @@ class AnalogEQPlot : public chowdsp::SpectrumPlotBase
std::unique_ptr<juce::Component> highBoostFullControl;
std::unique_ptr<juce::Component> highCutFullControl;

struct PlotPainter : juce::Component
{
std::function<void (juce::Graphics&)> painter;
void paint (juce::Graphics& g) override { painter (g); }
} plotPainter;

EQChyron chyron;
SpectrumAnalyser spectrumAnalyser;

Expand Down
2 changes: 0 additions & 2 deletions src/gui/BandSplitter/BandSplitterPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ BandSplitterPlot::BandSplitterPlot (State& pluginState,
spectrumTasks (splitterSpectrumTasks),
chyron (pluginState, bandSplitParams, hcp)
{
addMouseListener (this, true);
extraState.isEditorOpen.store (true);

addAndMakeVisible (cutoffSlider);
Expand Down Expand Up @@ -184,7 +183,6 @@ BandSplitterPlot::BandSplitterPlot (State& pluginState,

BandSplitterPlot::~BandSplitterPlot()
{
removeMouseListener (this);
extraState.isEditorOpen.store (false);
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/Brickwall/BrickwallEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class BrickwallEditor : public juce::Component
const chowdsp::HostContextProvider& hcp,
std::pair<gui::SpectrumAnalyserTask::OptionalBackgroundTask, gui::SpectrumAnalyserTask::OptionalBackgroundTask> spectrumAnalyserTasks);

~BrickwallEditor();
~BrickwallEditor() override;

void paint (juce::Graphics& g) override;
void resized() override;
Expand Down
18 changes: 10 additions & 8 deletions src/gui/Brickwall/BrickwallPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 });
Expand Down Expand Up @@ -160,7 +163,6 @@ BrickwallPlot::BrickwallPlot (State& pluginState,

BrickwallPlot::~BrickwallPlot()
{
removeMouseListener (this);
extraState.isEditorOpen.store (false);
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/Brickwall/BrickwallPlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class BrickwallPlot : public chowdsp::SpectrumPlotBase
const chowdsp::HostContextProvider& hcp,
std::pair<gui::SpectrumAnalyserTask::OptionalBackgroundTask, gui::SpectrumAnalyserTask::OptionalBackgroundTask> spectrumAnalyserTasks);

~BrickwallPlot();
~BrickwallPlot() override;
void paint (juce::Graphics& g) override;
void resized() override;
void mouseDown (const juce::MouseEvent& event) override;
Expand Down
9 changes: 7 additions & 2 deletions src/gui/EQ/EQEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 += {
Expand Down Expand Up @@ -77,7 +83,6 @@ EQEditor::EQEditor (State& pluginState,

EQEditor::~EQEditor()
{
removeMouseListener (this);
extraState.isEditorOpen.store (false);
}

Expand Down
33 changes: 11 additions & 22 deletions src/gui/SVF/SVFPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down
4 changes: 3 additions & 1 deletion src/gui/Shared/SpectrumAnalyser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 });
}
};

Expand Down
3 changes: 1 addition & 2 deletions src/state/PluginState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ PluginExtraState::PluginExtraState()
&eqExtraState->showPreSpectrum,
&eqExtraState->showPostSpectrum,
&brickwallExtraState->showSpectrum,
&svfExtraState->showPreSpectrum,
&svfExtraState->showPostSpectrum,
&svfExtraState->showSpectrum,
&bandSplitterExtraState->showSpectrum,
&editorBounds });
}
Expand Down