gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

commit df6fc70be64b0f63980fd358d21a52ebb70da47d
parent 1b2018955518f1d6e98a224578641e4fa32b49b3
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Mon,  5 Aug 2024 22:18:02 +0200

implement arp state/button

Diffstat:
Msource/nord/n2x/n2xJucePlugin/n2xArp.cpp | 45++++++++++++++++++++++++++++++++++++++++++++-
Msource/nord/n2x/n2xJucePlugin/n2xArp.h | 17+++++++++++++++--
Msource/nord/n2x/n2xJucePlugin/skins/n2xTrancy/n2xTrancy.json | 2+-
3 files changed, 60 insertions(+), 4 deletions(-)

diff --git a/source/nord/n2x/n2xJucePlugin/n2xArp.cpp b/source/nord/n2x/n2xJucePlugin/n2xArp.cpp @@ -1,8 +1,51 @@ #include "n2xArp.h" +#include "n2xController.h" +#include "n2xEditor.h" + +#include "juce_gui_basics/juce_gui_basics.h" + namespace n2xJucePlugin { - Arp::Arp(Editor& _editor) : m_editor(_editor) + Arp::Arp(Editor& _editor) : m_editor(_editor), m_btArpActive(_editor.findComponentT<juce::Button>("ArpEnabled")) + { + auto& c = _editor.getN2xController(); + + m_onCurrentPartChanged.set(c.onCurrentPartChanged, [this](const uint8_t&) + { + bind(); + }); + + m_btArpActive->onClick = [this] + { + if(!m_param) + return; + m_param->setUnnormalizedValueNotifyingHost(m_btArpActive->getToggleState() ? 0 : 3, pluginLib::Parameter::Origin::Ui); + }; + + bind(); + } + + void Arp::bind() { + const auto& c = m_editor.getN2xController(); + + m_param = c.getParameter("Lfo2Dest", c.getCurrentPart()); + + m_onParamChanged.set(m_param, [this](const pluginLib::Parameter* _parameter) + { + updateStateFromParameter(_parameter); + }); + + updateStateFromParameter(m_param); + } + + void Arp::updateStateFromParameter(const pluginLib::Parameter* _parameter) const + { + const auto v = _parameter->getUnnormalizedValue(); + + const bool arpActive = v != 3 && v != 4 && v != 7; + + m_btArpActive->setToggleState(arpActive, juce::dontSendNotification); } } diff --git a/source/nord/n2x/n2xJucePlugin/n2xArp.h b/source/nord/n2x/n2xJucePlugin/n2xArp.h @@ -1,5 +1,12 @@ #pragma once +#include "jucePluginLib/parameterlistener.h" + +namespace juce +{ + class Button; +} + namespace n2xJucePlugin { class Editor; @@ -10,6 +17,13 @@ namespace n2xJucePlugin explicit Arp(Editor& _editor); private: + void bind(); + void updateStateFromParameter(const pluginLib::Parameter* _parameter) const; + Editor& m_editor; + juce::Button* m_btArpActive; + pluginLib::ParameterListener m_onParamChanged; + pluginLib::EventListener<uint8_t> m_onCurrentPartChanged; + pluginLib::Parameter* m_param = nullptr; }; -} -\ No newline at end of file +} diff --git a/source/nord/n2x/n2xJucePlugin/skins/n2xTrancy/n2xTrancy.json b/source/nord/n2x/n2xJucePlugin/skins/n2xTrancy/n2xTrancy.json @@ -149,7 +149,7 @@ ] }, - { "name" : "Lfo2Dest", "parameterAttachment" : { "parameter" : "Lfo2Dest", "value":0, "valueOff":3}, "button" : { "isToggle" : "1", "normalImage" : "0", "overImage" : "0", "downImage" : "0", "normalImageOn" : "1", "overImageOn" : "1", "downImageOn" : "1", "x" : "485", "y" : "254", "width" : "70", "height" : "70", "texture" : "button_round", "tileSizeX" : "70", "tileSizeY" : "70" , "hitOffsetT":20, "hitOffsetB":-20, "hitOffsetR":90} }, + { "name" : "ArpEnabled", "button" : { "isToggle" : "1", "normalImage" : "0", "overImage" : "0", "downImage" : "0", "normalImageOn" : "1", "overImageOn" : "1", "downImageOn" : "1", "x" : "485", "y" : "254", "width" : "70", "height" : "70", "texture" : "button_round", "tileSizeX" : "70", "tileSizeY" : "70" , "hitOffsetT":20, "hitOffsetB":-20, "hitOffsetR":90} }, { "name" : "Lfo2Rate", "parameterAttachment" : { "parameter" : "Lfo2Rate" }, "rotary" : { }, "spritesheet" : { "x" : "36", "y" : "350", "width" : "113", "height" : "113", "texture" : "knob_big", "tileSizeX" : "113", "tileSizeY" : "113" } },