I have midi stream which turns on same drum instrument 0x24 (bass drum 1) simultaneously at different velocities.
00 99 24 77 00 24 7b
In some time both are being turned off
00 99 24 00 00 24 00
I have three questions:
key off command for channel 9 (0x89) has velocity parameter, and I can (should I?) turn off the note/instrument with this specific velocity only (e.g.
00 89 24 77will turn first key off), however with using key on command with velocity 0 (as far as I understand means key off) it is not clear what key to release - first or second. What is the rule here?
is key off in general mandatory by the standard? My question relates to mandatory key off command in the midi data stream because I want to free hardware sound channel when key gets off, and if this command will never come, hardware sound channel will get stuck and will not be reusable.
is it allowed by the midi standard to press key and release key within the same tick (therefore play time is 0)?
thank you very much for an answer. I deal with files, therefore same tick means all the events happen at once, however in the sequence they are laid out, and I commit changes at the end of the tick. That's why pressing key and releasing key within the same tick must be dealt with carefully.
I will make it the following way: if I get note off message with specific non-zero velocity, I will turn off only note with that velocity, however if I get note off with velocity 0 or note on with velocity 0, I will turn all notes for this instrument off.
Epic fail. Midi file turns on channel 9 note 82 with velocity 100, and turns off with velocity 127 (obviously it is this note as there's only one 82 sounding at the moment). Therefore following rule above consumes all the oscillator channels and gets stuck.