Add visualiser settings panel

pull/249/head
James H Ball 2024-08-10 20:26:56 +01:00 zatwierdzone przez James H Ball
rodzic 776578caa3
commit 87edfe0608
11 zmienionych plików z 143 dodań i 8 usunięć

Wyświetl plik

@ -204,6 +204,18 @@
} }
}); });
window.__JUCE__.backend.addEventListener("intensityChanged", intensity => {
controls.exposureStops = intensity;
});
window.__JUCE__.backend.addEventListener("persistenceChanged", persistence => {
controls.persistence = persistence;
});
window.__JUCE__.backend.addEventListener("hueChanged", hue => {
controls.hue = hue;
});
document.addEventListener("dblclick", function() { document.addEventListener("dblclick", function() {
toggleFullscreen(); toggleFullscreen();
}); });

Wyświetl plik

@ -157,6 +157,9 @@ OscirenderAudioProcessor::OscirenderAudioProcessor()
allEffects = toggleableEffects; allEffects = toggleableEffects;
allEffects.insert(allEffects.end(), permanentEffects.begin(), permanentEffects.end()); allEffects.insert(allEffects.end(), permanentEffects.begin(), permanentEffects.end());
allEffects.insert(allEffects.end(), luaEffects.begin(), luaEffects.end()); allEffects.insert(allEffects.end(), luaEffects.begin(), luaEffects.end());
allEffects.push_back(intensityEffect);
allEffects.push_back(persistenceEffect);
allEffects.push_back(hueEffect);
for (auto effect : allEffects) { for (auto effect : allEffects) {
for (auto effectParameter : effect->parameters) { for (auto effectParameter : effect->parameters) {

Wyświetl plik

@ -122,9 +122,7 @@ public:
); );
std::shared_ptr<Effect> traceMax = std::make_shared<Effect>( std::shared_ptr<Effect> traceMax = std::make_shared<Effect>(
[this](int index, Point input, const std::vector<double>& values, double sampleRate) { new EffectParameter(
return input;
}, new EffectParameter(
"Trace max", "Trace max",
"Defines the maximum proportion of the image that is drawn before skipping to the next frame. This has the effect of 'tracing' out the image from a single dot when animated. By default, we draw until the end of the frame, so this value is 1.0.", "Defines the maximum proportion of the image that is drawn before skipping to the next frame. This has the effect of 'tracing' out the image from a single dot when animated. By default, we draw until the end of the frame, so this value is 1.0.",
"traceMax", "traceMax",
@ -132,9 +130,7 @@ public:
) )
); );
std::shared_ptr<Effect> traceMin = std::make_shared<Effect>( std::shared_ptr<Effect> traceMin = std::make_shared<Effect>(
[this](int index, Point input, const std::vector<double>& values, double sampleRate) { new EffectParameter(
return input;
}, new EffectParameter(
"Trace min", "Trace min",
"Defines the proportion of the image that drawing starts from. This has the effect of 'tracing' out the image from a single dot when animated. By default, we start drawing from the beginning of the frame, so this value is 0.0.", "Defines the proportion of the image that drawing starts from. This has the effect of 'tracing' out the image from a single dot when animated. By default, we start drawing from the beginning of the frame, so this value is 0.0.",
"traceMin", "traceMin",
@ -162,6 +158,32 @@ public:
} }
); );
// visualiser settings
std::shared_ptr<Effect> persistenceEffect = std::make_shared<Effect>(
new EffectParameter(
"Persistence",
"Controls how long the light glows for on the oscilloscope display.",
"persistence",
VERSION_HINT, 0.0, -1.0, 1.0
)
);
std::shared_ptr<Effect> hueEffect = std::make_shared<Effect>(
new EffectParameter(
"Hue",
"Controls the hue/colour of the oscilloscope display.",
"hue",
VERSION_HINT, 125, 0, 359, 1
)
);
std::shared_ptr<Effect> intensityEffect = std::make_shared<Effect>(
new EffectParameter(
"Intensity",
"Controls how bright the light glows for on the oscilloscope display.",
"intensity",
VERSION_HINT, 0.0, -2.0, 2.0
)
);
BooleanParameter* midiEnabled = new BooleanParameter("MIDI Enabled", "midiEnabled", VERSION_HINT, false); BooleanParameter* midiEnabled = new BooleanParameter("MIDI Enabled", "midiEnabled", VERSION_HINT, false);
BooleanParameter* inputEnabled = new BooleanParameter("Audio Input Enabled", "inputEnabled", VERSION_HINT, false); BooleanParameter* inputEnabled = new BooleanParameter("Audio Input Enabled", "inputEnabled", VERSION_HINT, false);
std::atomic<float> frequency = 220.0f; std::atomic<float> frequency = 220.0f;

Wyświetl plik

@ -17,6 +17,10 @@ Effect::Effect(EffectApplicationType application, const std::vector<EffectParame
Effect::Effect(EffectApplicationType application, EffectParameter* parameter) : Effect(application, std::vector<EffectParameter*>{parameter}) {} Effect::Effect(EffectApplicationType application, EffectParameter* parameter) : Effect(application, std::vector<EffectParameter*>{parameter}) {}
Effect::Effect(const std::vector<EffectParameter*>& parameters) : Effect([](int index, Point input, const std::vector<double>& values, double sampleRate) {return input;}, parameters) {}
Effect::Effect(EffectParameter* parameter) : Effect([](int index, Point input, const std::vector<double>& values, double sampleRate) {return input;}, parameter) {}
Point Effect::apply(int index, Point input, double volume) { Point Effect::apply(int index, Point input, double volume) {
animateValues(volume); animateValues(volume);
if (application) { if (application) {

Wyświetl plik

@ -13,6 +13,8 @@ public:
Effect(std::shared_ptr<EffectApplication> effectApplication, EffectParameter* parameter); Effect(std::shared_ptr<EffectApplication> effectApplication, EffectParameter* parameter);
Effect(EffectApplicationType application, const std::vector<EffectParameter*>& parameters); Effect(EffectApplicationType application, const std::vector<EffectParameter*>& parameters);
Effect(EffectApplicationType application, EffectParameter* parameter); Effect(EffectApplicationType application, EffectParameter* parameter);
Effect(const std::vector<EffectParameter*>& parameters);
Effect(EffectParameter* parameter);
Point apply(int index, Point input, double volume = 0.0); Point apply(int index, Point input, double volume = 0.0);

Wyświetl plik

@ -49,7 +49,6 @@ void MainMenuBarModel::menuItemSelected(int menuItemID, int topLevelMenuIndex) {
} }
break; break;
case 1: { case 1: {
juce::String m = "Test";
juce::DialogWindow::LaunchOptions options; juce::DialogWindow::LaunchOptions options;
AboutComponent* about = new AboutComponent(); AboutComponent* about = new AboutComponent();
options.content.setOwned(about); options.content.setOwned(about);

Wyświetl plik

@ -1,5 +1,6 @@
#include "VisualiserComponent.h" #include "VisualiserComponent.h"
#include "../LookAndFeel.h" #include "../LookAndFeel.h"
#include "VisualiserSettings.h"
VisualiserComponent::VisualiserComponent(OscirenderAudioProcessor& p, VisualiserComponent* parent, bool useOldVisualiser) : backgroundColour(juce::Colours::black), waveformColour(juce::Colour(0xff00ff00)), audioProcessor(p), oldVisualiser(useOldVisualiser), juce::Thread("VisualiserComponent"), parent(parent) { VisualiserComponent::VisualiserComponent(OscirenderAudioProcessor& p, VisualiserComponent* parent, bool useOldVisualiser) : backgroundColour(juce::Colours::black), waveformColour(juce::Colour(0xff00ff00)), audioProcessor(p), oldVisualiser(useOldVisualiser), juce::Thread("VisualiserComponent"), parent(parent) {
resetBuffer(); resetBuffer();
@ -280,3 +281,30 @@ void VisualiserComponent::popoutWindow() {
resized(); resized();
popOutButton.setVisible(false); popOutButton.setVisible(false);
} }
void VisualiserComponent::setIntensity(double intensity) {
browser.emitEventIfBrowserIsVisible("intensityChanged", intensity);
}
void VisualiserComponent::setPersistence(double persistence) {
browser.emitEventIfBrowserIsVisible("persistenceChanged", persistence);
}
void VisualiserComponent::setHue(double hue) {
browser.emitEventIfBrowserIsVisible("hueChanged", hue);
}
void VisualiserComponent::openSettings() {
juce::DialogWindow::LaunchOptions options;
VisualiserSettings* settings = new VisualiserSettings(audioProcessor, *this);
settings->setLookAndFeel(&getLookAndFeel());
options.content.setOwned(settings);
options.content->setSize(500, 250);
options.dialogTitle = "Visualiser Settings";
options.dialogBackgroundColour = Colours::dark;
options.escapeKeyTriggersCloseButton = true;
options.useNativeTitleBar = true;
options.resizable = false;
juce::DialogWindow* dw = options.launchAsync();
}

Wyświetl plik

@ -19,6 +19,10 @@ public:
VisualiserComponent(OscirenderAudioProcessor& p, VisualiserComponent* parent = nullptr, bool useOldVisualiser = false); VisualiserComponent(OscirenderAudioProcessor& p, VisualiserComponent* parent = nullptr, bool useOldVisualiser = false);
~VisualiserComponent() override; ~VisualiserComponent() override;
void setIntensity(double intensity);
void setPersistence(double persistence);
void setHue(double hue);
void openSettings();
void childChanged(); void childChanged();
void enableFullScreen(); void enableFullScreen();
void setFullScreenCallback(std::function<void(FullScreenMode)> callback); void setFullScreenCallback(std::function<void(FullScreenMode)> callback);
@ -106,7 +110,7 @@ private:
popoutWindow(); popoutWindow();
}) })
.withNativeFunction("settings", [this](auto& var, auto complete) { .withNativeFunction("settings", [this](auto& var, auto complete) {
// need to implement openSettings();
}) })
.withNativeFunction("isDebug", [this](auto& var, auto complete) { .withNativeFunction("isDebug", [this](auto& var, auto complete) {
complete((bool) JUCE_DEBUG); complete((bool) JUCE_DEBUG);

Wyświetl plik

@ -0,0 +1,34 @@
#include "VisualiserSettings.h"
#include "../PluginEditor.h"
VisualiserSettings::VisualiserSettings(OscirenderAudioProcessor& p, VisualiserComponent& visualiser) : audioProcessor(p), visualiser(visualiser) {
addAndMakeVisible(intensity);
addAndMakeVisible(persistence);
addAndMakeVisible(hue);
intensity.slider.onValueChange = [this] {
double value = intensity.slider.getValue();
intensity.effect.setValue(value);
this->visualiser.setIntensity(value);
};
persistence.slider.onValueChange = [this] {
double value = persistence.slider.getValue();
persistence.effect.setValue(value);
this->visualiser.setPersistence(value);
};
hue.slider.onValueChange = [this] {
double value = hue.slider.getValue();
hue.effect.setValue(value);
this->visualiser.setHue(value);
};
}
VisualiserSettings::~VisualiserSettings() {}
void VisualiserSettings::resized() {
auto area = getLocalBounds().withTrimmedTop(20).reduced(20);
double rowHeight = 30;
intensity.setBounds(area.removeFromTop(rowHeight));
persistence.setBounds(area.removeFromTop(rowHeight));
hue.setBounds(area.removeFromTop(rowHeight));
}

Wyświetl plik

@ -0,0 +1,23 @@
#pragma once
#include <JuceHeader.h>
#include "VisualiserComponent.h"
#include "EffectComponent.h"
#include "SvgButton.h"
class VisualiserSettings : public juce::Component {
public:
VisualiserSettings(OscirenderAudioProcessor&, VisualiserComponent&);
~VisualiserSettings();
void resized() override;
private:
OscirenderAudioProcessor& audioProcessor;
VisualiserComponent& visualiser;
EffectComponent intensity{audioProcessor, *audioProcessor.intensityEffect};
EffectComponent persistence{audioProcessor, *audioProcessor.persistenceEffect};
EffectComponent hue{audioProcessor, *audioProcessor.hueEffect};
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(VisualiserSettings)
};

Wyświetl plik

@ -176,6 +176,10 @@
file="Source/components/VisualiserComponent.cpp"/> file="Source/components/VisualiserComponent.cpp"/>
<FILE id="ZueyNl" name="VisualiserComponent.h" compile="0" resource="0" <FILE id="ZueyNl" name="VisualiserComponent.h" compile="0" resource="0"
file="Source/components/VisualiserComponent.h"/> file="Source/components/VisualiserComponent.h"/>
<FILE id="uOtHbQ" name="VisualiserSettings.cpp" compile="1" resource="0"
file="Source/components/VisualiserSettings.cpp"/>
<FILE id="GcbeeZ" name="VisualiserSettings.h" compile="0" resource="0"
file="Source/components/VisualiserSettings.h"/>
<FILE id="icFMpl" name="VListBox.cpp" compile="1" resource="0" file="Source/components/VListBox.cpp"/> <FILE id="icFMpl" name="VListBox.cpp" compile="1" resource="0" file="Source/components/VListBox.cpp"/>
<FILE id="mvp8je" name="VListBox.h" compile="0" resource="0" file="Source/components/VListBox.h"/> <FILE id="mvp8je" name="VListBox.h" compile="0" resource="0" file="Source/components/VListBox.h"/>
<FILE id="s8EVcE" name="VolumeComponent.cpp" compile="1" resource="0" <FILE id="s8EVcE" name="VolumeComponent.cpp" compile="1" resource="0"