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 a19c342280a476e5a8648193bebb6f37973fc1db
parent 1b01bb84a067c7b814bc8506d8eec84bd55a45de
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Fri,  3 May 2024 23:56:43 +0200

reload factory patches if rom is switched

Diffstat:
Msource/jucePluginLib/processor.cpp | 7++++++-
Msource/jucePluginLib/processor.h | 3+++
Msource/virusJucePlugin/PatchManager.cpp | 7++++++-
Msource/virusJucePlugin/VirusController.cpp | 67++++++++++++++++++++++++++++++++++++++++++++-----------------------
Msource/virusJucePlugin/VirusController.h | 3+++
Msource/virusJucePlugin/VirusProcessor.cpp | 1+
6 files changed, 63 insertions(+), 25 deletions(-)

diff --git a/source/jucePluginLib/processor.cpp b/source/jucePluginLib/processor.cpp @@ -27,7 +27,7 @@ namespace pluginLib Processor::~Processor() { - m_controller.reset(); + destroyController(); m_plugin.reset(); m_device.reset(); } @@ -357,6 +357,11 @@ namespace pluginLib return m_device->getPreferredSamplerates(); } + void Processor::destroyController() + { + m_controller.reset(); + } + //============================================================================== void Processor::prepareToPlay(double sampleRate, int samplesPerBlock) { diff --git a/source/jucePluginLib/processor.h b/source/jucePluginLib/processor.h @@ -105,6 +105,9 @@ namespace pluginLib virtual void processBpm(float _bpm) {}; + protected: + void destroyController(); + private: void prepareToPlay(double sampleRate, int maximumExpectedSamplesPerBlock) override; void releaseResources() override; diff --git a/source/virusJucePlugin/PatchManager.cpp b/source/virusJucePlugin/PatchManager.cpp @@ -43,9 +43,14 @@ namespace genericVirusUI const auto& bank = banks[index]; if(_program == bank.size() - 1) - addDataSource(createRomDataSource(index)); + { + const auto romDS = createRomDataSource(index); + removeDataSource(romDS); + addDataSource(romDS); + } } }; + addGroupTreeItemForTag(pluginLib::patchDB::TagType::CustomA, "Virus Model"); addGroupTreeItemForTag(pluginLib::patchDB::TagType::CustomB, "Virus Features"); } diff --git a/source/virusJucePlugin/VirusController.cpp b/source/virusJucePlugin/VirusController.cpp @@ -37,37 +37,21 @@ namespace Virus return g_midiPacketNames[static_cast<uint32_t>(_type)]; } - Controller::Controller(VirusProcessor &p, const virusLib::DeviceModel _defaultModel, unsigned char deviceId) + Controller::Controller(VirusProcessor& p, const virusLib::DeviceModel _defaultModel, unsigned char deviceId) : pluginLib::Controller(p, loadParameterDescriptions(_defaultModel, p)) , m_processor(p) , m_defaultModel(_defaultModel) , m_deviceId(deviceId) + , m_onRomChanged(p.evRomChanged) { - switch(p.getModel()) - { - default: - case virusLib::DeviceModel::A: - case virusLib::DeviceModel::B: - case virusLib::DeviceModel::C: m_singles.resize(8); break; - case virusLib::DeviceModel::Snow: - case virusLib::DeviceModel::TI: - case virusLib::DeviceModel::TI2: - m_singles.resize( - virusLib::ROMFile::getRomBankCount(virusLib::DeviceModel::TI) + - virusLib::ROMFile::getRomBankCount(virusLib::DeviceModel::TI2) + - virusLib::ROMFile::getRomBankCount(virusLib::DeviceModel::Snow) + - 2 - ); break; - } - - registerParams(p); + registerParams(p); // add lambda to enforce updating patches when virus switch from/to multi/single. const auto paramIdx = getParameterIndexByName(g_paramPlayMode); auto* parameter = getParameter(paramIdx); if(parameter) { - parameter->onValueChanged.emplace_back(std::make_pair(0, [this] { + parameter->onValueChanged.emplace_back(0, [this] { const uint8_t prg = isMultiMode() ? 0x0 : virusLib::SINGLE; requestSingle(0, prg); requestMulti(0, prg); @@ -76,13 +60,24 @@ namespace Virus { onMsgDone(); } - })); + }); } + requestTotal(); requestArrangement(); - for(uint8_t i=3; i<=getBankCount(); ++i) - requestSingleBank(i); + // ABC models have different factory presets depending on the used ROM, but for the TI we have all presets from all models loaded anyway so no need to replace them at runtime + if(isTIFamily(m_processor.getModel())) + { + requestRomBanks(); + } + else + { + m_onRomChanged = [this](const virusLib::ROMFile*) + { + requestRomBanks(); + }; + } startTimer(5); } @@ -616,6 +611,32 @@ namespace Virus return sendSysEx(MidiPacketType::RequestArrangement); } + void Controller::requestRomBanks() + { + switch(m_processor.getModel()) + { + default: + case virusLib::DeviceModel::A: + case virusLib::DeviceModel::B: + case virusLib::DeviceModel::C: + m_singles.resize(8); + break; + case virusLib::DeviceModel::Snow: + case virusLib::DeviceModel::TI: + case virusLib::DeviceModel::TI2: + m_singles.resize( + virusLib::ROMFile::getRomBankCount(virusLib::DeviceModel::TI) + + virusLib::ROMFile::getRomBankCount(virusLib::DeviceModel::TI2) + + virusLib::ROMFile::getRomBankCount(virusLib::DeviceModel::Snow) + + 2 + ); + break; + } + + for(uint8_t i=3; i<=getBankCount(); ++i) + requestSingleBank(i); + } + bool Controller::sendSysEx(MidiPacketType _type) const { std::map<pluginLib::MidiDataType, uint8_t> params; diff --git a/source/virusJucePlugin/VirusController.h b/source/virusJucePlugin/VirusController.h @@ -2,6 +2,7 @@ #include "../jucePluginLib/parameterdescriptions.h" #include "../jucePluginLib/controller.h" +#include "../jucePluginLib/event.h" #include "../virusLib/microcontrollerTypes.h" #include "../virusLib/romfile.h" @@ -139,6 +140,7 @@ namespace Virus bool requestTotal() const; bool requestArrangement() const; + void requestRomBanks(); void sendParameterChange(const pluginLib::Parameter& _parameter, uint8_t _value) override; bool sendParameterChange(uint8_t _page, uint8_t _part, uint8_t _index, uint8_t _value) const; @@ -178,5 +180,6 @@ namespace Virus virusLib::BankNumber m_currentBank[16]{}; uint8_t m_currentProgram[16]{}; PresetSource m_currentPresetSource[16]{PresetSource::Unknown}; + pluginLib::EventListener<const virusLib::ROMFile*> m_onRomChanged; }; }; // namespace Virus diff --git a/source/virusJucePlugin/VirusProcessor.cpp b/source/virusJucePlugin/VirusProcessor.cpp @@ -18,6 +18,7 @@ VirusProcessor::VirusProcessor(const BusesProperties& _busesProperties, const ju VirusProcessor::~VirusProcessor() { + destroyController(); destroyEditorState(); }