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 b8094452200625521ac9526e5d89361d8615a024
parent dbfcb07e5c50f4ff8354ea969aef7754e53b2f89
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Tue,  3 Dec 2024 20:46:28 +0100

convert filetype from enum to own class to be able to extend it

Diffstat:
Msource/jucePluginEditorLib/CMakeLists.txt | 2+-
Asource/jucePluginEditorLib/filetype.cpp | 19+++++++++++++++++++
Asource/jucePluginEditorLib/filetype.h | 23+++++++++++++++++++++++
Msource/jucePluginEditorLib/patchmanager/datasourcetreeitem.cpp | 4+++-
Msource/jucePluginEditorLib/patchmanager/listmodel.cpp | 8+++++---
Msource/jucePluginEditorLib/patchmanager/listmodel.h | 7+++++--
Msource/jucePluginEditorLib/patchmanager/patchmanager.cpp | 6++++--
Msource/jucePluginEditorLib/patchmanager/patchmanager.h | 6+++---
Msource/jucePluginEditorLib/pluginEditor.cpp | 3++-
Msource/jucePluginEditorLib/pluginEditor.h | 5+++--
Dsource/jucePluginEditorLib/types.h | 10----------
Msource/mqJucePlugin/mqEditor.cpp | 5+++--
Msource/mqJucePlugin/mqEditor.h | 2+-
Msource/virusJucePlugin/VirusEditor.cpp | 13+++++++------
Msource/virusJucePlugin/VirusEditor.h | 4++--
15 files changed, 81 insertions(+), 36 deletions(-)

