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 86f76a45a4e55c23b59ffe271ea88d2815a09f06
parent 0b80335c26e1a6766863cebf9e44cfb4e15859a9
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Tue, 30 Jul 2024 18:18:08 +0200

implement parameter updates by control change

Diffstat:
Msource/jucePluginLib/controller.cpp | 25+++++++++++++++++++++++--
Msource/jucePluginLib/controller.h | 2++
Msource/nord/n2x/n2xJucePlugin/n2xController.cpp | 23++++++++++++++++-------
3 files changed, 41 insertions(+), 9 deletions(-)

diff --git a/source/jucePluginLib/controller.cpp b/source/jucePluginLib/controller.cpp @@ -157,10 +157,10 @@ namespace pluginLib } } - void Controller::sendSysEx(const pluginLib::SysEx& msg) const + void Controller::sendSysEx(const pluginLib::SysEx& _msg) const { synthLib::SMidiEvent ev(synthLib::MidiEventSource::Editor); - ev.sysex = msg; + ev.sysex = _msg; sendMidiEvent(ev); } @@ -521,6 +521,27 @@ namespace pluginLib m_parameterLinks.saveChunkData(s); } + Parameter::Origin Controller::midiEventSourceToParameterOrigin(const synthLib::MidiEventSource _source) + { + switch (_source) + { + case synthLib::MidiEventSource::Unknown: + return Parameter::Origin::Unknown; + case synthLib::MidiEventSource::Editor: + return Parameter::Origin::Ui; + case synthLib::MidiEventSource::Host: + return Parameter::Origin::HostAutomation; + case synthLib::MidiEventSource::PhysicalInput: + case synthLib::MidiEventSource::Plugin: + return Parameter::Origin::Midi; + case synthLib::MidiEventSource::Internal: + return Parameter::Origin::Unknown; + default: + assert(false && "implement new midi event source type"); + return Parameter::Origin::Unknown; + } + } + void Controller::getMidiMessages(std::vector<synthLib::SMidiEvent>& _events) { const std::lock_guard l(m_midiMessagesLock); diff --git a/source/jucePluginLib/controller.h b/source/jucePluginLib/controller.h @@ -75,6 +75,8 @@ namespace pluginLib void loadChunkData(baseLib::ChunkReader& _cr); void saveChunkData(baseLib::BinaryStream& s); + static Parameter::Origin midiEventSourceToParameterOrigin(synthLib::MidiEventSource _source); + private: void getMidiMessages(std::vector<synthLib::SMidiEvent>&); void processMidiMessages(); diff --git a/source/nord/n2x/n2xJucePlugin/n2xController.cpp b/source/nord/n2x/n2xJucePlugin/n2xController.cpp @@ -81,13 +81,9 @@ namespace n2xJucePlugin bool Controller::parseSysexMessage(const pluginLib::SysEx& _msg, synthLib::MidiEventSource) { if(_msg.size() == n2x::g_singleDumpSize) - { return parseSingleDump(_msg); - } if(_msg.size() == n2x::g_multiDumpSize) - { return parseMultiDump(_msg); - } return false; } @@ -117,10 +113,23 @@ namespace n2xJucePlugin return false; } - bool Controller::parseControllerMessage(const synthLib::SMidiEvent&) + bool Controller::parseControllerMessage(const synthLib::SMidiEvent& _e) { - // TODO - return false; + const auto& cm = getParameterDescriptions().getControllerMap(); + const auto paramIndices = cm.getControlledParameters(_e); + + if(paramIndices.empty()) + return false; + + for (const auto paramIndex : paramIndices) + { + auto* param = getParameter(paramIndex); + assert(param && "parameter not found for control change"); + // TODO: part + param->setValueFromSynth(_e.c, midiEventSourceToParameterOrigin(_e.source)); + } + + return true; } void Controller::sendParameterChange(const pluginLib::Parameter& _parameter, const uint8_t _value)