Skip to content

Commit

Permalink
Merge branch 'spectrum_analyser' of https://github.com/Chowdhury-DSP/…
Browse files Browse the repository at this point in the history
…ChowMultiTool into spectrum_analyser
  • Loading branch information
RachelMaryamLocke committed Nov 24, 2023
2 parents d9f9659 + ec61217 commit c9f27ea
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ target_sources(ChowMultiTool PRIVATE

gui/Brickwall/BrickwallEditor.cpp
gui/Brickwall/BrickwallPlot.cpp
gui/Brickwall/BrickwallChyron.cpp
gui/Brickwall/BottomBar.cpp

gui/AnalogEQ/AnalogEQEditor.cpp
Expand Down
1 change: 0 additions & 1 deletion src/dsp/EQ/EQProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ void EQProcessor::processBlock (const chowdsp::BufferView<float>& buffer)
preSpectrumAnalyserTask->processBlockInput (preEqAudioBuffer);
}


const auto&& eqParams = getEQParams();
EQToolParams::EQParams::setEQParameters (eq, eqParams);
linPhaseEQ.setParameters (eqParams);
Expand Down
32 changes: 32 additions & 0 deletions src/gui/Brickwall/BrickwallChyron.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "BrickwallChyron.h"
#include "gui/Shared/Colours.h"

namespace gui::brickwall
{
BrickwallChyron::BrickwallChyron (chowdsp::PluginState& pluginState,
dsp::brickwall::Params& params,
const chowdsp::HostContextProvider& hcp)
: state (pluginState),
cutoffSlider (state, params.cutoff.get(), &hcp)
{
cutoffSlider.setName ("Cutoff");
addAndMakeVisible (cutoffSlider);
}

void BrickwallChyron::resized()
{
auto bounds = getLocalBounds();
cutoffSlider.setBounds (bounds.reduced (proportionOfHeight (0.2f)));
}

void BrickwallChyron::paint (juce::Graphics& g)
{
const auto bounds = getLocalBounds();

g.setColour (juce::Colours::black.withAlpha (0.75f));
g.fillRoundedRectangle (bounds.toFloat(), 2.5f);

g.setColour (colours::linesColour);
g.drawRoundedRectangle (bounds.toFloat(), 2.5f, 1.0f);
}
} // namespace gui::brickwall
28 changes: 28 additions & 0 deletions src/gui/Brickwall/BrickwallChyron.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once

#include "dsp/Brickwall/BrickwallProcessor.h"
#include "gui/Shared/Fonts.h"
#include "gui/Shared/TextSlider.h"

namespace gui::brickwall
{
class BrickwallChyron : public juce::Component
{
public:
BrickwallChyron (chowdsp::PluginState& pluginState,
dsp::brickwall::Params& params,
const chowdsp::HostContextProvider& hcp);

void resized() override;
void paint (juce::Graphics& g) override;

private:
chowdsp::PluginState& state;

TextSlider cutoffSlider;

SharedFonts fonts;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BrickwallChyron)
};
} // namespace gui::brickwall
12 changes: 11 additions & 1 deletion src/gui/Brickwall/BrickwallPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ BrickwallPlot::BrickwallPlot (State& pluginState, dsp::brickwall::Params& brickw
.fftOrder = fftOrder,
}),
brickwall (brickwallParams),
cutoffSlider (*brickwallParams.cutoff, *this, pluginState, hcp)
cutoffSlider (*brickwallParams.cutoff, *this, pluginState, hcp),
chyron (pluginState, brickwallParams, hcp)
{
addAndMakeVisible (cutoffSlider);
addAndMakeVisible (chyron);

brickwall.prepare ({ sampleRate, (uint32_t) blockSize, 1 });
filterPlotter.runFilterCallback = [this] (const float* input, float* output, int numSamples)
Expand Down Expand Up @@ -162,5 +164,13 @@ void BrickwallPlot::resized()
{
updatePlot();
cutoffSlider.setBounds (getLocalBounds());

const auto pad = proportionOfWidth (0.005f);
const auto chyronWidth = proportionOfWidth (0.15f);
const auto chyronHeight = proportionOfWidth (0.05f);
chyron.setBounds (getWidth() - pad - chyronWidth,
getHeight() - pad - proportionOfHeight (0.075f) - chyronHeight,
chyronWidth,
chyronHeight);
}
} // namespace gui::brickwall
3 changes: 3 additions & 0 deletions src/gui/Brickwall/BrickwallPlot.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "BrickwallChyron.h"
#include "dsp/Brickwall/BrickwallProcessor.h"
#include "state/PluginState.h"

Expand Down Expand Up @@ -41,6 +42,8 @@ class BrickwallPlot : public chowdsp::SpectrumPlotBase
const chowdsp::HostContextProvider& hostContextProvider;
} cutoffSlider;

BrickwallChyron chyron;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BrickwallPlot)
};
} // namespace gui::brickwall
4 changes: 2 additions & 2 deletions src/gui/EQ/EQEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ EQEditor::EQEditor (State& pluginState, dsp::eq::EQToolParams& eqParams, const c
drawCheckButton ("Vector/square-check-regular.svg", colours::linesColour, colours::linesColour),
drawXButton ("Vector/rectangle-xmark-regular.svg", colours::linesColour, colours::linesColour)
{
params.isOpen.store(true);
params.isOpen.store (true);

bottomBar = std::make_unique<BottomBar> (pluginState, eqParams);

Expand Down Expand Up @@ -57,7 +57,7 @@ EQEditor::EQEditor (State& pluginState, dsp::eq::EQToolParams& eqParams, const c

EQEditor::~EQEditor()
{
params.isOpen.store(false);
params.isOpen.store (false);
}

void EQEditor::paint (juce::Graphics& g)
Expand Down
2 changes: 1 addition & 1 deletion src/gui/Shared/SpectrumAnalyser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void SpectrumAnalyser::paint (juce::Graphics& g)
g.strokePath(prePath, juce::PathStrokeType(1));
g.setGradientFill (juce::ColourGradient::vertical (gui::logo::colours::backgroundBlue.withAlpha(0.4f),
eqPlot.getYCoordinateForDecibels (0.0f),
gui::logo::colours::backgroundBlue.darker().withAlpha(0.4f),
gui::logo::colours::backgroundBlue.darker().withAlpha (0.4f),
(float) getHeight()));
g.fillPath (postPath);
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/Shared/SpectrumAnalyserTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void SpectrumAnalyserTask::SpectrumAnalyserBackgroundTask::runTask (const juce::
freqSmooth (fftMagsUnsmoothedDB.data(), fftMagsSmoothedDB.data(), fftOutSize, 1.0f / 128.0f);
expSmooth (magsPrevious.data(), fftMagsSmoothedDB.data(), fftOutSize, 0.2f);
}
}
} // namespace gui
// notes for Rachel:
// - dynamic range trick is cool!
// - tweaked some things re: painting, frequency band smoothing, smoothing across time, and threading stuff
Expand Down
2 changes: 1 addition & 1 deletion src/gui/Shared/SpectrumAnalyserTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ class SpectrumAnalyserTask
private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SpectrumAnalyserTask)
};
}
} // namespace gui

0 comments on commit c9f27ea

Please sign in to comment.