commit 718ca15f5a1f890251c3454cd6f5e86d71ac5651
parent 68d18830c2efb23fc05788f16930330737912b53
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Sun, 5 May 2024 18:33:55 +0200
added Panic menu
Diffstat:
4 files changed, 58 insertions(+), 0 deletions(-)
diff --git a/doc/changelog.txt b/doc/changelog.txt
@@ -5,6 +5,7 @@ Release Notes
Framework:
- [Imp] Added warning message if running under Rosetta as performance will be bad
+- [Imp] Added 'Panic' menu to send All Notes Off / reboot device
- [Fix] Do not crash if a skin cannot be loaded
diff --git a/source/jucePluginEditorLib/pluginEditorState.cpp b/source/jucePluginEditorLib/pluginEditorState.cpp
@@ -292,6 +292,40 @@ void PluginEditorState::openMenu()
initContextMenu(menu);
{
+ menu.addSeparator();
+
+ juce::PopupMenu panicMenu;
+
+ panicMenu.addItem("Send 'All Notes Off'", [this]
+ {
+ for(uint8_t c=0; c<16; ++c)
+ {
+ synthLib::SMidiEvent ev(synthLib::MidiEventSource::Editor, synthLib::M_CONTROLCHANGE + c, synthLib::MC_ALLNOTESOFF);
+ m_processor.addMidiEvent(ev);
+ }
+ });
+
+ panicMenu.addItem("Send 'Note Off' for every Note", [this]
+ {
+ for(uint8_t c=0; c<16; ++c)
+ {
+ for(uint8_t n=0; n<128; ++n)
+ {
+ synthLib::SMidiEvent ev(synthLib::MidiEventSource::Editor, synthLib::M_NOTEOFF + c, n, 64, n * 256);
+ m_processor.addMidiEvent(ev);
+ }
+ }
+ });
+
+ panicMenu.addItem("Reboot Device", [this]
+ {
+ m_processor.rebootDevice();
+ });
+
+ menu.addSubMenu("Panic", panicMenu);
+ }
+
+ {
const auto allowAdvanced = config.getBoolValue("allow_advanced_options", false);
juce::PopupMenu advancedMenu;
diff --git a/source/jucePluginLib/processor.cpp b/source/jucePluginLib/processor.cpp
@@ -703,4 +703,25 @@ namespace pluginLib
{
return 0.0f;
}
+
+ bool Processor::rebootDevice()
+ {
+ try
+ {
+ synthLib::Device* device = createDevice();
+ getPlugin().setDevice(device);
+ (void)m_device.release();
+ m_device.reset(device);
+
+ return true;
+ }
+ catch(const synthLib::DeviceException& e)
+ {
+ juce::NativeMessageBox::showMessageBox(juce::MessageBoxIconType::WarningIcon,
+ "Device creation failed:",
+ std::string("Failed to create device:\n\n") +
+ e.what() + "\n\n");
+ return false;
+ }
+ }
}
diff --git a/source/jucePluginLib/processor.h b/source/jucePluginLib/processor.h
@@ -105,6 +105,8 @@ namespace pluginLib
virtual void processBpm(float _bpm) {};
+ bool rebootDevice();
+
protected:
void destroyController();