InstrumentMidiIOView: added support for fixed output notes

It came to me that having LMMS output one fixed note from a track could
be useful for controlling drum machines or something like that, so here's
a new spinbox for the MIDI tab.

Signed-off-by: Tobias Doerffel <tobias.doerffel@gmail.com>
This commit is contained in:
Raine M. Ekman
2012-11-10 12:49:37 +01:00
committed by Tobias Doerffel
parent 6f7572b949
commit 3aa03da5af
5 changed files with 30 additions and 4 deletions

View File

@@ -55,6 +55,7 @@ private:
lcdSpinBox * m_outputChannelSpinBox;
lcdSpinBox * m_fixedOutputVelocitySpinBox;
lcdSpinBox * m_outputProgramSpinBox;
lcdSpinBox * m_fixedOutputNoteSpinBox;
QToolButton * m_wpBtn;
} ;

View File

@@ -56,6 +56,8 @@ class MidiPort : public Model, public SerializingObject
m_fixedInputVelocityModel);
mapPropertyFromModel(int,fixedOutputVelocity,setFixedOutputVelocity,
m_fixedOutputVelocityModel);
mapPropertyFromModel(int,fixedOutputNote,setFixedOutputNote,
m_fixedOutputNoteModel);
mapPropertyFromModel(int,outputProgram,setOutputProgram,
m_outputProgramModel);
mapPropertyFromModel(bool,isReadable,setReadable,m_readableModel);
@@ -155,6 +157,7 @@ private:
IntModel m_outputControllerModel;
IntModel m_fixedInputVelocityModel;
IntModel m_fixedOutputVelocityModel;
IntModel m_fixedOutputNoteModel;
IntModel m_outputProgramModel;
BoolModel m_readableModel;
BoolModel m_writableModel;

View File

@@ -85,6 +85,7 @@ const int MidiChannelCount = 16;
const int MidiControllerCount = 128;
const int MidiProgramCount = 128;
const int MidiMaxVelocity = 127;
const int MidiMaxNote = 127;
const int MidiMaxPanning = 127;
const int MidiMinPanning = -128;

View File

@@ -52,6 +52,8 @@ MidiPort::MidiPort( const QString & _name, MidiClient * _mc,
tr( "Fixed input velocity" ) ),
m_fixedOutputVelocityModel( -1, -1, MidiMaxVelocity, this,
tr( "Fixed output velocity" ) ),
m_fixedOutputNoteModel( -1, -1, MidiMaxNote, this,
tr( "Fixed output note" ) ),
m_outputProgramModel( 1, 1, MidiProgramCount, this,
tr( "Output MIDI program" ) ),
m_readableModel( false, this, tr( "Receive MIDI-events" ) ),
@@ -156,9 +158,16 @@ void MidiPort::processOutEvent( const midiEvent & _me, const midiTime & _time )
midiEvent ev = _me;
// we use/display MIDI channels 1...16 but we need 0...15 for
// the outside world
if( ev.m_channel > 0 )
// We are already in "real" MIDI channel space here
/* if( ev.m_channel > 0 )
{
--ev.m_channel;
} */
if( ( _me.m_type == MidiNoteOn || _me.m_type == MidiNoteOff ) &&
fixedOutputNote() >=0 ) {
// Convert MIDI note number (from spinbox) -> LMMS note number
// that will be converted back when outputted.
ev.key() = fixedOutputNote() - KeysPerOctave;
}
if( fixedOutputVelocity() >= 0 && _me.velocity() > 0 &&
( _me.m_type == MidiNoteOn ||
@@ -183,6 +192,8 @@ void MidiPort::saveSettings( QDomDocument & _doc, QDomElement & _this )
"fixedinputvelocity" );
m_fixedOutputVelocityModel.saveSettings( _doc, _this,
"fixedoutputvelocity" );
m_fixedOutputNoteModel.saveSettings( _doc, _this,
"fixedoutputnote" );
m_outputProgramModel.saveSettings( _doc, _this, "outputprogram" );
m_readableModel.saveSettings( _doc, _this, "readable" );
m_writableModel.saveSettings( _doc, _this, "writable" );

View File

@@ -85,26 +85,34 @@ InstrumentMidiIOView::InstrumentMidiIOView( QWidget * _parent ) :
m_outputProgramSpinBox->move( 112, 32 );
m_outputProgramSpinBox->setEnabled( false );
m_fixedOutputNoteSpinBox = new lcdSpinBox( 3, m_midiOutputGroupBox );
m_fixedOutputNoteSpinBox->addTextForValue( -1, "---" );
m_fixedOutputNoteSpinBox->setLabel( tr( "NOTE" ) );
m_fixedOutputNoteSpinBox->move( 160, 32 );
m_fixedOutputNoteSpinBox->setEnabled( false );
connect( m_midiOutputGroupBox->ledButton(), SIGNAL( toggled( bool ) ),
m_outputChannelSpinBox, SLOT( setEnabled( bool ) ) );
connect( m_midiOutputGroupBox->ledButton(), SIGNAL( toggled( bool ) ),
m_fixedOutputVelocitySpinBox, SLOT( setEnabled( bool ) ) );
connect( m_midiOutputGroupBox->ledButton(), SIGNAL( toggled( bool ) ),
m_outputProgramSpinBox, SLOT( setEnabled( bool ) ) );
connect( m_midiOutputGroupBox->ledButton(), SIGNAL( toggled( bool ) ),
m_fixedOutputNoteSpinBox, SLOT( setEnabled( bool ) ) );
if( !engine::getMixer()->midiClient()->isRaw() )
{
m_rpBtn = new QToolButton( m_midiInputGroupBox );
m_rpBtn->setText( tr( "MIDI devices to receive MIDI events from" ) );
m_rpBtn->setIcon( embed::getIconPixmap( "piano" ) );
m_rpBtn->setGeometry( 186, 24, 32, 32 );
m_rpBtn->setGeometry( 208, 24, 32, 32 );
m_rpBtn->setPopupMode( QToolButton::InstantPopup );
m_wpBtn = new QToolButton( m_midiOutputGroupBox );
m_wpBtn->setText( tr( "MIDI devices to send MIDI events to" ) );
m_wpBtn->setIcon( embed::getIconPixmap( "piano" ) );
m_wpBtn->setGeometry( 186, 24, 32, 32 );
m_wpBtn->setGeometry( 208, 24, 32, 32 );
m_wpBtn->setPopupMode( QToolButton::InstantPopup );
}
}
@@ -131,6 +139,8 @@ void InstrumentMidiIOView::modelChanged()
m_outputChannelSpinBox->setModel( &mp->m_outputChannelModel );
m_fixedOutputVelocitySpinBox->setModel(
&mp->m_fixedOutputVelocityModel );
m_fixedOutputNoteSpinBox->setModel(
&mp->m_fixedOutputNoteModel );
m_outputProgramSpinBox->setModel( &mp->m_outputProgramModel );
if( m_rpBtn )