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 e0866ff972621df116223ff7e0eb3e0cc735a1ad
parent 563da64c0355444cb703c3e6e486c5f28bd66ca9
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Sat, 12 Feb 2022 04:15:04 +0100

UI controls now react to midi input messages (CC, PP and sysex control changes)

Diffstat:
Msource/jucePlugin/PluginProcessor.cpp | 10+++++++++-
Msource/jucePlugin/VirusController.cpp | 30+++++++++++++-----------------
Msource/virusLib/microcontroller.cpp | 6++++++
3 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/source/jucePlugin/PluginProcessor.cpp b/source/jucePlugin/PluginProcessor.cpp @@ -179,6 +179,14 @@ void AudioPluginAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer, ev.a = message.getRawData()[0]; ev.b = message.getRawDataSize() > 0 ? message.getRawData()[1] : 0; ev.c = message.getRawDataSize() > 1 ? message.getRawData()[2] : 0; + + const auto status = ev.a & 0xf0; + + if(status == synthLib::M_CONTROLCHANGE || status == synthLib::M_POLYPRESSURE) + { + // forward to UI to react to control input changes that should move knobs + getController().dispatchVirusOut(std::vector<synthLib::SMidiEvent>{ev}); + } } ev.offset = metadata.samplePosition; @@ -211,7 +219,7 @@ void AudioPluginAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer, if (!m_midiOut.empty()) { - m_controller->dispatchVirusOut(m_midiOut); + getController().dispatchVirusOut(m_midiOut); } for (auto& e : m_midiOut) diff --git a/source/jucePlugin/VirusController.cpp b/source/jucePlugin/VirusController.cpp @@ -428,26 +428,22 @@ namespace Virus void Controller::parseControllerDump(synthLib::SMidiEvent &m) { + const uint8_t status = m.a & 0xf0; + const uint8_t part = m.a & 0x0f; + uint8_t page; - uint8_t part; - if (m.a & synthLib::M_CONTROLCHANGE) - { - part = m.a ^ synthLib::M_CONTROLCHANGE; - page = 0x0; - } - else if (m.a & synthLib::M_POLYPRESSURE) - { - part = m.a ^ synthLib::M_POLYPRESSURE; - page = 0x1; - } + + if (status == synthLib::M_CONTROLCHANGE) + page = virusLib::PAGE_A; + else if (status == synthLib::M_POLYPRESSURE) + page = virusLib::PAGE_B; else - { - jassertfalse; return; - } - jassert(bank != 0xFF); - DBG(juce::String::formatted("Set part: %d bank: %s param: %d value: %d", part, bank == 0 ? "A" : "B", m.b, m.c)); - findSynthParam(part, page, m.b)->setValueFromSynth(m.c, true); + + DBG(juce::String::formatted("Set part: %d bank: %s param: %d value: %d", part, page == 0 ? "A" : "B", m.b, m.c)); + auto* p = findSynthParam(part, page, m.b); + if(p) + p->setValueFromSynth(m.c, true); } uint8_t Controller::copyData(const SysEx &src, int startPos, std::array<uint8_t, kDataSizeInBytes>& dst) diff --git a/source/virusLib/microcontroller.cpp b/source/virusLib/microcontroller.cpp @@ -575,6 +575,12 @@ bool Microcontroller::sendSysex(const std::vector<uint8_t>& _data, bool _cancelI } } + // bounce back to UI + SMidiEvent ev; + ev.sysex = _data; + ev.source = MidiEventSourceEditor; // don't send to output + _responses.push_back(ev); + return send(page, part, param, value, _cancelIfFull); } default: