MidiPort: added realOutputChannel() returning zero-based MIDI channel

MidiPort::outputChannelModel is ranged from 1 to 16 for displaying
user-friendly values. However internally MIDI channels are ranged from
0 to 15. Therefore added realOutputChannel() which returns zero-based
MIDI channel which should be used everywhere except for the GUI.

Fixes MIDI events being sent to VST plugins on channel 2 instead of
channel 1. Makes some more VST plugins actually usable.

Signed-off-by: Tobias Doerffel <tobias.doerffel@gmail.com>
This commit is contained in:
Tobias Doerffel
2009-07-09 12:10:33 +02:00
parent 41c9318be8
commit 4f249400ac
4 changed files with 37 additions and 36 deletions

View File

@@ -152,7 +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 )
if( outputEnabled() && realOutputChannel() == _me.m_channel )
{
midiEvent ev = _me;
// we use/display MIDI channels 1...16 but we need 0...15 for
@@ -422,7 +422,7 @@ void midiPort::updateWritablePorts( void )
void midiPort::updateOutputProgram( void )
{
processOutEvent( midiEvent( MidiProgramChange,
outputChannel(),
realOutputChannel(),
outputProgram()-1 ), midiTime( 0 ) );
}

View File

@@ -1,5 +1,3 @@
#ifndef SINGLE_SOURCE_COMPILE
/*
* note_play_handle.cpp - implementation of class notePlayHandle, part of
* rendering engine
@@ -106,7 +104,7 @@ notePlayHandle::notePlayHandle( instrumentTrack * _it,
{
// send MIDI-note-on-event
m_instrumentTrack->processOutEvent( midiEvent( MidiNoteOn,
m_instrumentTrack->getMidiPort()->outputChannel(),
m_instrumentTrack->getMidiPort()->realOutputChannel(),
key(), getMidiVelocity() ),
midiTime::fromFrames( offset(),
engine::framesPerTick() ) );
@@ -153,7 +151,7 @@ void notePlayHandle::setVolume( const volume_t _volume )
{
note::setVolume( _volume );
m_instrumentTrack->processOutEvent( midiEvent( MidiKeyPressure,
m_instrumentTrack->getMidiPort()->outputChannel(),
m_instrumentTrack->getMidiPort()->realOutputChannel(),
key(), getMidiVelocity() ), 0 );
}
@@ -331,7 +329,7 @@ void notePlayHandle::noteOff( const f_cnt_t _s )
{
// send MIDI-note-off-event
m_instrumentTrack->processOutEvent( midiEvent( MidiNoteOff,
m_instrumentTrack->getMidiPort()->outputChannel(),
m_instrumentTrack->getMidiPort()->realOutputChannel(),
key(), 0 ),
midiTime::fromFrames( m_framesBeforeRelease,
engine::framesPerTick() ) );
@@ -518,6 +516,3 @@ void notePlayHandle::resize( const bpm_t _new_tempo )
}
#endif

View File

@@ -369,11 +369,12 @@ void instrumentTrack::processOutEvent( const midiEvent & _me,
if( m_runningMidiNotes[k] > 0 )
{
m_instrument->handleMidiEvent(
midiEvent( MidiNoteOff, getMidiPort()->outputChannel(), k, 0 ), _time );
midiEvent( MidiNoteOff, getMidiPort()->realOutputChannel(), k, 0 ),
_time );
}
++m_runningMidiNotes[k];
m_instrument->handleMidiEvent(
midiEvent( MidiNoteOn, getMidiPort()->outputChannel(), k,
midiEvent( MidiNoteOn, getMidiPort()->realOutputChannel(), k,
_me.velocity() ), _time );
}
break;
@@ -389,7 +390,8 @@ void instrumentTrack::processOutEvent( const midiEvent & _me,
--m_runningMidiNotes[k] <= 0 )
{
m_instrument->handleMidiEvent(
midiEvent( MidiNoteOff, getMidiPort()->outputChannel(), k, 0 ), _time );
midiEvent( MidiNoteOff, getMidiPort()->realOutputChannel(), k, 0 ),
_time );
}
break;
@@ -542,7 +544,7 @@ void instrumentTrack::updatePitch( void )
{
updateBaseNote();
processOutEvent( midiEvent( MidiPitchBend,
getMidiPort()->outputChannel(),
getMidiPort()->realOutputChannel(),
midiPitch() ), 0 );
}