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

n2xOutputMode.cpp (1953B)


      1 #include "n2xOutputMode.h"
      2 
      3 #include "n2xController.h"
      4 #include "n2xEditor.h"
      5 
      6 namespace n2xJucePlugin
      7 {
      8 	static constexpr const char* g_outModesAB[] =
      9 	{
     10 		"A & B Mono/Stereo",
     11 		"A & B Mono",
     12 		"A & B Alternating",
     13 		"A to A / B to B"
     14 	};
     15 
     16 	static constexpr const char* g_outModesCD[] =
     17 	{
     18 		"Same as A & B",
     19 		"C & D Mono/Stereo",
     20 		"C & D Mono",
     21 		"C & D Alternating",
     22 		"C to C / D to D"
     23 	};
     24 
     25 	OutputMode::OutputMode(const Editor& _editor)
     26 	: m_outAB(_editor.findComponentT<juce::ComboBox>("PerfOutModeAB"))
     27 	, m_outCD(_editor.findComponentT<juce::ComboBox>("PerfOutModeCD"))
     28 	, m_parameter(_editor.getN2xController().getParameter("PerfOutModeABCD", 0))
     29 	{
     30 		int id = 1;
     31 		for (const auto* mode : g_outModesAB)
     32 			m_outAB->addItem(mode, id++);
     33 
     34 		id = 1;
     35 		for (const auto* mode : g_outModesCD)
     36 			m_outCD->addItem(mode, id++);
     37 
     38 		m_outAB->onChange = [this]
     39 		{
     40 			setOutModeAB(static_cast<uint8_t>(m_outAB->getSelectedItemIndex()));
     41 		};
     42 
     43 		m_outCD->onChange = [this]
     44 		{
     45 			setOutModeCD(static_cast<uint8_t>(m_outCD->getSelectedItemIndex()));
     46 		};
     47 
     48 		m_onOutputModeChanged.set(m_parameter, [this](pluginLib::Parameter* const& _parameter)
     49 		{
     50 			onOutModeChanged(_parameter->getUnnormalizedValue());
     51 		});
     52 	}
     53 
     54 	void OutputMode::setOutModeAB(const uint8_t _mode)
     55 	{
     56 		auto v = m_parameter->getUnnormalizedValue();
     57 		v &= 0xf0;
     58 		v |= _mode;
     59 		m_parameter->setUnnormalizedValueNotifyingHost(v, pluginLib::Parameter::Origin::Ui);
     60 	}
     61 	 
     62 	void OutputMode::setOutModeCD(const uint8_t _mode)
     63 	{
     64 		auto v = m_parameter->getUnnormalizedValue();
     65 		v &= 0x0f;
     66 		v |= _mode<<4;
     67 		m_parameter->setUnnormalizedValueNotifyingHost(v, pluginLib::Parameter::Origin::Ui);
     68 	}
     69 
     70 	void OutputMode::onOutModeChanged(pluginLib::ParamValue _paramValue)
     71 	{
     72 		const auto ab = _paramValue & 0xf;
     73 		const auto cd = (_paramValue >> 4) & 0xf;
     74 
     75 		m_outAB->setSelectedItemIndex(ab, juce::dontSendNotification);
     76 		m_outCD->setSelectedItemIndex(cd, juce::dontSendNotification);
     77 	}
     78 }