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:
@@ -81,23 +81,27 @@ public:
|
||||
|
||||
void setName( const QString & _name );
|
||||
|
||||
inline Modes mode( void ) const
|
||||
inline Modes mode() const
|
||||
{
|
||||
return( m_mode );
|
||||
return m_mode;
|
||||
}
|
||||
|
||||
void setMode( Modes _mode );
|
||||
|
||||
inline bool inputEnabled( void ) const
|
||||
inline bool inputEnabled() const
|
||||
{
|
||||
return( mode() == Input || mode() == Duplex );
|
||||
return mode() == Input || mode() == Duplex;
|
||||
}
|
||||
|
||||
inline bool outputEnabled( void ) const
|
||||
inline bool outputEnabled() const
|
||||
{
|
||||
return( mode() == Output || mode() == Duplex );
|
||||
return mode() == Output || mode() == Duplex;
|
||||
}
|
||||
|
||||
inline int realOutputChannel() const
|
||||
{
|
||||
return outputChannel() - 1;
|
||||
}
|
||||
|
||||
void processInEvent( const midiEvent & _me, const midiTime & _time );
|
||||
void processOutEvent( const midiEvent & _me, const midiTime & _time );
|
||||
@@ -106,9 +110,9 @@ public:
|
||||
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
|
||||
virtual void loadSettings( const QDomElement & _this );
|
||||
|
||||
virtual QString nodeName( void ) const
|
||||
virtual QString nodeName() const
|
||||
{
|
||||
return( "midiport" );
|
||||
return "midiport";
|
||||
}
|
||||
|
||||
void subscribeReadablePort( const QString & _port,
|
||||
@@ -116,19 +120,19 @@ public:
|
||||
void subscribeWritablePort( const QString & _port,
|
||||
bool _subscribe = TRUE );
|
||||
|
||||
const map & readablePorts( void ) const
|
||||
const map & readablePorts() const
|
||||
{
|
||||
return( m_readablePorts );
|
||||
return m_readablePorts;
|
||||
}
|
||||
|
||||
const map & writablePorts( void ) const
|
||||
const map & writablePorts() const
|
||||
{
|
||||
return( m_writablePorts );
|
||||
return m_writablePorts;
|
||||
}
|
||||
|
||||
void unsubscribeAllReadablePorts( void );
|
||||
void unsubscribeAllWriteablePorts( void );
|
||||
inline void unsubscribeAllPorts( void )
|
||||
void unsubscribeAllReadablePorts();
|
||||
void unsubscribeAllWriteablePorts();
|
||||
inline void unsubscribeAllPorts()
|
||||
{
|
||||
unsubscribeAllReadablePorts();
|
||||
unsubscribeAllWriteablePorts();
|
||||
@@ -139,13 +143,13 @@ public:
|
||||
|
||||
|
||||
public slots:
|
||||
void updateMidiPortMode( void );
|
||||
void updateMidiPortMode();
|
||||
|
||||
|
||||
private slots:
|
||||
void updateReadablePorts( void );
|
||||
void updateWritablePorts( void );
|
||||
void updateOutputProgram( void );
|
||||
void updateReadablePorts();
|
||||
void updateWritablePorts();
|
||||
void updateOutputProgram();
|
||||
|
||||
|
||||
private:
|
||||
@@ -173,9 +177,9 @@ private:
|
||||
|
||||
|
||||
signals:
|
||||
void readablePortsChanged( void );
|
||||
void writablePortsChanged( void );
|
||||
void modeChanged( void );
|
||||
void readablePortsChanged();
|
||||
void writablePortsChanged();
|
||||
void modeChanged();
|
||||
|
||||
|
||||
} ;
|
||||
|
||||
@@ -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 ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user