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

n2xMasterVolume.cpp (996B)


      1 #include "n2xMasterVolume.h"
      2 
      3 #include "n2xController.h"
      4 #include "n2xEditor.h"
      5 
      6 namespace n2xJucePlugin
      7 {
      8 	MasterVolume::MasterVolume(const Editor& _editor) : m_editor(_editor), m_volume(_editor.findComponentT<juce::Slider>("MasterVolume"))
      9 	{
     10 		m_volume->setRange(0.0f, 255.0f);
     11 
     12 		uint8_t currentValue;
     13 
     14 		if(_editor.getN2xController().getKnobState(currentValue, n2x::KnobType::MasterVol))
     15 			m_volume->setValue(currentValue, juce::dontSendNotification);
     16 		else
     17 			m_volume->setValue(255.0f, juce::dontSendNotification);
     18 
     19 		m_volume->onValueChange = [this]
     20 		{
     21 			const auto sysex = n2x::State::createKnobSysex(n2x::KnobType::MasterVol, static_cast<uint8_t>(m_volume->getValue()));
     22 
     23 			m_editor.getN2xController().sendSysEx(sysex);
     24 		};
     25 
     26 		m_onKnobChanged.set(_editor.getN2xController().onKnobChanged, [this](const n2x::KnobType& _type, const unsigned char& _value)
     27 		{
     28 			if(_type != n2x::KnobType::MasterVol)
     29 				return;
     30 			m_volume->setValue(_value, juce::dontSendNotification);
     31 		});
     32 	}
     33 }