From 0b7e37ca6a3e0861745b4b41197050c0f1916c7e Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Tue, 31 Aug 2010 16:38:15 +0200 Subject: [PATCH] ZynAddSubFX: added LED checkbox to disable forwarding of MIDI CC events After introducing the control knobs it's not always desired to forward all MIDI Control Change events to ZynAddSubFX. Therefore added an LED checkbox which allows to disable forwarding of such events. Closes #3055332. --- plugins/zynaddsubfx/ZynAddSubFx.cpp | 26 ++++++++++++++++++++++---- plugins/zynaddsubfx/ZynAddSubFx.h | 3 +++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/plugins/zynaddsubfx/ZynAddSubFx.cpp b/plugins/zynaddsubfx/ZynAddSubFx.cpp index 7db3922a9..bc30f33d5 100644 --- a/plugins/zynaddsubfx/ZynAddSubFx.cpp +++ b/plugins/zynaddsubfx/ZynAddSubFx.cpp @@ -35,6 +35,7 @@ #include "ZynAddSubFx.h" #include "engine.h" #include "knob.h" +#include "led_checkbox.h" #include "mmp.h" #include "InstrumentPlayHandle.h" #include "InstrumentTrack.h" @@ -116,7 +117,8 @@ ZynAddSubFxInstrument::ZynAddSubFxInstrument( m_bandwidthModel( 64, 0, 127, 1, this, tr( "Bandwidth" ) ), m_fmGainModel( 127, 0, 127, 1, this, tr( "FM Gain" ) ), m_resCenterFreqModel( 64, 0, 127, 1, this, tr( "Resonance Center Frequency" ) ), - m_resBandwidthModel( 64, 0, 127, 1, this, tr( "Resonance Bandwidth" ) ) + m_resBandwidthModel( 64, 0, 127, 1, this, tr( "Resonance Bandwidth" ) ), + m_forwardMidiCcModel( true, this, tr( "Forward MIDI Control Change Events" ) ) { initPlugin(); @@ -152,7 +154,7 @@ ZynAddSubFxInstrument::~ZynAddSubFxInstrument() void ZynAddSubFxInstrument::saveSettings( QDomDocument & _doc, - QDomElement & _this ) + QDomElement & _this ) { m_portamentoModel.saveSettings( _doc, _this, "portamento" ); m_filterFreqModel.saveSettings( _doc, _this, "filterfreq" ); @@ -161,6 +163,7 @@ void ZynAddSubFxInstrument::saveSettings( QDomDocument & _doc, m_fmGainModel.saveSettings( _doc, _this, "fmgain" ); m_resCenterFreqModel.saveSettings( _doc, _this, "rescenterfreq" ); m_resBandwidthModel.saveSettings( _doc, _this, "resbandwidth" ); + m_forwardMidiCcModel.saveSettings( _doc, _this, "forwardmidicc" ); QTemporaryFile tf; if( tf.open() ) @@ -208,6 +211,7 @@ void ZynAddSubFxInstrument::loadSettings( const QDomElement & _this ) m_fmGainModel.loadSettings( _this, "fmgain" ); m_resCenterFreqModel.loadSettings( _this, "rescenterfreq" ); m_resBandwidthModel.loadSettings( _this, "resbandwidth" ); + m_forwardMidiCcModel.loadSettings( _this, "forwardmidicc" ); QDomDocument doc; doc.appendChild( doc.importNode( _this.firstChild(), true ) ); @@ -304,6 +308,14 @@ bool ZynAddSubFxInstrument::handleMidiEvent( const midiEvent & _me, { return true; } + // do not forward external MIDI Control Change events if the according + // LED is not checked + else if( _me.type() == MidiControlChange && + _me.sourcePort() != this && + m_forwardMidiCcModel.value() == false ) + { + return true; + } m_pluginMutex.lock(); if( m_remotePlugin ) @@ -398,7 +410,7 @@ void ZynAddSubFxInstrument::initPlugin() void ZynAddSubFxInstrument::sendControlChange( MidiControllers midiCtl, float value ) { - handleMidiEvent( midiEvent( MidiControlChange, 0, midiCtl, (int) value ), + handleMidiEvent( midiEvent( MidiControlChange, 0, midiCtl, (int) value, this ), midiTime() ); } @@ -457,6 +469,8 @@ ZynAddSubFxView::ZynAddSubFxView( Instrument * _instrument, QWidget * _parent ) m_resBandwidth->setHintText( tr( "Resonance bandwidth:" ) + "", "" ); m_resBandwidth->setLabel( tr( "RES BW" ) ); + m_forwardMidiCC = new ledCheckBox( tr( "Forward MIDI Control Changes" ), this ); + m_toggleUIButton = new QPushButton( tr( "Show GUI" ), this ); m_toggleUIButton->setCheckable( true ); m_toggleUIButton->setChecked( false ); @@ -477,7 +491,9 @@ ZynAddSubFxView::ZynAddSubFxView( Instrument * _instrument, QWidget * _parent ) l->addWidget( m_fmGain, 3, 0 ); l->addWidget( m_resCenterFreq, 3, 1 ); l->addWidget( m_resBandwidth, 3, 2 ); - l->setRowStretch( 4, 10 ); + l->addWidget( m_forwardMidiCC, 4, 0, 1, 4 ); + + l->setRowStretch( 5, 10 ); l->setColumnStretch( 4, 10 ); } @@ -505,6 +521,8 @@ void ZynAddSubFxView::modelChanged() m_resCenterFreq->setModel( &m->m_resCenterFreqModel ); m_resBandwidth->setModel( &m->m_resBandwidthModel ); + m_forwardMidiCC->setModel( &m->m_forwardMidiCcModel ); + toggleUI(); } diff --git a/plugins/zynaddsubfx/ZynAddSubFx.h b/plugins/zynaddsubfx/ZynAddSubFx.h index d97af3a0f..583ca7acd 100644 --- a/plugins/zynaddsubfx/ZynAddSubFx.h +++ b/plugins/zynaddsubfx/ZynAddSubFx.h @@ -40,6 +40,7 @@ class LocalZynAddSubFx; class ZynAddSubFxView; class notePlayHandle; class knob; +class ledCheckBox; class ZynAddSubFxRemotePlugin : public QObject, public RemotePlugin @@ -115,6 +116,7 @@ private: FloatModel m_fmGainModel; FloatModel m_resCenterFreqModel; FloatModel m_resBandwidthModel; + BoolModel m_forwardMidiCcModel; friend class ZynAddSubFxView; @@ -145,6 +147,7 @@ private: knob * m_fmGain; knob * m_resCenterFreq; knob * m_resBandwidth; + ledCheckBox * m_forwardMidiCC; private slots: