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 035b675493b0ca79eafa42c314a5a606a98751ed
parent b0d2800c9ff7e7b65d0de9400a0441bfe2d66db5
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Mon, 30 Sep 2024 22:24:44 +0200

wave table selection now follows the wave parameter from the current part patch

Diffstat:
Msource/xtJucePlugin/weTablesTree.cpp | 64+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Msource/xtJucePlugin/weTablesTree.h | 16++++++++++++++++
Msource/xtJucePlugin/weTablesTreeItem.h | 2++
Msource/xtJucePlugin/weWaveTree.cpp | 1+
Msource/xtJucePlugin/xtWaveEditor.cpp | 3+++
5 files changed, 85 insertions(+), 1 deletion(-)

diff --git a/source/xtJucePlugin/weTablesTree.cpp b/source/xtJucePlugin/weTablesTree.cpp @@ -1,8 +1,10 @@ #include "weTablesTree.h" #include "weTablesTreeItem.h" -#include "weTypes.h" #include "weData.h" +#include "xtController.h" +#include "xtEditor.h" +#include "xtWaveEditor.h" #include "xtLib/xtMidiTypes.h" @@ -17,6 +19,66 @@ namespace xtJucePlugin getRootItem()->addSubItem(new TablesTreeItem(_editor, xt::TableId(i))); } + setIndentSize(5); + + auto* paramWave = getWaveParameter(); + + m_waveParamListener.set(paramWave, [this](pluginLib::Parameter* const&) + { + onWaveParamChanged(); + }); + + m_partChangedListener.set(getWaveEditor().getEditor().getXtController().onCurrentPartChanged, [this](const uint8_t&) + { + onPartChanged(); + }); + } + + void TablesTree::setSelectedEntryFromCurrentPreset() const + { + const auto* paramWave = getWaveParameter(); + + const auto tableId = xt::TableId(static_cast<uint16_t>(paramWave->getUnnormalizedValue())); + getWaveEditor().setSelectedTable(tableId); + } + + void TablesTree::setSelectedTable(const xt::TableId _id) const + { + for(int i=0; i<getRootItem()->getNumSubItems(); ++i) + { + auto* subItem = dynamic_cast<TablesTreeItem*>(getRootItem()->getSubItem(i)); + if(!subItem) + continue; + if(subItem->getTableId() == _id) + { + subItem->setSelected(true, true, juce::dontSendNotification); + getRootItem()->getOwnerView()->scrollToKeepItemVisible(subItem); + + auto* paramWave = getWaveParameter(); + if(paramWave->getUnnormalizedValue() != _id.rawId()) + paramWave->setUnnormalizedValueNotifyingHost(_id.rawId(), pluginLib::Parameter::Origin::Ui); + + return; + } + } + } + + void TablesTree::onWaveParamChanged() const + { + setSelectedEntryFromCurrentPreset(); + } + + void TablesTree::onPartChanged() const + { + setSelectedEntryFromCurrentPreset(); + } + + pluginLib::Parameter* TablesTree::getWaveParameter() const + { + const auto& c = getWaveEditor().getEditor().getXtController(); + auto* param = c.getParameter("Wave", c.getCurrentPart()); + assert(param); + return param; } } diff --git a/source/xtJucePlugin/weTablesTree.h b/source/xtJucePlugin/weTablesTree.h @@ -2,11 +2,27 @@ #include "weTree.h" +#include "xtLib/xtId.h" + +#include "jucePluginLib/parameterlistener.h" + namespace xtJucePlugin { class TablesTree : public Tree { public: explicit TablesTree(WaveEditor& _editor); + + void setSelectedTable(xt::TableId _id) const; + + void setSelectedEntryFromCurrentPreset() const; + + private: + void onWaveParamChanged() const; + void onPartChanged() const; + pluginLib::Parameter* getWaveParameter() const; + + pluginLib::ParameterListener m_waveParamListener; + pluginLib::EventListener<uint8_t> m_partChangedListener; }; } diff --git a/source/xtJucePlugin/weTablesTreeItem.h b/source/xtJucePlugin/weTablesTreeItem.h @@ -23,6 +23,8 @@ namespace xtJucePlugin bool isInterestedInDragSource(const juce::DragAndDropTarget::SourceDetails& dragSourceDetails) override; void itemDropped(const juce::DragAndDropTarget::SourceDetails& dragSourceDetails, int insertIndex) override; + const auto& getTableId() const { return m_index; } + private: void onTableChanged(xt::TableId _index); void onTableChanged(); diff --git a/source/xtJucePlugin/weWaveTree.cpp b/source/xtJucePlugin/weWaveTree.cpp @@ -3,6 +3,7 @@ #include "weTypes.h" #include "weWaveCategoryTreeItem.h" #include "xtEditor.h" +#include "xtWaveEditor.h" namespace xtJucePlugin { diff --git a/source/xtJucePlugin/xtWaveEditor.cpp b/source/xtJucePlugin/xtWaveEditor.cpp @@ -98,6 +98,8 @@ namespace xtJucePlugin { saveWavetable(); }; + + m_tablesTree->setSelectedEntryFromCurrentPreset(); } void WaveEditor::destroy() @@ -214,6 +216,7 @@ namespace xtJucePlugin m_selectedTable = _index; m_controlTree->setTable(_index); + m_tablesTree->setSelectedTable(_index); } void WaveEditor::setSelectedWave(const xt::WaveId _waveIndex, bool _forceRefresh/* = false*/)