Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in midiToInput & 1500+ unit tests #1168

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

m-dhooge
Copy link

Hello,

There is a bug in QLCMIDIProtocol::midiToInput(): It expects 2 data bytes but according to the MIDI spec only 1 byte is provided. Note that the reverse function (feedbackToMidi) correctly uses only the first byte.

I also produced some unit tests...

M.

@m-dhooge
Copy link
Author

...for the MIDI_PROGRAM_CHANGE command. Other commands are valid.

@@ -67,8 +67,8 @@ bool QLCMIDIProtocol::midiToInput(uchar cmd, uchar data1, uchar data2,
break;

case MIDI_PROGRAM_CHANGE:
*channel = CHANNEL_OFFSET_PROGRAM_CHANGE + quint32(data1);
*value = MIDI2DMX(data2);
*channel = CHANNEL_OFFSET_PROGRAM_CHANGE;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is plain wrong. You probably haven't invested enough time to understand how the MIDI plugin works.
See https://www.qlcplus.org/docs/html_en_EN/midiplugin.html - QLC+ Channels map

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I did… by using what I believe IS the MIDI reference!
https://www.midi.org/specifications-old/item/table-1-summary-of-midi-message

cmd = 1100nnnn
data1 = 0ppppppp
data2 = NONE
Program Change. This message sent when the patch number changes. (ppppppp) is the new program number.

And furthermore, if you look at feedbackToMidi(), it only uses data1.

M.

Copy link
Owner

@mcallegari mcallegari Dec 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably be:

*channel = CHANNEL_OFFSET_PROGRAM_CHANGE + quint32(data1);
*value = 0xFF;

If you remove data1 from the channel number, then all program change will be sent on the same QLC+ channel and cannot be distinguished anymore.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be an option… but this isn't what you chose for feedbackToMidi ;-)
And as I wrote in another comment, it seems this isn't used by DAWs.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just looked at the InputChannelEditor UI. And your above proposal, with value = 0xFF makes sense. Otherwise, there is a huge gap in the QLC channel numbers… as with the Midi Beat (between 513 & 529).
I can come back with a new PR, with feedbackToMidi in sync with your above comment. And all the unit tests adapted.
M.

@m-dhooge
Copy link
Author

I didn't try to recompile the whole project… and CHANNEL_OFFSET_PROGRAM_CHANGE_MAX is used by InputChannelEditor::numberToMidi :-(
I'll update my code with something that wholly compiles.

@mcallegari
Copy link
Owner

Ok, let's take a step back then.
What is the reason why this patch is needed ? Cause last time I checked, program changes were working.
Please indicate step by step what you did, and the equipment you used. Thanks.

@m-dhooge
Copy link
Author

I have a problem with a Behringer X-Touch Compact -- but this isn't directly related to this patch.
However, I wanted to learn a bit the code before diving into my problem; so I started writing some unit tests for the midiprotocol.cpp functions. And this is how I discovered there is an inconsistency between both functions (midiToInput & feedbackToMidi).

Note that I just grep-ed through all the profile files in resources/inputprofiles for any value between 256 and 513 as the channel number (i.e. Note aftertouch, Program Change, Channel aftertouch & Pitch Wheel). Only Pitch Wheel is used, by Behringer-BCF2000inMackieControlMode.qxi & Zoom-R16.qxi.

So I believe no manufacturers use PC within their DAW… So there is no real reason -- so far -- to apply this patch. But there is a bug in midiToInput because data2 isn't defined in the case of PC. Or this is feedbackToMidi that is wrong (because it uses data1) -- but I think midi.org is accurate.

My 2 cents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants