diff --git a/data/themes/default/midi_in.png b/data/themes/default/midi_in.png deleted file mode 100644 index 44808ede8..000000000 Binary files a/data/themes/default/midi_in.png and /dev/null differ diff --git a/data/themes/default/midi_out.png b/data/themes/default/midi_out.png deleted file mode 100644 index a7e2a0923..000000000 Binary files a/data/themes/default/midi_out.png and /dev/null differ diff --git a/include/group_box.h b/include/group_box.h index 40bbeac26..a77e1250e 100644 --- a/include/group_box.h +++ b/include/group_box.h @@ -44,6 +44,11 @@ public: virtual void modelChanged( void ); + pixmapButton * ledButton( void ) + { + return m_led; + } + protected: virtual void mousePressEvent( QMouseEvent * _me ); diff --git a/include/instrument_midi_io_view.h b/include/instrument_midi_io_view.h index 6dc52e883..d9b1128b8 100644 --- a/include/instrument_midi_io_view.h +++ b/include/instrument_midi_io_view.h @@ -32,8 +32,7 @@ #include "mv_base.h" -class tabWidget; -class ledCheckBox; +class groupBox; class lcdSpinBox; class midiPortMenu; class QToolButton; @@ -49,14 +48,15 @@ public: private: virtual void modelChanged( void ); - tabWidget * m_setupTabWidget; + groupBox * m_midiInputGroupBox; lcdSpinBox * m_inputChannelSpinBox; - lcdSpinBox * m_outputChannelSpinBox; - ledCheckBox * m_receiveCheckBox; - ledCheckBox * m_sendCheckBox; - ledCheckBox * m_defaultVelocityInCheckBox; - ledCheckBox * m_defaultVelocityOutCheckBox; + lcdSpinBox * m_fixedInputVelocitySpinBox; QToolButton * m_rpBtn; + + groupBox * m_midiOutputGroupBox; + lcdSpinBox * m_outputChannelSpinBox; + lcdSpinBox * m_fixedOutputVelocitySpinBox; + lcdSpinBox * m_outputProgramSpinBox; QToolButton * m_wpBtn; } ; diff --git a/include/midi.h b/include/midi.h index cad10c60b..dbbc15898 100644 --- a/include/midi.h +++ b/include/midi.h @@ -81,6 +81,7 @@ enum MidiMetaEvents const int MidiChannelCount = 16; const int MidiControllerCount = 128; +const int MidiProgramCount = 128; const int MidiMaxVelocity = 127; diff --git a/include/midi_port.h b/include/midi_port.h index 61073b313..05847e1b5 100644 --- a/include/midi_port.h +++ b/include/midi_port.h @@ -53,6 +53,12 @@ class midiPort : public model, public serializingObject m_inputControllerModel); mapPropertyFromModel(int,outputController,setOutputController, m_outputControllerModel); + mapPropertyFromModel(int,fixedInputVelocity,setFixedInputVelocity, + m_fixedInputVelocityModel); + mapPropertyFromModel(int,fixedOutputVelocity,setFixedOutputVelocity, + m_fixedOutputVelocityModel); + mapPropertyFromModel(int,outputProgram,setOutputProgram, + m_outputProgramModel); mapPropertyFromModel(bool,isReadable,setReadable,m_readableModel); mapPropertyFromModel(bool,isWritable,setWritable,m_writableModel); public: @@ -73,11 +79,6 @@ public: Modes _mode = Disabled ); virtual ~midiPort(); - inline const QString & name( void ) const - { - return( m_name ); - } - void setName( const QString & _name ); inline Modes mode( void ) const @@ -97,16 +98,6 @@ public: return( mode() == Output || mode() == Duplex ); } - inline void enableDefaultVelocityForInEvents( const bool _on ) - { - m_defaultVelocityInEnabledModel.setValue( _on ); - } - - inline void enableDefaultVelocityForOutEvents( const bool _on ) - { - m_defaultVelocityOutEnabledModel.setValue( _on ); - } - void processInEvent( const midiEvent & _me, const midiTime & _time ); void processOutEvent( const midiEvent & _me, const midiTime & _time ); @@ -139,12 +130,6 @@ public: midiPortMenu * m_writablePortsMenu; -signals: - void readablePortsChanged( void ); - void writeablePortsChanged( void ); - void modeChanged( void ); - - public slots: void updateMidiPortMode( void ); @@ -152,24 +137,24 @@ public slots: private slots: void updateReadablePorts( void ); void updateWriteablePorts( void ); + void updateOutputProgram( void ); private: midiClient * m_midiClient; midiEventProcessor * m_midiEventProcessor; - QString m_name; // TODO: replace with model-name-property! - Modes m_mode; intModel m_inputChannelModel; intModel m_outputChannelModel; intModel m_inputControllerModel; intModel m_outputControllerModel; + intModel m_fixedInputVelocityModel; + intModel m_fixedOutputVelocityModel; + intModel m_outputProgramModel; boolModel m_readableModel; boolModel m_writableModel; - boolModel m_defaultVelocityInEnabledModel; - boolModel m_defaultVelocityOutEnabledModel; map m_readablePorts; map m_writablePorts; @@ -178,6 +163,13 @@ private: friend class controllerConnectionDialog; friend class instrumentMidiIOView; + +signals: + void readablePortsChanged( void ); + void writeablePortsChanged( void ); + void modeChanged( void ); + + } ; diff --git a/src/core/midi/midi_port.cpp b/src/core/midi/midi_port.cpp index cd270f37a..44896e798 100644 --- a/src/core/midi/midi_port.cpp +++ b/src/core/midi/midi_port.cpp @@ -1,5 +1,3 @@ -#ifndef SINGLE_SOURCE_COMPILE - /* * midi_port.cpp - abstraction of MIDI-ports which are part of LMMS's MIDI- * sequencing system @@ -42,7 +40,6 @@ midiPort::midiPort( const QString & _name, midiClient * _mc, m_writablePortsMenu( NULL ), m_midiClient( _mc ), m_midiEventProcessor( _mep ), - m_name( _name ), m_mode( _mode ), m_inputChannelModel( 0, 0, MidiChannelCount, this, tr( "Input channel" ) ), @@ -52,12 +49,14 @@ midiPort::midiPort( const QString & _name, midiClient * _mc, tr( "Input controller" ) ), m_outputControllerModel( 0, 0, MidiControllerCount, this, tr( "Output controller" ) ), - m_readableModel( FALSE, this, tr( "Receive MIDI-events" ) ), - m_writableModel( FALSE, this, tr( "Send MIDI-events" ) ), - m_defaultVelocityInEnabledModel( FALSE, this, - tr( "Default input velocity" ) ), - m_defaultVelocityOutEnabledModel( FALSE, this, - tr( "Default output velocity" ) ) + m_fixedInputVelocityModel( -1, -1, MidiMaxVelocity, this, + tr( "Fixed input velocity" ) ), + m_fixedOutputVelocityModel( -1, -1, MidiMaxVelocity, this, + tr( "Fixed output velocity" ) ), + m_outputProgramModel( 1, 1, MidiProgramCount, this, + tr( "Output MIDI program" ) ), + m_readableModel( false, this, tr( "Receive MIDI-events" ) ), + m_writableModel( false, this, tr( "Send MIDI-events" ) ) { m_midiClient->addPort( this ); @@ -68,11 +67,13 @@ midiPort::midiPort( const QString & _name, midiClient * _mc, this, SLOT( updateMidiPortMode() ) ); connect( &m_writableModel, SIGNAL( dataChanged() ), this, SLOT( updateMidiPortMode() ) ); + connect( &m_outputProgramModel, SIGNAL( dataChanged() ), + this, SLOT( updateOutputProgram() ) ); // when using with non-raw-clients we can provide buttons showing // our port-menus when being clicked - if( m_midiClient->isRaw() == FALSE ) + if( m_midiClient->isRaw() == false ) { updateReadablePorts(); updateWriteablePorts(); @@ -93,8 +94,8 @@ midiPort::midiPort( const QString & _name, midiClient * _mc, midiPort::~midiPort() { // unsubscribe ports - m_readableModel.setValue( FALSE ); - m_writableModel.setValue( FALSE ); + m_readableModel.setValue( false ); + m_writableModel.setValue( false ); // and finally unregister ourself m_midiClient->removePort( this ); @@ -105,7 +106,7 @@ midiPort::~midiPort() void midiPort::setName( const QString & _name ) { - m_name = _name; + setDisplayName( _name ); m_midiClient->applyPortName( this ); } @@ -137,10 +138,9 @@ void midiPort::processInEvent( const midiEvent & _me, const midiTime & _time ) } } midiEvent ev = _me; - if( m_defaultVelocityInEnabledModel.value() == true && - _me.velocity() > 0 ) + if( fixedInputVelocity() >= 0 && _me.velocity() > 0 ) { - ev.velocity() = MidiMaxVelocity; + ev.velocity() = fixedInputVelocity(); } m_midiEventProcessor->processInEvent( ev, _time ); } @@ -152,8 +152,7 @@ void midiPort::processInEvent( const midiEvent & _me, const midiTime & _time ) void midiPort::processOutEvent( const midiEvent & _me, const midiTime & _time ) { // mask event - if( outputEnabled() && - ( outputChannel() == _me.m_channel && outputChannel() != 0 ) ) + if( outputEnabled() && outputChannel() == _me.m_channel ) { midiEvent ev = _me; // we use/display MIDI channels 1...16 but we need 0...15 for @@ -162,10 +161,11 @@ void midiPort::processOutEvent( const midiEvent & _me, const midiTime & _time ) { --ev.m_channel; } - if( m_defaultVelocityOutEnabledModel.value() == true && - _me.velocity() > 0 ) + if( fixedOutputVelocity() >= 0 && _me.velocity() > 0 && + ( _me.m_type == MidiNoteOn || + _me.m_type == MidiKeyPressure ) ) { - ev.velocity() = MidiMaxVelocity; + ev.velocity() = fixedOutputVelocity(); } m_midiClient->processOutEvent( ev, _time, this ); } @@ -180,11 +180,13 @@ void midiPort::saveSettings( QDomDocument & _doc, QDomElement & _this ) m_outputChannelModel.saveSettings( _doc, _this, "outputchannel" ); m_inputControllerModel.saveSettings( _doc, _this, "inputcontroller" ); m_outputControllerModel.saveSettings( _doc, _this, "outputcontroller" ); + m_fixedInputVelocityModel.saveSettings( _doc, _this, + "fixedinputvelocity" ); + m_fixedOutputVelocityModel.saveSettings( _doc, _this, + "fixedoutputvelocity" ); + m_outputProgramModel.saveSettings( _doc, _this, "outputprogram" ); m_readableModel.saveSettings( _doc, _this, "readable" ); m_writableModel.saveSettings( _doc, _this, "writable" ); - m_defaultVelocityInEnabledModel.saveSettings( _doc, _this, "defvelin" ); - m_defaultVelocityOutEnabledModel.saveSettings( _doc, _this, - "defvelout" ); if( inputEnabled() ) { @@ -234,10 +236,11 @@ void midiPort::loadSettings( const QDomElement & _this ) m_outputChannelModel.loadSettings( _this, "outputchannel" ); m_inputControllerModel.loadSettings( _this, "inputcontroller" ); m_outputControllerModel.loadSettings( _this, "outputcontroller" ); + m_fixedInputVelocityModel.loadSettings( _this, "fixedinputvelocity" ); + m_fixedOutputVelocityModel.loadSettings( _this, "fixedoutputvelocity" ); + m_outputProgramModel.loadSettings( _this, "outputprogram" ); m_readableModel.loadSettings( _this, "readable" ); m_writableModel.loadSettings( _this, "writable" ); - m_defaultVelocityInEnabledModel.loadSettings( _this, "defvelin" ); - m_defaultVelocityOutEnabledModel.loadSettings( _this, "defvelout" ); // restore connections @@ -271,6 +274,34 @@ void midiPort::loadSettings( const QDomElement & _this ) +void midiPort::subscribeReadablePort( const QString & _port, bool _subscribe ) +{ + m_readablePorts[_port] = _subscribe; + // make sure, MIDI-port is configured for input + if( _subscribe == true && !inputEnabled() ) + { + m_readableModel.setValue( true ); + } + m_midiClient->subscribeReadablePort( this, _port, _subscribe ); +} + + + + +void midiPort::subscribeWriteablePort( const QString & _port, bool _subscribe ) +{ + m_writablePorts[_port] = _subscribe; + // make sure, MIDI-port is configured for output + if( _subscribe == true && !outputEnabled() ) + { + m_writableModel.setValue( true ); + } + m_midiClient->subscribeWriteablePort( this, _port, _subscribe ); +} + + + + void midiPort::updateMidiPortMode( void ) { // this small lookup-table makes everything easier @@ -290,7 +321,7 @@ void midiPort::updateMidiPortMode( void ) // subscribed? if( it.value() ) { - subscribeReadablePort( it.key(), FALSE ); + subscribeReadablePort( it.key(), false ); } } } @@ -303,7 +334,7 @@ void midiPort::updateMidiPortMode( void ) // subscribed? if( it.value() ) { - subscribeWriteablePort( it.key(), FALSE ); + subscribeWriteablePort( it.key(), false ); } } } @@ -325,7 +356,7 @@ void midiPort::updateReadablePorts( void ) for( midiPort::map::iterator it = m_readablePorts.begin(); it != m_readablePorts.end(); ++it ) { - if( it.value() == TRUE ) + if( it.value() == true ) { selected_ports.push_back( it.key() ); } @@ -351,7 +382,7 @@ void midiPort::updateWriteablePorts( void ) for( midiPort::map::iterator it = m_writablePorts.begin(); it != m_writablePorts.end(); ++it ) { - if( it.value() == TRUE ) + if( it.value() == true ) { selected_ports.push_back( it.key() ); } @@ -370,34 +401,14 @@ void midiPort::updateWriteablePorts( void ) -void midiPort::subscribeReadablePort( const QString & _port, bool _subscribe ) +void midiPort::updateOutputProgram( void ) { - m_readablePorts[_port] = _subscribe; - // make sure, MIDI-port is configured for input - if( _subscribe == TRUE && !inputEnabled() ) - { - m_readableModel.setValue( TRUE ); - } - m_midiClient->subscribeReadablePort( this, _port, _subscribe ); -} - - - - -void midiPort::subscribeWriteablePort( const QString & _port, bool _subscribe ) -{ - m_writablePorts[_port] = _subscribe; - // make sure, MIDI-port is configured for output - if( _subscribe == TRUE && !outputEnabled() ) - { - m_writableModel.setValue( TRUE ); - } - m_midiClient->subscribeWriteablePort( this, _port, _subscribe ); + processOutEvent( midiEvent( MidiProgramChange, + outputChannel(), + outputProgram()-1 ), midiTime( 0 ) ); } #include "moc_midi_port.cxx" - -#endif diff --git a/src/gui/widgets/instrument_midi_io_view.cpp b/src/gui/widgets/instrument_midi_io_view.cpp index df69b2839..7149bc98e 100644 --- a/src/gui/widgets/instrument_midi_io_view.cpp +++ b/src/gui/widgets/instrument_midi_io_view.cpp @@ -1,5 +1,3 @@ -#ifndef SINGLE_SOURCE_COMPILE - /* * instrument_midi_io_view.cpp - MIDI-IO-View * @@ -32,11 +30,10 @@ #include "instrument_midi_io_view.h" #include "midi_port_menu.h" #include "embed.h" +#include "group_box.h" #include "gui_templates.h" -#include "led_checkbox.h" #include "lcd_spinbox.h" #include "midi_client.h" -#include "tab_widget.h" #include "tooltip.h" @@ -47,64 +44,69 @@ instrumentMidiIOView::instrumentMidiIOView( QWidget * _parent ) : m_rpBtn( NULL ), m_wpBtn( NULL ) { - m_setupTabWidget = new tabWidget( - tr( "MIDI SETUP FOR THIS INSTRUMENT" ), - this ); - m_setupTabWidget->setGeometry( 4, 5, 242, 200 ); + m_midiInputGroupBox = new groupBox( tr( "ENABLE MIDI INPUT" ), this ); + m_midiInputGroupBox->setGeometry( 4, 5, 242, 80 ); - m_inputChannelSpinBox = new lcdSpinBox( 3, m_setupTabWidget ); + m_inputChannelSpinBox = new lcdSpinBox( 3, m_midiInputGroupBox ); m_inputChannelSpinBox->addTextForValue( 0, "---" ); m_inputChannelSpinBox->setLabel( tr( "CHANNEL" ) ); - m_inputChannelSpinBox->move( 28, 52 ); - m_inputChannelSpinBox->setEnabled( FALSE ); + m_inputChannelSpinBox->move( 16, 32 ); + m_inputChannelSpinBox->setEnabled( false ); + m_fixedInputVelocitySpinBox = new lcdSpinBox( 3, m_midiInputGroupBox ); + m_fixedInputVelocitySpinBox->addTextForValue( -1, "---" ); + m_fixedInputVelocitySpinBox->setLabel( tr( "VELOCITY" ) ); + m_fixedInputVelocitySpinBox->move( 64, 32 ); + m_fixedInputVelocitySpinBox->setEnabled( false ); - - m_outputChannelSpinBox = new lcdSpinBox( 3, m_setupTabWidget ); - m_outputChannelSpinBox->setLabel( tr( "CHANNEL" ) ); - m_outputChannelSpinBox->move( 28, 132 ); - m_outputChannelSpinBox->setEnabled( FALSE ); - - - m_receiveCheckBox = new ledCheckBox( tr( "Receive MIDI-events" ), - m_setupTabWidget ); - m_receiveCheckBox->move( 10, 34 ); - // enabling/disabling widgets is UI-stuff thus we do not use model here - connect( m_receiveCheckBox, SIGNAL( toggled( bool ) ), + connect( m_midiInputGroupBox->ledButton(), SIGNAL( toggled( bool ) ), m_inputChannelSpinBox, SLOT( setEnabled( bool ) ) ); + connect( m_midiInputGroupBox->ledButton(), SIGNAL( toggled( bool ) ), + m_fixedInputVelocitySpinBox, SLOT( setEnabled( bool ) ) ); - m_defaultVelocityInCheckBox = new ledCheckBox( tr( "Equal velocity" ), - m_setupTabWidget ); - m_defaultVelocityInCheckBox->move( 28, 86 ); + m_midiOutputGroupBox = new groupBox( tr( "ENABLE MIDI OUTPUT" ), this ); + m_midiOutputGroupBox->setGeometry( 4, 90, 242, 80 ); - m_sendCheckBox = new ledCheckBox( tr( "Send MIDI-events" ), - m_setupTabWidget ); - m_sendCheckBox->move( 10, 114 ); - connect( m_sendCheckBox, SIGNAL( toggled( bool ) ), + m_outputChannelSpinBox = new lcdSpinBox( 3, m_midiOutputGroupBox ); + m_outputChannelSpinBox->setLabel( tr( "CHANNEL" ) ); + m_outputChannelSpinBox->move( 16, 32 ); + m_outputChannelSpinBox->setEnabled( false ); + + m_fixedOutputVelocitySpinBox = new lcdSpinBox( 3, m_midiOutputGroupBox ); + m_fixedOutputVelocitySpinBox->addTextForValue( -1, "---" ); + m_fixedOutputVelocitySpinBox->setLabel( tr( "VELOCITY" ) ); + m_fixedOutputVelocitySpinBox->move( 64, 32 ); + m_fixedOutputVelocitySpinBox->setEnabled( false ); + + m_outputProgramSpinBox = new lcdSpinBox( 3, m_midiOutputGroupBox ); + m_outputProgramSpinBox->setLabel( tr( "PROGRAM" ) ); + m_outputProgramSpinBox->move( 112, 32 ); + m_outputProgramSpinBox->setEnabled( false ); + + connect( m_midiOutputGroupBox->ledButton(), SIGNAL( toggled( bool ) ), m_outputChannelSpinBox, SLOT( setEnabled( bool ) ) ); - - - m_defaultVelocityOutCheckBox = new ledCheckBox( tr( "Equal velocity" ), - m_setupTabWidget ); - m_defaultVelocityOutCheckBox->move( 28, 166 ); + connect( m_midiOutputGroupBox->ledButton(), SIGNAL( toggled( bool ) ), + m_fixedOutputVelocitySpinBox, SLOT( setEnabled( bool ) ) ); + connect( m_midiOutputGroupBox->ledButton(), SIGNAL( toggled( bool ) ), + m_outputProgramSpinBox, SLOT( setEnabled( bool ) ) ); if( !engine::getMixer()->getMidiClient()->isRaw() ) { - m_rpBtn = new QToolButton( m_setupTabWidget ); + m_rpBtn = new QToolButton( m_midiInputGroupBox ); m_rpBtn->setText( tr( "MIDI-devices to receive " "MIDI-events from" ) ); - m_rpBtn->setIcon( embed::getIconPixmap( "midi_in" ) ); - m_rpBtn->setGeometry( 186, 34, 40, 40 ); + m_rpBtn->setIcon( embed::getIconPixmap( "piano" ) ); + m_rpBtn->setGeometry( 186, 24, 32, 32 ); m_rpBtn->setPopupMode( QToolButton::InstantPopup ); - m_wpBtn = new QToolButton( m_setupTabWidget ); + m_wpBtn = new QToolButton( m_midiOutputGroupBox ); m_wpBtn->setText( tr( "MIDI-devices to send MIDI-events " "to" ) ); - m_wpBtn->setIcon( embed::getIconPixmap( "midi_out" ) ); - m_wpBtn->setGeometry( 186, 114, 40, 40 ); + m_wpBtn->setIcon( embed::getIconPixmap( "piano" ) ); + m_wpBtn->setGeometry( 186, 24, 32, 32 ); m_wpBtn->setPopupMode( QToolButton::InstantPopup ); } } @@ -122,14 +124,17 @@ instrumentMidiIOView::~instrumentMidiIOView() void instrumentMidiIOView::modelChanged( void ) { midiPort * mp = castModel(); + + m_midiInputGroupBox->setModel( &mp->m_readableModel ); m_inputChannelSpinBox->setModel( &mp->m_inputChannelModel ); + m_fixedInputVelocitySpinBox->setModel( &mp->m_fixedInputVelocityModel ); + + m_midiOutputGroupBox->setModel( &mp->m_writableModel ); m_outputChannelSpinBox->setModel( &mp->m_outputChannelModel ); - m_receiveCheckBox->setModel( &mp->m_readableModel ); - m_defaultVelocityInCheckBox->setModel( - &mp->m_defaultVelocityInEnabledModel ); - m_sendCheckBox->setModel( &mp->m_writableModel ); - m_defaultVelocityOutCheckBox->setModel( - &mp->m_defaultVelocityOutEnabledModel ); + m_fixedOutputVelocitySpinBox->setModel( + &mp->m_fixedOutputVelocityModel ); + m_outputProgramSpinBox->setModel( &mp->m_outputProgramModel ); + if( m_rpBtn ) { m_rpBtn->setMenu( mp->m_readablePortsMenu ); @@ -141,4 +146,3 @@ void instrumentMidiIOView::modelChanged( void ) } -#endif