View Single Post
Old 01-10-2012, 06:05 AM   #31
captain_caveman
Human being with feelings
 
captain_caveman's Avatar
 
Join Date: Dec 2011
Posts: 999
Default

Cool, if I could just point out one tiny, weeny last buglet...

You didn't have to shuffle my code around btw, just add a check for note-ons @ 0 vel to the note-off and a vel >0 bit to the note-on bit. Anyhoo, the way you have done it is very nearly correct, except...
Code:
//Check if we have recieved a note off message.
  statusLo == 8 || velocity==0 ? (
... checks for a note off or for any other message with a value of 0 (remember that value is only velocity if the message is a note), so whenever any MIDI message of value 0 was received it would cut off the corresponding note, if one was playing (eg note 82 would be cut off by a CC82 message at value 0).

So...
Code:
statusLo == 8 || (statusLo == 9 && velocity == 0) ? (
... will stop that happening.

For the record, this was the bit missing from my code to check for note-offs that are note-ons at zero velocity, as well as a bit to make sure these messages are not confused with actual note-ons....
Code:
statusLo ==9 && velocity > 0 ? (
... but of course, since you have put this section in an else (once you've added the note-off check above), you don't need to put that in since the initial if statement will have executed with a note-on @ zero velocity.
captain_caveman is offline   Reply With Quote