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 ea9e967fc8dcb3e321bcfd94ec20c2752cc69e6f
parent 03f3b1a0d02aeb58aeac7a9745831d75f81b30c5
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Sat, 15 Jun 2024 16:59:19 +0200

wave editor now based on predefined UI layout

Diffstat:
Msource/xtJucePlugin/skins/xtDefault/xtDefault.json | 178+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
Msource/xtJucePlugin/skins/xtDefault/xtPageWave.png | 0
Msource/xtJucePlugin/weTree.cpp | 15+++++++++++++++
Msource/xtJucePlugin/weTree.h | 1+
Msource/xtJucePlugin/weTypes.h | 2++
Asource/xtJucePlugin/weWaveCategoryTreeItem.cpp | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asource/xtJucePlugin/weWaveCategoryTreeItem.h | 25+++++++++++++++++++++++++
Msource/xtJucePlugin/xtEditor.cpp | 16+++++++++++++---
Msource/xtJucePlugin/xtEditor.h | 1+
Msource/xtJucePlugin/xtWaveEditor.cpp | 40++++++++++------------------------------
Msource/xtJucePlugin/xtWaveEditor.h | 11+++++------
11 files changed, 301 insertions(+), 42 deletions(-)

diff --git a/source/xtJucePlugin/skins/xtDefault/xtDefault.json b/source/xtJucePlugin/skins/xtDefault/xtDefault.json @@ -8494,10 +8494,182 @@ "name" : "waveEditorContainer", "component" : { "x" : "0", - "y" : "48", + "y" : "0", "width" : "3322.7", - "height" : "1431.802" - } + "height" : "1479.802" + }, + "children" : [ + { + "name" : "wecWavetableList", + "component" : { + "x" : "0", + "y" : "48", + "width" : "500", + "height" : "1431.802" + } + }, + { + "name" : "wecWaveControlTable", + "component" : { + "x" : "540", + "y" : "48", + "width" : "500", + "height" : "1284.952" + } + }, + { + "name" : "xtButton", + "button" : { + "isToggle" : "1", + "normalImage" : "0", + "overImage" : "0", + "downImage" : "1", + "normalImageOn" : "1", + "overImageOn" : "1", + "downImageOn" : "1", + "x" : "638", + "y" : "1372.377", + "width" : "64", + "height" : "64", + "texture" : "xtknob_small", + "tileSizeX" : "64", + "tileSizeY" : "64" + } + }, + { + "name" : "xtLed", + "button" : { + "normalImage" : "0", + "overImage" : "0", + "downImage" : "0", + "normalImageOn" : "1", + "overImageOn" : "1", + "downImageOn" : "1", + "x" : "654", + "y" : "1340.377", + "width" : "32", + "height" : "32", + "texture" : "led", + "tileSizeX" : "128", + "tileSizeY" : "128" + }, + "parameterAttachment" : { + "parameter" : "O2Link" + } + }, + { + "name" : "xtButton", + "button" : { + "normalImage" : "0", + "overImage" : "0", + "downImage" : "1", + "normalImageOn" : "1", + "overImageOn" : "1", + "downImageOn" : "1", + "x" : "878", + "y" : "1372.377", + "width" : "64", + "height" : "64", + "texture" : "xtknob_small", + "tileSizeX" : "64", + "tileSizeY" : "64" + } + }, + { + "name" : "wecWaveList", + "component" : { + "x" : "1080", + "y" : "48", + "width" : "500", + "height" : "1431.802" + } + }, + { + "name" : "wecWaveTime", + "component" : { + "x" : "1620", + "y" : "48", + "width" : "1700", + "height" : "614.5936" + } + }, + { + "name" : "xtButton", + "button" : { + "isToggle" : "1", + "normalImage" : "0", + "overImage" : "0", + "downImage" : "1", + "normalImageOn" : "1", + "overImageOn" : "1", + "downImageOn" : "1", + "x" : "1662", + "y" : "705.9009", + "width" : "64", + "height" : "64", + "texture" : "xtknob_small", + "tileSizeX" : "64", + "tileSizeY" : "64" + } + }, + { + "name" : "xtLed", + "button" : { + "normalImage" : "0", + "overImage" : "0", + "downImage" : "0", + "normalImageOn" : "1", + "overImageOn" : "1", + "downImageOn" : "1", + "x" : "1678", + "y" : "673.9009", + "width" : "32", + "height" : "32", + "texture" : "led", + "tileSizeX" : "128", + "tileSizeY" : "128" + }, + "parameterAttachment" : { + "parameter" : "O2Link" + } + }, + { + "name" : "xtButton", + "button" : { + "normalImage" : "0", + "overImage" : "0", + "downImage" : "1", + "normalImageOn" : "1", + "overImageOn" : "1", + "downImageOn" : "1", + "x" : "1815", + "y" : "705.9009", + "width" : "64", + "height" : "64", + "texture" : "xtknob_small", + "tileSizeX" : "64", + "tileSizeY" : "64" + } + }, + { + "name" : "wecWaveFreq", + "component" : { + "x" : "1620", + "y" : "865.2081", + "width" : "830", + "height" : "614.5936" + } + }, + { + "name" : "wecWavePhase", + "component" : { + "x" : "2490", + "y" : "865.2081", + "width" : "830", + "height" : "614.5936" + } + } + ] } ] }, diff --git a/source/xtJucePlugin/skins/xtDefault/xtPageWave.png b/source/xtJucePlugin/skins/xtDefault/xtPageWave.png Binary files differ. diff --git a/source/xtJucePlugin/weTree.cpp b/source/xtJucePlugin/weTree.cpp @@ -30,6 +30,21 @@ namespace xtJucePlugin deleteRootItem(); } + void Tree::parentHierarchyChanged() + { + TreeView::parentHierarchyChanged(); + + const auto* parent = getParentComponent(); + if(!parent) + return; + + const auto w = static_cast<float>(parent->getWidth()) / g_waveEditorScale; + const auto h = static_cast<float>(parent->getHeight()) / g_waveEditorScale; + + setTransform(juce::AffineTransform::scale(g_waveEditorScale)); + setSize(static_cast<int>(w), static_cast<int>(h)); + } + void Tree::paint(juce::Graphics& _g) { juce::TreeView::paint(_g); diff --git a/source/xtJucePlugin/weTree.h b/source/xtJucePlugin/weTree.h @@ -15,6 +15,7 @@ namespace xtJucePlugin WaveEditor& getWaveEditor() const { return m_editor; } + void parentHierarchyChanged() override; private: WaveEditor& m_editor; diff --git a/source/xtJucePlugin/weTypes.h b/source/xtJucePlugin/weTypes.h @@ -17,4 +17,6 @@ namespace xtJucePlugin Count }; + + static constexpr float g_waveEditorScale = 2.0f * 1.3f; } diff --git a/source/xtJucePlugin/weWaveCategoryTreeItem.cpp b/source/xtJucePlugin/weWaveCategoryTreeItem.cpp @@ -0,0 +1,54 @@ +#include "weWaveCategoryTreeItem.h" + +#include "weWaveTreeItem.h" +#include "../xtLib/xtMidiTypes.h" + +namespace xtJucePlugin +{ + constexpr const char* const g_categoryNames[] = + { + "ROM", + "User", + "Plugin" + }; + + static_assert(std::size(g_categoryNames) == static_cast<size_t>(WaveCategory::Count)); + + WaveCategoryTreeItem::WaveCategoryTreeItem(WaveEditor& _editor, const WaveCategory _category) : m_editor(_editor), m_category(_category) + { + setText(getCategoryName(_category)); + + switch (_category) + { + case WaveCategory::Rom: + addItems(0, xt::Wave::g_romWaveCount); + break; + case WaveCategory::User: + addItems(xt::Wave::g_firstRamWaveIndex, xt::Wave::g_ramWaveCount); + break; + case WaveCategory::Invalid: + case WaveCategory::Plugin: + case WaveCategory::Count: + default: + break; + } + } + + std::string WaveCategoryTreeItem::getCategoryName(WaveCategory _category) + { + return g_categoryNames[static_cast<uint32_t>(_category)]; + } + + void WaveCategoryTreeItem::addItems(uint32_t _first, uint32_t _count) + { + for(uint32_t i=0; i<_count; ++i) + addItem(i + _first); + + setOpen(true); + } + + void WaveCategoryTreeItem::addItem(const uint32_t _index) + { + addSubItem(new WaveTreeItem(m_editor, m_category, _index)); + } +} diff --git a/source/xtJucePlugin/weWaveCategoryTreeItem.h b/source/xtJucePlugin/weWaveCategoryTreeItem.h @@ -0,0 +1,25 @@ +#pragma once + +#include "weTreeItem.h" +#include "weTypes.h" + +namespace xtJucePlugin +{ + class WaveEditor; + + class WaveCategoryTreeItem : public TreeItem + { + public: + explicit WaveCategoryTreeItem(WaveEditor& _editor, WaveCategory _category); + bool mightContainSubItems() override { return true; } + + static std::string getCategoryName(WaveCategory _category); + + private: + void addItems(uint32_t _first, uint32_t _count); + void addItem(uint32_t _index); + + WaveEditor& m_editor; + const WaveCategory m_category; + }; +} diff --git a/source/xtJucePlugin/xtEditor.cpp b/source/xtJucePlugin/xtEditor.cpp @@ -103,9 +103,8 @@ namespace xtJucePlugin }; #if defined(_DEBUG) && defined(_WIN32) - auto* waveEditorContainer = findComponent("waveEditorContainer"); - m_waveEditor = std::make_unique<WaveEditor>(waveEditorContainer, *this); - getXtController().setWaveEditor(m_waveEditor.get()); + assert(m_waveEditor); + m_waveEditor->initialize(); #else auto* waveEditorButtonParent = findComponent("waveEditorButtonParent"); waveEditorButtonParent->setVisible(false); @@ -180,6 +179,17 @@ namespace xtJucePlugin return jucePluginEditorLib::Editor::createJuceComponent(_button, _object); } + juce::Component* Editor::createJuceComponent(juce::Component* _component, genericUI::UiObject& _object) + { + if(_object.getName() == "waveEditorContainer") + { + m_waveEditor.reset(new WaveEditor(*this)); + getXtController().setWaveEditor(m_waveEditor.get()); + return m_waveEditor.get(); + } + return jucePluginEditorLib::Editor::createJuceComponent(_component, _object); + } + void Editor::setCurrentPart(const uint8_t _part) { m_controller.setCurrentPart(_part); diff --git a/source/xtJucePlugin/xtEditor.h b/source/xtJucePlugin/xtEditor.h @@ -49,6 +49,7 @@ namespace xtJucePlugin genericUI::Button<juce::DrawableButton>* createJuceComponent(genericUI::Button<juce::DrawableButton>*, genericUI::UiObject& _object, const std::string& _name, juce::DrawableButton::ButtonStyle) override; genericUI::Button<juce::TextButton>* createJuceComponent(genericUI::Button<juce::TextButton>*, genericUI::UiObject& _object) override; + juce::Component* createJuceComponent(juce::Component*, genericUI::UiObject& _object) override; void setCurrentPart(uint8_t _part) override; private: diff --git a/source/xtJucePlugin/xtWaveEditor.cpp b/source/xtJucePlugin/xtWaveEditor.cpp @@ -6,19 +6,9 @@ namespace xtJucePlugin { - constexpr float g_scale = 2.0f * 1.3f; - - WaveEditor::WaveEditor(Component* _parent, Editor& _editor) : ComponentMovementWatcher(this), m_editor(_editor), m_data(_editor.getXtController()) + WaveEditor::WaveEditor(Editor& _editor) : ComponentMovementWatcher(this), m_editor(_editor), m_data(_editor.getXtController()) { - setSize(static_cast<int>(static_cast<float>(_parent->getWidth()) / g_scale), static_cast<int>(static_cast<float>(_parent->getHeight()) / g_scale)); - setTransform(juce::AffineTransform::scale(g_scale)); - _parent->addAndMakeVisible(this); - addComponentListener(this); - - m_waveTree.reset(new WaveTree(*this)); - m_waveTree->setSize(170, getHeight()); - addAndMakeVisible(m_waveTree.get()); } WaveEditor::~WaveEditor() @@ -28,26 +18,11 @@ namespace xtJucePlugin removeComponentListener(this); } - void WaveEditor::visibilityChanged() - { - Component::visibilityChanged(); - checkFirstTimeVisible(); - } - - void WaveEditor::parentHierarchyChanged() - { - Component::parentHierarchyChanged(); - checkFirstTimeVisible(); - } - - void WaveEditor::onReceiveWave(const pluginLib::MidiPacket::Data& _data, const std::vector<uint8_t>& _msg) + void WaveEditor::initialize() { - m_data.onReceiveWave(_data, _msg); - } - - void WaveEditor::componentVisibilityChanged() - { - checkFirstTimeVisible(); + auto* waveListParent = m_editor.findComponent("wecWaveList"); + m_waveTree.reset(new WaveTree(*this)); + waveListParent->addAndMakeVisible(m_waveTree.get()); } void WaveEditor::checkFirstTimeVisible() @@ -63,4 +38,9 @@ namespace xtJucePlugin { m_data.requestData(); } + + void WaveEditor::onReceiveWave(const pluginLib::MidiPacket::Data& _data, const std::vector<uint8_t>& _msg) + { + m_data.onReceiveWave(_data, _msg); + } } diff --git a/source/xtJucePlugin/xtWaveEditor.h b/source/xtJucePlugin/xtWaveEditor.h @@ -13,11 +13,10 @@ namespace xtJucePlugin class WaveEditor : public juce::Component, juce::ComponentMovementWatcher { public: - explicit WaveEditor(juce::Component* _parent, Editor& _editor); + explicit WaveEditor(Editor& _editor); ~WaveEditor() override; - void visibilityChanged() override; - void parentHierarchyChanged() override; + void initialize(); void onReceiveWave(const pluginLib::MidiPacket::Data& _data, const std::vector<uint8_t>& _msg); @@ -28,9 +27,9 @@ namespace xtJucePlugin private: // ComponentMovementWatcher - void componentVisibilityChanged() override; - void componentPeerChanged() override {} - void componentMovedOrResized(bool wasMoved, bool wasResized) override {} + void componentVisibilityChanged() override { checkFirstTimeVisible(); } + void componentPeerChanged() override { checkFirstTimeVisible(); } + void componentMovedOrResized(bool wasMoved, bool wasResized) override { checkFirstTimeVisible(); } void checkFirstTimeVisible(); void onFirstTimeVisible();