-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding JSON test * Adding test for ParametersView * Add WaveformView test * Add test for Level Detector Visualizer * Add gain computer plot test * Trying to fix vizualizer tests * Running viz test comparisons not just on Mac * Apply clang-format * Fixing typos * Apply clang-format * Updating ForwardingParameter for ignoring code coverage * Add tests for CLAP preset discovery * Apply clang-format * Fixing warnings, etc * More designated initializer fixes --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
ee4722f
commit ef7a646
Showing
28 changed files
with
611 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#include <CatchUtils.h> | ||
#include <chowdsp_gui/chowdsp_gui.h> | ||
#include <chowdsp_plugin_base/chowdsp_plugin_base.h> | ||
|
||
namespace params_view_test | ||
{ | ||
struct LevelParams : chowdsp::ParamHolder | ||
{ | ||
explicit LevelParams (const juce::String& paramPrefix = "", int version = 100) | ||
: prefix (paramPrefix), | ||
versionHint (version) | ||
{ | ||
add (percent, gain); | ||
} | ||
|
||
const juce::String prefix; | ||
const int versionHint; | ||
|
||
chowdsp::PercentParameter::Ptr percent { juce::ParameterID { prefix + "percent", versionHint }, "Percent" }; | ||
chowdsp::GainDBParameter::Ptr gain { juce::ParameterID { prefix + "gain", versionHint }, "Gain", juce::NormalisableRange { -30.0f, 0.0f }, 0.0f }; | ||
}; | ||
|
||
struct PluginParameterState : chowdsp::ParamHolder | ||
{ | ||
PluginParameterState() | ||
{ | ||
add (levelParams, mode, onOff); | ||
} | ||
|
||
LevelParams levelParams; | ||
chowdsp::ChoiceParameter::Ptr mode { "mode", "Mode", juce::StringArray { "Percent", "Gain", "Percent / Gain", "Gain / Percent" }, 2 }; | ||
chowdsp::BoolParameter::Ptr onOff { "on_off", "On/Off", true }; | ||
}; | ||
|
||
using State = chowdsp::PluginStateImpl<PluginParameterState>; | ||
|
||
struct Plugin : chowdsp::PluginBase<State> | ||
{ | ||
const juce::String getName() const override { return "Plugin"; } | ||
void releaseResources() override {} | ||
void processAudioBlock (juce::AudioBuffer<float>& buffer) override { buffer.clear(); } | ||
juce::AudioProcessorEditor* createEditor() override { return new chowdsp::ParametersViewEditor { *this }; } | ||
}; | ||
} // namespace params_view_test | ||
|
||
TEST_CASE ("Parameters View Test", "[gui][state]") | ||
{ | ||
params_view_test::Plugin plugin; | ||
|
||
auto* editor = dynamic_cast<chowdsp::ParametersViewEditor*> (plugin.createEditor()); | ||
REQUIRE (editor != nullptr); | ||
auto _ = chowdsp::runAtEndOfScope ( | ||
[&plugin, editor] | ||
{ | ||
plugin.editorBeingDeleted (editor); | ||
delete editor; | ||
}); | ||
|
||
editor->setSize (600, 600); | ||
|
||
auto& params = plugin.getState().params; | ||
REQUIRE (editor->view.getComponentForParameter (params.onOff) != nullptr); | ||
REQUIRE (editor->view.getComponentForParameter (params.mode) != nullptr); | ||
REQUIRE (editor->view.getComponentForParameter (params.levelParams.gain) != nullptr); | ||
REQUIRE (editor->view.getComponentForParameter (params.levelParams.percent) != nullptr); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
tests/gui_tests/chowdsp_visualizers_test/GainComputerPlotTest.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include "VizTestUtils.h" | ||
|
||
#include <chowdsp_compressor/chowdsp_compressor.h> | ||
#include <chowdsp_visualizers/chowdsp_visualizers.h> | ||
|
||
TEST_CASE ("Gain Computer Plot Test", "[visualizers][compressor]") | ||
{ | ||
static constexpr int width = 500; | ||
static constexpr int height = 500; | ||
static constexpr int plotNumSamples = 128; | ||
|
||
chowdsp::compressor::GainComputerPlot plot; | ||
plot.setSize (width, height); | ||
plot.setThreshold (-12.0f); | ||
|
||
chowdsp::compressor::GainComputer<float, chowdsp::compressor::FeedForwardCompGainComputer<float>> gainComputer; | ||
|
||
gainComputer.prepare (48000.0, plotNumSamples); | ||
gainComputer.setThreshold (-12.0f); | ||
gainComputer.setRatio (4.0f); | ||
gainComputer.setKnee (18.0f); | ||
gainComputer.reset(); | ||
|
||
chowdsp::StaticBuffer<float, 1, plotNumSamples> inputBuffer { 1, plotNumSamples }; | ||
chowdsp::StaticBuffer<float, 1, plotNumSamples> outputBuffer { 1, plotNumSamples }; | ||
|
||
for (auto [n, sample] : chowdsp::enumerate (inputBuffer.getWriteSpan (0))) | ||
sample = juce::Decibels::decibelsToGain (juce::jmap ((float) n, | ||
0.0f, | ||
(float) inputBuffer.getNumSamples(), | ||
plot.params.xMin, | ||
plot.params.xMax)); | ||
|
||
gainComputer.processBlock (inputBuffer, outputBuffer); | ||
plot.updatePlotPath (inputBuffer.getReadSpan (0), outputBuffer.getReadSpan (0)); | ||
|
||
const auto testScreenshot = plot.createComponentSnapshot ({ width, height }); | ||
// VizTestUtils::saveImage (testScreenshot, "gain_computer_plot.png"); | ||
|
||
const auto refScreenshot = VizTestUtils::loadImage ("gain_computer_plot.png"); | ||
VizTestUtils::compareImages (testScreenshot, refScreenshot); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+6.4 KB
tests/gui_tests/chowdsp_visualizers_test/Images/gain_computer_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+103 Bytes
(100%)
tests/gui_tests/chowdsp_visualizers_test/Images/waveshaper_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions
35
tests/gui_tests/chowdsp_visualizers_test/LevelDetectorTest.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "VizTestUtils.h" | ||
#include <chowdsp_visualizers/chowdsp_visualizers.h> | ||
|
||
TEST_CASE ("Level Detector Test", "[visualizers][compressor]") | ||
{ | ||
static constexpr int width = 500; | ||
static constexpr int height = 300; | ||
static constexpr int block_size = 512; | ||
|
||
chowdsp::compressor::LevelDetectorVisualizer visualizer; | ||
visualizer.setBufferSize (100); | ||
visualizer.setSamplesPerBlock (block_size); | ||
|
||
float phase = 0.0f; | ||
for (int i = 0; i < 100; ++i) | ||
{ | ||
std::array<float, block_size> buffer {}; | ||
for (auto& x : buffer) | ||
{ | ||
x = 0.5f * std::sin (phase); | ||
phase += 0.08f; | ||
} | ||
visualizer.pushChannel (0, nonstd::span<const float> { buffer }); | ||
|
||
buffer.fill (0.5f); | ||
visualizer.pushChannel (1, nonstd::span<const float> { buffer }); | ||
} | ||
|
||
visualizer.setSize (width, height); | ||
const auto testScreenshot = visualizer.createComponentSnapshot ({ width, height }); | ||
// VizTestUtils::saveImage (testScreenshot, "level_detector.png"); | ||
|
||
const auto refScreenshot = VizTestUtils::loadImage ("level_detector.png"); | ||
VizTestUtils::compareImages (testScreenshot, refScreenshot); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.