commit 2392bf87c7f3e60ac24a315acd97f1a3a39664ad
parent 8dac756ec0338adcd812cc42a1d8fe5a9f907140
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Tue, 6 Aug 2024 22:28:22 +0200
implement octave LED
Diffstat:
6 files changed, 85 insertions(+), 3 deletions(-)
diff --git a/source/nord/n2x/n2xJucePlugin/CMakeLists.txt b/source/nord/n2x/n2xJucePlugin/CMakeLists.txt
@@ -7,6 +7,7 @@ set(SOURCES
n2xController.cpp n2xController.h
n2xEditor.cpp n2xEditor.h
n2xMasterVolume.cpp n2xMasterVolume.h
+ n2xOctLed.cpp n2xOctLed.h
n2xLcd.cpp n2xLcd.h
n2xPart.cpp n2xPart.h
n2xParts.cpp n2xParts.h
diff --git a/source/nord/n2x/n2xJucePlugin/n2xEditor.cpp b/source/nord/n2x/n2xJucePlugin/n2xEditor.cpp
@@ -6,6 +6,7 @@
#include "n2xController.h"
#include "n2xLcd.h"
#include "n2xMasterVolume.h"
+#include "n2xOctLed.h"
#include "n2xPart.h"
#include "n2xParts.h"
#include "n2xPatchManager.h"
@@ -72,6 +73,7 @@ namespace n2xJucePlugin
m_arp.reset(new Arp(*this));
m_lcd.reset(new Lcd(*this));
m_masterVolume.reset(new MasterVolume(*this));
+ m_octLed.reset(new OctLed(*this));
m_parts.reset(new Parts(*this));
m_vmMap.reset(new VmMap(*this, m_parameterBinding));
@@ -116,6 +118,7 @@ namespace n2xJucePlugin
m_arp.reset();
m_lcd.reset();
m_masterVolume.reset();
+ m_octLed.reset();
m_parts.reset();
m_vmMap.reset();
}
diff --git a/source/nord/n2x/n2xJucePlugin/n2xEditor.h b/source/nord/n2x/n2xJucePlugin/n2xEditor.h
@@ -18,10 +18,12 @@ namespace n2xJucePlugin
{
class PatchManager;
class Controller;
- class Lcd;
+
class Arp;
- class Parts;
+ class Lcd;
class MasterVolume;
+ class OctLed;
+ class Parts;
class VmMap;
class Editor final : public jucePluginEditorLib::Editor
@@ -60,6 +62,7 @@ namespace n2xJucePlugin
std::unique_ptr<Arp> m_arp;
std::unique_ptr<Lcd> m_lcd;
std::unique_ptr<MasterVolume> m_masterVolume;
+ std::unique_ptr<OctLed> m_octLed;
std::unique_ptr<Parts> m_parts;
std::unique_ptr<VmMap> m_vmMap;
diff --git a/source/nord/n2x/n2xJucePlugin/n2xOctLed.cpp b/source/nord/n2x/n2xJucePlugin/n2xOctLed.cpp
@@ -0,0 +1,46 @@
+#include "n2xOctLed.h"
+
+#include "n2xController.h"
+#include "n2xEditor.h"
+
+#include "juce_gui_basics/juce_gui_basics.h"
+
+namespace n2xJucePlugin
+{
+ OctLed::OctLed(Editor& _editor) : m_editor(_editor), m_octLed(_editor.findComponentT<juce::Button>("O2Pitch_LED"))
+ {
+ auto& c = _editor.getN2xController();
+
+ m_onCurrentPartChanged.set(c.onCurrentPartChanged, [this](const uint8_t&)
+ {
+ bind();
+ });
+
+ m_octLed->setInterceptsMouseClicks(false, false);
+
+ bind();
+ }
+
+ void OctLed::bind()
+ {
+ const auto& c = m_editor.getN2xController();
+
+ m_param = c.getParameter("O2Pitch", c.getCurrentPart());
+
+ m_onParamChanged.set(m_param, [this](const pluginLib::Parameter* _parameter)
+ {
+ updateStateFromParameter(_parameter);
+ });
+
+ updateStateFromParameter(m_param);
+ }
+
+ void OctLed::updateStateFromParameter(const pluginLib::Parameter* _parameter) const
+ {
+ const auto v = _parameter->getUnnormalizedValue();
+
+ const bool active = v / 12 * 12 == v;
+
+ m_octLed->setToggleState(active, juce::dontSendNotification);
+ }
+}
diff --git a/source/nord/n2x/n2xJucePlugin/n2xOctLed.h b/source/nord/n2x/n2xJucePlugin/n2xOctLed.h
@@ -0,0 +1,29 @@
+#pragma once
+
+#include "jucePluginLib/parameterlistener.h"
+
+namespace juce
+{
+ class Button;
+}
+
+namespace n2xJucePlugin
+{
+ class Editor;
+
+ class OctLed
+ {
+ public:
+ explicit OctLed(Editor& _editor);
+
+ private:
+ void bind();
+ void updateStateFromParameter(const pluginLib::Parameter* _parameter) const;
+
+ Editor& m_editor;
+ juce::Button* m_octLed;
+ pluginLib::ParameterListener m_onParamChanged;
+ pluginLib::EventListener<uint8_t> m_onCurrentPartChanged;
+ pluginLib::Parameter* m_param = nullptr;
+ };
+}
diff --git a/source/nord/n2x/n2xJucePlugin/skins/n2xTrancy/n2xTrancy.json b/source/nord/n2x/n2xJucePlugin/skins/n2xTrancy/n2xTrancy.json
@@ -70,7 +70,7 @@
{ "name" : "O2PitchFine", "parameterAttachment" : { "parameter" : "O2PitchFine" }, "rotary" : { }, "spritesheet" : { "x" : "923", "y" : "377", "width" : "113", "height" : "113", "texture" : "knob_big", "tileSizeX" : "113", "tileSizeY" : "113" } },
{ "name" : "O2Pitch", "parameterAttachment" : { "parameter" : "O2Pitch" }, "rotary" : { }, "spritesheet" : { "x" : "921", "y" : "107", "width" : "113", "height" : "113", "texture" : "knob_big", "tileSizeX" : "113", "tileSizeY" : "113" } },
- { "name" : "O2Pitch_LED", "parameterAttachment" : { "parameter" : "O2Pitch", "value":60}, "button" : { "isToggle" : "0", "normalImage" : "0", "overImage" : "0", "downImage" : "0", "normalImageOn" : "1", "overImageOn" : "1", "downImageOn" : "1", "x" : "942", "y" : "27", "width" : "70", "height" : "70", "texture" : "button_round", "tileSizeX" : "70", "tileSizeY" : "70" } },
+ { "name" : "O2Pitch_LED", "button" : { "isToggle" : "0", "normalImage" : "0", "overImage" : "0", "downImage" : "0", "normalImageOn" : "1", "overImageOn" : "1", "downImageOn" : "1", "x" : "942", "y" : "27", "width" : "70", "height" : "70", "texture" : "button_round", "tileSizeX" : "70", "tileSizeY" : "70" } },
{ "name" : "O2Waveform_1", "parameterAttachment" : { "parameter" : "O2Waveform", "value":2}, "button" : { "isToggle" : "1", "normalImage" : "0", "overImage" : "0", "downImage" : "0", "normalImageOn" : "1", "overImageOn" : "1", "downImageOn" : "1", "x" : "1101", "y" : "79", "width" : "70", "height" : "70", "texture" : "button_round", "tileSizeX" : "70", "tileSizeY" : "70", "hitOffsetT":20, "hitOffsetB":-20, "hitOffsetR":100 } },