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 47e12754e100d48174bf39eb94663216666a21b5
parent d3f3e36e84be94e53ef9d9fa4618140ff4c451aa
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Sat,  3 Aug 2024 02:15:16 +0200

update patch name in LCD

Diffstat:
Msource/nord/n2x/n2xJucePlugin/n2xEditor.cpp | 63++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
Msource/nord/n2x/n2xJucePlugin/n2xEditor.h | 9+++++++++
Msource/nord/n2x/n2xJucePlugin/n2xLcd.cpp | 5+++++
Msource/nord/n2x/n2xJucePlugin/n2xLcd.h | 2++
Msource/nord/n2x/n2xJucePlugin/n2xPatchManager.cpp | 8++++++--
5 files changed, 82 insertions(+), 5 deletions(-)

diff --git a/source/nord/n2x/n2xJucePlugin/n2xEditor.cpp b/source/nord/n2x/n2xJucePlugin/n2xEditor.cpp @@ -84,6 +84,11 @@ namespace n2xJucePlugin onBtSave(); }; } + + m_onSelectedPatchChanged.set(getPatchManager()->onSelectedPatchChanged, [this](const uint32_t& _part, const pluginLib::patchDB::PatchKey& _patchKey) + { + onSelectedPatchChanged(static_cast<uint8_t>(_part), _patchKey); + }); } Editor::~Editor() @@ -128,19 +133,71 @@ namespace n2xJucePlugin std::string Editor::getCurrentPatchName() const { - return m_controller.getPatchName(m_controller.getCurrentPart()); + const auto part = m_controller.getCurrentPart(); + if(!m_activePatchNames[part].empty()) + return m_activePatchNames[part]; + return m_controller.getPatchName(part); + } + + void Editor::onPatchActivated(const pluginLib::patchDB::PatchPtr& _patch, const uint32_t _part) + { + const auto isMulti = _patch->sysex.size() == n2x::g_multiDumpSize; + + const auto name = _patch->getName(); + + setCurrentPatchName(_part, name); + + if(isMulti) + { + for (uint8_t p=0; p<m_activePatchNames.size(); ++p) + { + if(p == _part) + continue; + + // set patch name for all parts if the source is a multi + setCurrentPatchName(p, name); + + // set patch manager selection so that all parts have the multi selected + getPatchManager()->setSelectedPatch(p, _patch); + } + } + + m_lcd->updatePatchName(); } void Editor::onBtSave() const { juce::PopupMenu menu; - const auto numAdded = getPatchManager()->createSaveMenuEntries(menu, "Program"); - if(numAdded) + if(getPatchManager()->createSaveMenuEntries(menu, "Program")) menu.addSeparator(); getPatchManager()->createSaveMenuEntries(menu, m_controller.getPartCount(), "Performance"); menu.showMenuAsync({}); } + + void Editor::setCurrentPatchName(uint8_t _part, const std::string& _name) + { + if(m_activePatchNames[_part] == _name) + return; + + m_activePatchNames[_part] = _name; + + if(m_controller.getCurrentPart() == _part) + m_lcd->updatePatchName(); + } + + void Editor::onSelectedPatchChanged(uint8_t _part, const pluginLib::patchDB::PatchKey& _patchKey) + { + auto source = _patchKey.source; + if(!source) + return; + + if(source->patches.empty()) + source = getPatchManager()->getDataSource(*source); + + if(const auto patch = source->getPatch(_patchKey)) + setCurrentPatchName(_part, patch->getName()); + } } diff --git a/source/nord/n2x/n2xJucePlugin/n2xEditor.h b/source/nord/n2x/n2xJucePlugin/n2xEditor.h @@ -1,6 +1,7 @@ #pragma once #include "jucePluginEditorLib/pluginEditor.h" +#include "jucePluginLib/patchdb/patch.h" namespace jucePluginEditorLib { @@ -42,8 +43,12 @@ namespace n2xJucePlugin std::string getCurrentPatchName() const; + void onPatchActivated(const pluginLib::patchDB::PatchPtr& _patch, uint32_t _part); + private: void onBtSave() const; + void setCurrentPatchName(uint8_t _part, const std::string& _name); + void onSelectedPatchChanged(uint8_t _part, const pluginLib::patchDB::PatchKey& _patchKey); Controller& m_controller; pluginLib::ParameterBinding& m_parameterBinding; @@ -52,5 +57,9 @@ namespace n2xJucePlugin std::unique_ptr<Lcd> m_lcd; std::unique_ptr<Parts> m_parts; pluginLib::EventListener<uint8_t> onPartChanged; + + std::array<std::string, 4> m_activePatchNames; + + pluginLib::EventListener<uint32_t, pluginLib::patchDB::PatchKey> m_onSelectedPatchChanged; }; } diff --git a/source/nord/n2x/n2xJucePlugin/n2xLcd.cpp b/source/nord/n2x/n2xJucePlugin/n2xLcd.cpp @@ -68,6 +68,11 @@ namespace n2xJucePlugin } } + void Lcd::updatePatchName() + { + onProgramChanged(); + } + void Lcd::setClippedText(const std::string& _text) { if(m_clippedText == _text) diff --git a/source/nord/n2x/n2xJucePlugin/n2xLcd.h b/source/nord/n2x/n2xJucePlugin/n2xLcd.h @@ -31,6 +31,8 @@ namespace n2xJucePlugin void timerCallback() override; + void updatePatchName(); + private: void setClippedText(const std::string& _text); static std::string substring(const std::string& _text, uint32_t _offset, uint32_t _len); diff --git a/source/nord/n2x/n2xJucePlugin/n2xPatchManager.cpp b/source/nord/n2x/n2xJucePlugin/n2xPatchManager.cpp @@ -114,9 +114,13 @@ namespace n2xJucePlugin return activatePatch(_patch, getCurrentPart()); } - bool PatchManager::activatePatch(const pluginLib::patchDB::PatchPtr& _patch, uint32_t _part) + bool PatchManager::activatePatch(const pluginLib::patchDB::PatchPtr& _patch, const uint32_t _part) { - return m_controller.activatePatch(_patch->sysex, _part); + if(!m_controller.activatePatch(_patch->sysex, _part)) + return false; + + m_editor.onPatchActivated(_patch, _part); + return true; } bool PatchManager::parseFileData(pluginLib::patchDB::DataList& _results, const pluginLib::patchDB::Data& _data)