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 a7c089b874a8d0dea67074413e0619e0a41d059c
parent ea492dabeb6a645842570f9f6266e75a88cc8235
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Tue, 19 Nov 2024 19:59:52 +0100

add option to find similar patches based on a parameter value/range

Diffstat:
Msource/jucePluginEditorLib/patchmanager/patchmanager.cpp | 7+++++++
Msource/jucePluginEditorLib/patchmanager/patchmanager.h | 1+
Msource/jucePluginEditorLib/pluginEditor.cpp | 44++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/source/jucePluginEditorLib/patchmanager/patchmanager.cpp b/source/jucePluginEditorLib/patchmanager/patchmanager.cpp @@ -290,6 +290,13 @@ namespace jucePluginEditorLib::patchManager return true; } + void PatchManager::setCustomSearch(const pluginLib::patchDB::SearchHandle _sh) const + { + m_treeDS->clearSelectedItems(); + m_treeTags->clearSelectedItems(); + + getListModel()->setContent(_sh); + } void PatchManager::bringToFront() const { diff --git a/source/jucePluginEditorLib/patchmanager/patchmanager.h b/source/jucePluginEditorLib/patchmanager/patchmanager.h @@ -112,6 +112,7 @@ namespace jucePluginEditorLib::patchManager void setLayout(LayoutType _layout); bool setGridLayout128(); + void setCustomSearch(pluginLib::patchDB::SearchHandle _sh) const; void bringToFront() const; diff --git a/source/jucePluginEditorLib/pluginEditor.cpp b/source/jucePluginEditorLib/pluginEditor.cpp @@ -455,6 +455,50 @@ namespace jucePluginEditorLib menu.addSubMenu("Parameter Links", linkMenu); + auto& midiPackets = m_processor.getController().getParameterDescriptions().getMidiPackets(); + for (const auto& mp : midiPackets) + { + auto defIndices = mp.second.getDefinitionIndicesForParameterName(param->getDescription().name); + if (defIndices.empty()) + continue; + + const auto expectedValue = param->getUnnormalizedValue(); + + menu.addSeparator(); + + auto findSimilar = [this, defIndices, packet = &mp.second, expectedValue](const int _offsetMin, const int _offsetMax) + { + pluginLib::patchDB::SearchRequest sr; + + sr.customCompareFunc = [packet, expectedValue, defIndices, _offsetMin, _offsetMax](const pluginLib::patchDB::Patch& _patch) -> bool + { + if (_patch.sysex.empty()) + return false; + const auto v = packet->getParameterValue(_patch.sysex, defIndices); + if (v >= expectedValue + _offsetMin && v <= expectedValue + _offsetMax) + return true; + return false; + }; + + const auto sh = getPatchManager()->search(std::move(sr)); + + if (sh != pluginLib::patchDB::g_invalidSearchHandle) + { + getPatchManager()->setCustomSearch(sh); + getPatchManager()->bringToFront(); + } + }; + + juce::PopupMenu subMenu; + subMenu.addItem("Exact Match (Value " + param->getCurrentValueAsText() + ")", [this, findSimilar]{ findSimilar(0, 0); }); + subMenu.addItem("-/+ 4", [this, findSimilar]{ findSimilar(-4, 4); }); + subMenu.addItem("-/+ 12", [this, findSimilar]{ findSimilar(-12, 12); }); + subMenu.addItem("-/+ 24", [this, findSimilar]{ findSimilar(-24, 24); }); + + menu.addSubMenu("Find similar Patches for parameter " + param->getDescription().displayName, subMenu); + + break; + } menu.showMenuAsync({}); return true;