Using external MIDI input and output.

Having trouble with LMMS? Ask about it here.
Image

That's what happens with Chromium, Vivaldi, and Opera in Linux.
I think I sorted out the problem here.

The MIDI events are being filtered on output in this code:

Code: Select all

 void MidiPort::processOutEvent( const MidiEvent& event, const MidiTime& time )
 {
        // mask event
       if( isOutputEnabled() && realOutputChannel() == event.channel() )
        {
                MidiEvent outEvent = event;
 
                if( fixedOutputVelocity() >= 0 && event.velocity() > 0 &&
                        ( event.type() == MidiNoteOn || event.type() == MidiKeyPressure ) )
                {
                        outEvent.setVelocity( fixedOutputVelocity() );
                }

                m_midiClient->processOutEvent( outEvent, time, this );
        }
}
This allows the MIDI event to go out only if its channel matches the output channel.

However, my expectation is that events from any channel are accepted (since I configured the input to accept input from all channels) and that any accepted MIDI events are simply moved to the correct output channel.

So I was able to make it work the way that I expect by doing this:

Code: Select all

@@ -146,10 +146,12 @@ void MidiPort::processInEvent( const MidiEvent& event, const MidiTime& time )
 void MidiPort::processOutEvent( const MidiEvent& event, const MidiTime& time )
 {
        // mask event
-       if( isOutputEnabled() && realOutputChannel() == event.channel() )
+       if( isOutputEnabled())
        {
                MidiEvent outEvent = event;
 
+                outEvent.setChannel(realOutputChannel());
+
                if( fixedOutputVelocity() >= 0 && event.velocity() > 0 &&
                        ( event.type() == MidiNoteOn || event.type() == MidiKeyPressure ) )
                {
The channel number isn't an attribute of an event, its just the channel that it is received or transmitted on. So I can't think of why simply assigning the output channel when the note is output would ever be the wrong thing to do. Indeed, everything seems to work correctly after this change, in particular input channel filtering still works.
Moosfet wrote:
Sat Mar 24, 2018 6:12 am
So I was able to make it work the way that I expect by doing this:

Code: Select all

@@ -146,10 +146,12 @@ void MidiPort::processInEvent( const MidiEvent& event, const MidiTime& time )
 void MidiPort::processOutEvent( const MidiEvent& event, const MidiTime& time )
 {
        // mask event
-       if( isOutputEnabled() && realOutputChannel() == event.channel() )
+       if( isOutputEnabled())
        {
                MidiEvent outEvent = event;
 
+                outEvent.setChannel(realOutputChannel());
+
                if( fixedOutputVelocity() >= 0 && event.velocity() > 0 &&
                        ( event.type() == MidiNoteOn || event.type() == MidiKeyPressure ) )
                {
The channel number isn't an attribute of an event, its just the channel that it is received or transmitted on. So I can't think of why simply assigning the output channel when the note is output would ever be the wrong thing to do. Indeed, everything seems to work correctly after this change, in particular input channel filtering still works.
Thanks for looking into this! I'll try the patch out.
The developers hang out on Discord: https://discord.gg/3sc5su7