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

PluginEditorState.cpp (2021B)


      1 #include "PluginEditorState.h"
      2 
      3 #include "mqEditor.h"
      4 #include "PluginProcessor.h"
      5 
      6 #include "jucePluginEditorLib/midiPorts.h"
      7 
      8 #include "skins.h"
      9 
     10 namespace mqJucePlugin
     11 {
     12 	PluginEditorState::PluginEditorState(AudioPluginAudioProcessor& _processor) : jucePluginEditorLib::PluginEditorState(_processor, _processor.getController(), g_includedSkins)
     13 	{
     14 		loadDefaultSkin();
     15 	}
     16 
     17 	void PluginEditorState::initContextMenu(juce::PopupMenu& _menu)
     18 	{
     19 		jucePluginEditorLib::PluginEditorState::initContextMenu(_menu);
     20 
     21 		auto& p = m_processor;
     22 
     23 		const auto gain = static_cast<int>(std::roundf(p.getOutputGain()));
     24 
     25 		juce::PopupMenu gainMenu;
     26 
     27 		gainMenu.addItem("0 dB (default)", true, gain == 1, [&p] { p.setOutputGain(1); });
     28 		gainMenu.addItem("+6 dB", true, gain == 2, [&p] { p.setOutputGain(2); });
     29 		gainMenu.addItem("+12 dB", true, gain == 4, [&p] { p.setOutputGain(4); });
     30 
     31 		_menu.addSubMenu("Output Gain", gainMenu);
     32 
     33 		jucePluginEditorLib::MidiPorts::createMidiPortsMenu(_menu, p.getMidiPorts());
     34 	}
     35 
     36 	bool PluginEditorState::initAdvancedContextMenu(juce::PopupMenu& _menu, bool _enabled)
     37 	{
     38 		jucePluginEditorLib::PluginEditorState::initAdvancedContextMenu(_menu, _enabled);
     39 
     40 		const auto percent = m_processor.getDspClockPercent();
     41 		const auto hz = m_processor.getDspClockHz();
     42 
     43 		juce::PopupMenu clockMenu;
     44 
     45 		auto makeEntry = [&](const int _percent)
     46 		{
     47 			const auto mhz = hz * _percent / 100 / 1000000;
     48 			std::stringstream ss;
     49 			ss << _percent << "% (" << mhz << " MHz)";
     50 			if(_percent == 100)
     51 				ss << " (Default)";
     52 			clockMenu.addItem(ss.str(), _enabled, percent == _percent, [this, _percent] { m_processor.setDspClockPercent(_percent); });
     53 		};
     54 
     55 		makeEntry(50);
     56 		makeEntry(75);
     57 		makeEntry(100);
     58 		makeEntry(125);
     59 		makeEntry(150);
     60 		makeEntry(200);
     61 
     62 		_menu.addSubMenu("DSP Clock", clockMenu);
     63 
     64 		return true;
     65 	}
     66 
     67 	jucePluginEditorLib::Editor* PluginEditorState::createEditor(const jucePluginEditorLib::Skin& _skin)
     68 	{
     69 		return new mqJucePlugin::Editor(m_processor, m_parameterBinding, _skin);
     70 	}
     71 }