diff --git a/source/jucePluginEditorLib/CMakeLists.txt b/source/jucePluginEditorLib/CMakeLists.txt @@ -3,6 +3,7 @@ project(jucePluginEditorLib VERSION ${CMAKE_PROJECT_VERSION}) set(SOURCES dragAndDropObject.cpp dragAndDropObject.h + filetype.cpp filetype.h focusedParameter.cpp focusedParameter.h focusedParameterTooltip.cpp focusedParameterTooltip.h imagePool.cpp imagePool.h @@ -17,7 +18,6 @@ set(SOURCES pluginEditorState.cpp pluginEditorState.h pluginProcessor.cpp pluginProcessor.h skin.h - types.h ) set(SOURCES_PM diff --git a/source/jucePluginEditorLib/filetype.cpp b/source/jucePluginEditorLib/filetype.cpp @@ -0,0 +1,19 @@ +#include "filetype.h" + +#include "synthLib/os.h" + +namespace jucePluginEditorLib +{ + FileType FileType::Syx("syx"); + FileType FileType::Mid("mid"); + + bool FileType::operator==(const FileType& _other) const + { + return synthLib::lowercase(type) == synthLib::lowercase(_other.type); + } + + bool FileType::operator!=(const FileType& _other) const + { + return !(*this == _other); + } +} diff --git a/source/jucePluginEditorLib/filetype.h b/source/jucePluginEditorLib/filetype.h @@ -0,0 +1,23 @@ +#pragma once + +#include <string> + +namespace jucePluginEditorLib +{ + class FileType + { + public: + static FileType Syx; + static FileType Mid; + + explicit FileType(std::string _type) : type(std::move(_type)) + { + } + + bool operator == (const FileType& _other) const; + bool operator != (const FileType& _other) const; + + private: + std::string type; + }; +} diff --git a/source/jucePluginEditorLib/patchmanager/datasourcetreeitem.cpp b/source/jucePluginEditorLib/patchmanager/datasourcetreeitem.cpp @@ -7,6 +7,8 @@ #include "../pluginEditor.h" +#include "jucePluginEditorLib/filetype.h" + #include "jucePluginLib/patchdb/datasource.h" #include "jucePluginLib/patchdb/search.h" @@ -164,7 +166,7 @@ namespace jucePluginEditorLib::patchManager return menu; }; - menu.addSubMenu("Export...", fileTypeMenu([this](const FileType _fileType) + menu.addSubMenu("Export...", fileTypeMenu([this](const FileType& _fileType) { const auto s = getPatchManager().getSearch(getSearchHandle()); if(s) diff --git a/source/jucePluginEditorLib/patchmanager/listmodel.cpp b/source/jucePluginEditorLib/patchmanager/listmodel.cpp @@ -9,6 +9,8 @@ #include "../pluginEditor.h" +#include "jucePluginEditorLib/filetype.h" + #include "juceUiLib/uiObjectStyle.h" namespace jucePluginEditorLib::patchManager @@ -75,7 +77,7 @@ namespace jucePluginEditorLib::patchManager getPatchManager().setListStatus(static_cast<uint32_t>(selectedPatches.size()), static_cast<uint32_t>(getPatches().size())); } - bool ListModel::exportPresets(const bool _selectedOnly, FileType _fileType) const + bool ListModel::exportPresets(const bool _selectedOnly, const FileType& _fileType) const { Patches patches; @@ -116,8 +118,8 @@ namespace jucePluginEditorLib::patchManager juce::PopupMenu menu; if(hasSelectedPatches) - menu.addSubMenu("Export selected...", fileTypeMenu([this](const FileType _fileType) { exportPresets(true, _fileType); })); - menu.addSubMenu("Export all...", fileTypeMenu([this](const FileType _fileType) { exportPresets(false, _fileType); })); + menu.addSubMenu("Export selected...", fileTypeMenu([this](const FileType& _fileType) { exportPresets(true, _fileType); })); + menu.addSubMenu("Export all...", fileTypeMenu([this](const FileType& _fileType) { exportPresets(false, _fileType); })); if(hasSelectedPatches) { diff --git a/source/jucePluginEditorLib/patchmanager/listmodel.h b/source/jucePluginEditorLib/patchmanager/listmodel.h @@ -6,7 +6,10 @@ #include "juce_gui_basics/juce_gui_basics.h" -#include "../types.h" +namespace jucePluginEditorLib +{ + class FileType; +} namespace pluginLib::patchDB { @@ -141,7 +144,7 @@ namespace jucePluginEditorLib::patchManager void filterPatches(); bool match(const Patch& _patch) const; void setContent(const std::shared_ptr<pluginLib::patchDB::Search>& _search); - bool exportPresets(bool _selectedOnly, FileType _fileType) const; + bool exportPresets(bool _selectedOnly, const FileType& _fileType) const; bool onClicked(const juce::MouseEvent&); void cancelSearch(); diff --git a/source/jucePluginEditorLib/patchmanager/patchmanager.cpp b/source/jucePluginEditorLib/patchmanager/patchmanager.cpp @@ -18,6 +18,8 @@ #include "jucePluginLib/types.h" #include "jucePluginLib/clipboard.h" +#include "jucePluginEditorLib/filetype.h" + #include "dsp56kEmu/logging.h" #if JUCE_MAJOR_VERSION < 8 // they forgot this include but fixed it in version 8+ @@ -604,7 +606,7 @@ namespace jucePluginEditorLib::patchManager g.fillAll(juce::Colour(0,0,0)); } - void PatchManager::exportPresets(const juce::File& _file, const std::vector<pluginLib::patchDB::PatchPtr>& _patches, FileType _fileType) const + void PatchManager::exportPresets(const juce::File& _file, const std::vector<pluginLib::patchDB::PatchPtr>& _patches, const FileType& _fileType) const { #if SYNTHLIB_DEMO_MODE getEditor().showDemoRestrictionMessageBox(); @@ -626,7 +628,7 @@ namespace jucePluginEditorLib::patchManager #endif } - bool PatchManager::exportPresets(std::vector<pluginLib::patchDB::PatchPtr>&& _patches, FileType _fileType) const + bool PatchManager::exportPresets(std::vector<pluginLib::patchDB::PatchPtr>&& _patches, const FileType& _fileType) const { if(_patches.size() > 128) { diff --git a/source/jucePluginEditorLib/patchmanager/patchmanager.h b/source/jucePluginEditorLib/patchmanager/patchmanager.h @@ -11,7 +11,7 @@ namespace jucePluginEditorLib { - enum class FileType; + class FileType; class Editor; } @@ -71,8 +71,8 @@ namespace jucePluginEditorLib::patchManager void paint(juce::Graphics& g) override; - void exportPresets(const juce::File& _file, const std::vector<pluginLib::patchDB::PatchPtr>& _patches, FileType _fileType) const; - bool exportPresets(std::vector<pluginLib::patchDB::PatchPtr>&& _patches, FileType _fileType) const; + void exportPresets(const juce::File& _file, const std::vector<pluginLib::patchDB::PatchPtr>& _patches, const FileType& _fileType) const; + bool exportPresets(std::vector<pluginLib::patchDB::PatchPtr>&& _patches, const FileType& _fileType) const; void resized() override; diff --git a/source/jucePluginEditorLib/pluginEditor.cpp b/source/jucePluginEditorLib/pluginEditor.cpp @@ -1,5 +1,6 @@ #include "pluginEditor.h" +#include "filetype.h" #include "pluginProcessor.h" #include "skin.h" @@ -102,7 +103,7 @@ namespace jucePluginEditorLib } #if !SYNTHLIB_DEMO_MODE - bool Editor::savePresets(const FileType _type, const std::string& _pathName, const std::vector<std::vector<uint8_t>>& _presets) + bool Editor::savePresets(const FileType& _type, const std::string& _pathName, const std::vector<std::vector<uint8_t>>& _presets) { if (_presets.empty()) return false; diff --git a/source/jucePluginEditorLib/pluginEditor.h b/source/jucePluginEditorLib/pluginEditor.h @@ -3,7 +3,6 @@ #include "imagePool.h" #include "parameterOverlays.h" #include "skin.h" -#include "types.h" #include "juceUiLib/editor.h" @@ -26,6 +25,8 @@ namespace pluginLib namespace jucePluginEditorLib { + class FileType; + namespace patchManager { class PatchManager; @@ -53,7 +54,7 @@ namespace jucePluginEditorLib void loadPreset(const std::function<void(const juce::File&)>& _callback); void savePreset(const std::function<void(const juce::File&)>& _callback); #if !SYNTHLIB_DEMO_MODE - static bool savePresets(FileType _type, const std::string& _pathName, const std::vector<std::vector<uint8_t>>& _presets); + static bool savePresets(const FileType& _type, const std::string& _pathName, const std::vector<std::vector<uint8_t>>& _presets); #endif static std::string createValidFilename(FileType& _type, const juce::File& _file); diff --git a/source/jucePluginEditorLib/types.h b/source/jucePluginEditorLib/types.h @@ -1,10 +0,0 @@ -#pragma once - -namespace jucePluginEditorLib -{ - enum class FileType - { - Syx, - Mid - }; -} diff --git a/source/mqJucePlugin/mqEditor.cpp b/source/mqJucePlugin/mqEditor.cpp @@ -10,6 +10,7 @@ #include "mqLib/mqbuildconfig.h" +#include "jucePluginEditorLib/filetype.h" #include "jucePluginEditorLib/focusedParameter.h" namespace mqJucePlugin @@ -146,11 +147,11 @@ namespace mqJucePlugin m_focusedParameter->onMouseEnter(_event); } - void Editor::savePreset(const jucePluginEditorLib::FileType _type) + void Editor::savePreset(const jucePluginEditorLib::FileType& _type) { jucePluginEditorLib::Editor::savePreset([&](const juce::File& _file) { - jucePluginEditorLib::FileType type = _type; + auto type = _type; const auto file = createValidFilename(type, _file); const auto part = m_controller.getCurrentPart(); diff --git a/source/mqJucePlugin/mqEditor.h b/source/mqJucePlugin/mqEditor.h @@ -45,7 +45,7 @@ namespace mqJucePlugin private: void mouseEnter(const juce::MouseEvent& _event) override; - void savePreset(jucePluginEditorLib::FileType _type); + void savePreset(const jucePluginEditorLib::FileType& _type); void onBtSave(); void onBtPresetPrev(); diff --git a/source/virusJucePlugin/VirusEditor.cpp b/source/virusJucePlugin/VirusEditor.cpp @@ -8,9 +8,10 @@ #include "VirusController.h" #include "jucePluginLib/parameterbinding.h" +#include "jucePluginLib/pluginVersion.h" +#include "jucePluginEditorLib/filetype.h" #include "jucePluginEditorLib/patchmanager/savepatchdesc.h" -#include "jucePluginLib/pluginVersion.h" #include "synthLib/os.h" @@ -315,14 +316,14 @@ namespace genericVirusUI _menu.addSubMenu(_name, subMenu); }; - addEntry(menu, "Export Current Single (Edit Buffer)", [this](jucePluginEditorLib::FileType _type) + addEntry(menu, "Export Current Single (Edit Buffer)", [this](const jucePluginEditorLib::FileType& _type) { savePresets(SaveType::CurrentSingle, _type); }); if(getController().isMultiMode()) { - addEntry(menu, "Export Arrangement (Multi + 16 Singles)", [this](jucePluginEditorLib::FileType _type) + addEntry(menu, "Export Arrangement (Multi + 16 Singles)", [this](const jucePluginEditorLib::FileType& _type) { savePresets(SaveType::Arrangement, _type); }); @@ -331,7 +332,7 @@ namespace genericVirusUI juce::PopupMenu banksMenu; for(uint8_t b=0; b<static_cast<uint8_t>(getController().getBankCount()); ++b) { - addEntry(banksMenu, getController().getBankName(b), [this, b](const jucePluginEditorLib::FileType _type) + addEntry(banksMenu, getController().getBankName(b), [this, b](const jucePluginEditorLib::FileType& _type) { savePresets(SaveType::Bank, _type, b); }); @@ -444,7 +445,7 @@ namespace genericVirusUI getController().requestArrangement(); } - void VirusEditor::savePresets(SaveType _saveType, jucePluginEditorLib::FileType _fileType, uint8_t _bankNumber/* = 0*/) + void VirusEditor::savePresets(SaveType _saveType, const jucePluginEditorLib::FileType& _fileType, uint8_t _bankNumber/* = 0*/) { Editor::savePreset([this, _saveType, _bankNumber, _fileType](const juce::File& _result) { @@ -454,7 +455,7 @@ namespace genericVirusUI }); } - bool VirusEditor::savePresets(const std::string& _pathName, SaveType _saveType, jucePluginEditorLib::FileType _fileType, uint8_t _bankNumber/* = 0*/) const + bool VirusEditor::savePresets(const std::string& _pathName, SaveType _saveType, const jucePluginEditorLib::FileType& _fileType, uint8_t _bankNumber/* = 0*/) const { #if SYNTHLIB_DEMO_MODE return false; diff --git a/source/virusJucePlugin/VirusEditor.h b/source/virusJucePlugin/VirusEditor.h @@ -81,8 +81,8 @@ namespace genericVirusUI void setPlayMode(uint8_t _playMode); - void savePresets(SaveType _saveType, jucePluginEditorLib::FileType _fileType, uint8_t _bankNumber = 0); - bool savePresets(const std::string& _pathName, SaveType _saveType, jucePluginEditorLib::FileType _fileType, uint8_t _bankNumber = 0) const; + void savePresets(SaveType _saveType, const jucePluginEditorLib::FileType& _fileType, uint8_t _bankNumber = 0); + bool savePresets(const std::string& _pathName, SaveType _saveType, const jucePluginEditorLib::FileType& _fileType, uint8_t _bankNumber = 0) const; virus::VirusProcessor& m_processor; pluginLib::ParameterBinding& m_parameterBinding;