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 (2115B)


      1 #include "PluginEditorState.h"
      2 
      3 #include "xtEditor.h"
      4 #include "PluginProcessor.h"
      5 
      6 #include "skins.h"
      7 
      8 #include "weGraph.h"
      9 
     10 namespace xtJucePlugin
     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 
     34 	bool PluginEditorState::initAdvancedContextMenu(juce::PopupMenu& _menu, bool _enabled)
     35 	{
     36 		jucePluginEditorLib::PluginEditorState::initAdvancedContextMenu(_menu, _enabled);
     37 
     38 		const auto percent = m_processor.getDspClockPercent();
     39 		const auto hz = m_processor.getDspClockHz();
     40 
     41 		juce::PopupMenu clockMenu;
     42 
     43 		auto makeEntry = [&](const int _percent)
     44 		{
     45 			const auto mhz = hz * _percent / 100 / 1000000;
     46 			std::stringstream ss;
     47 			ss << _percent << "% (" << mhz << " MHz)";
     48 			if(_percent == 100)
     49 				ss << " (Default)";
     50 			clockMenu.addItem(ss.str(), _enabled, percent == _percent, [this, _percent] { m_processor.setDspClockPercent(_percent); });
     51 		};
     52 
     53 		makeEntry(50);
     54 		makeEntry(75);
     55 		makeEntry(100);
     56 		makeEntry(125);
     57 		makeEntry(150);
     58 		makeEntry(200);
     59 
     60 		_menu.addSubMenu("DSP Clock", clockMenu);
     61 
     62 		return true;
     63 	}
     64 
     65 	void PluginEditorState::openMenu(const juce::MouseEvent* _event)
     66 	{
     67 		if (dynamic_cast<Graph*>(_event->eventComponent))
     68 			return;
     69 		jucePluginEditorLib::PluginEditorState::openMenu(_event);
     70 	}
     71 
     72 
     73 	jucePluginEditorLib::Editor* PluginEditorState::createEditor(const jucePluginEditorLib::Skin& _skin)
     74 	{
     75 		return new xtJucePlugin::Editor(m_processor, m_parameterBinding, _skin);
     76 	}
     77 }