diff --git a/ChangeLog b/ChangeLog index ba426771a..bfdfacfe3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2008-09-07 Tobias Doerffel + * include/midi.h: + * src/core/midi/midi_client.cpp: + * src/core/midi/midi_port.cpp: + * src/core/midi/midi_alsa_seq.cpp: + fixed MIDI output channel issues (closes #2098722) + * include/graph.h: * src/gui/widgets/graph.cpp: integrated patch by Attila Herman which adds support for colorized diff --git a/include/midi.h b/include/midi.h index 4f3cf91fe..61e1736a9 100644 --- a/include/midi.h +++ b/include/midi.h @@ -114,6 +114,11 @@ struct midiEvent { } + inline int channel( void ) const + { + return m_channel; + } + inline Uint16 key( void ) const { return( m_data.m_param[0] ); diff --git a/src/core/midi/midi_alsa_seq.cpp b/src/core/midi/midi_alsa_seq.cpp index 39b328e98..fff1074fa 100644 --- a/src/core/midi/midi_alsa_seq.cpp +++ b/src/core/midi/midi_alsa_seq.cpp @@ -150,47 +150,47 @@ void midiALSASeq::processOutEvent( const midiEvent & _me, { case MidiNoteOn: snd_seq_ev_set_noteon( &ev, - _port->outputChannel(), + _me.channel(), _me.key() + KeysPerOctave, _me.velocity() ); break; case MidiNoteOff: snd_seq_ev_set_noteoff( &ev, - _port->outputChannel(), + _me.channel(), _me.key() + KeysPerOctave, _me.velocity() ); break; case MidiKeyPressure: snd_seq_ev_set_keypress( &ev, - _port->outputChannel(), + _me.channel(), _me.key() + KeysPerOctave, _me.velocity() ); break; case MidiControlChange: snd_seq_ev_set_controller( &ev, - _port->outputChannel(), + _me.channel(), _me.m_data.m_param[0], _me.m_data.m_param[1] ); break; case MidiProgramChange: snd_seq_ev_set_pgmchange( &ev, - _port->outputChannel(), + _me.channel(), _me.m_data.m_param[0] ); break; case MidiChannelPressure: snd_seq_ev_set_chanpress( &ev, - _port->outputChannel(), + _me.channel(), _me.m_data.m_param[0] ); break; case MidiPitchBend: snd_seq_ev_set_pitchbend( &ev, - _port->outputChannel(), + _me.channel(), _me.m_data.m_param[0] - 8192 ); break; diff --git a/src/core/midi/midi_client.cpp b/src/core/midi/midi_client.cpp index e97992d5d..e183c5202 100644 --- a/src/core/midi/midi_client.cpp +++ b/src/core/midi/midi_client.cpp @@ -278,26 +278,10 @@ void midiClientRaw::processOutEvent( const midiEvent & _me, case MidiNoteOn: case MidiNoteOff: case MidiKeyPressure: - if( _port->outputChannel() >= 0 ) - { - sendByte( _me.m_type | _port->outputChannel() ); - sendByte( _me.m_data.m_param[0] + - KeysPerOctave ); - sendByte( tLimit( (int) _me.m_data.m_param[1], + sendByte( _me.m_type | _me.channel() ); + sendByte( _me.m_data.m_param[0] + KeysPerOctave ); + sendByte( tLimit( (int) _me.m_data.m_param[1], 0, 127 ) ); - } - else - { - for( Sint8 i = 0; i < MidiChannelCount; ++i ) - { - sendByte( _me.m_type | i ); - sendByte( _me.m_data.m_param[0] + - KeysPerOctave ); - sendByte( tLimit( (int) - _me.m_data.m_param[1], - 0, 127 ) ); - } - } break; default: diff --git a/src/core/midi/midi_port.cpp b/src/core/midi/midi_port.cpp index c895f0b12..cd270f37a 100644 --- a/src/core/midi/midi_port.cpp +++ b/src/core/midi/midi_port.cpp @@ -137,10 +137,10 @@ void midiPort::processInEvent( const midiEvent & _me, const midiTime & _time ) } } midiEvent ev = _me; - if( m_defaultVelocityInEnabledModel.value() == TRUE && + if( m_defaultVelocityInEnabledModel.value() == true && _me.velocity() > 0 ) { - ev.velocity() = DefaultVolume; + ev.velocity() = MidiMaxVelocity; } m_midiEventProcessor->processInEvent( ev, _time ); } @@ -156,10 +156,16 @@ void midiPort::processOutEvent( const midiEvent & _me, const midiTime & _time ) ( outputChannel() == _me.m_channel && outputChannel() != 0 ) ) { midiEvent ev = _me; + // we use/display MIDI channels 1...16 but we need 0...15 for + // the outside world + if( ev.m_channel > 0 ) + { + --ev.m_channel; + } if( m_defaultVelocityOutEnabledModel.value() == true && _me.velocity() > 0 ) { - ev.velocity() = DefaultVolume; + ev.velocity() = MidiMaxVelocity; } m_midiClient->processOutEvent( ev, _time, this ); }