1

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:

  1. 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 77 will 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?

  2. 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.

  3. is it allowed by the midi standard to press key and release key within the same tick (therefore play time is 0)?

Update:

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.

2
  • 1
    Linked for your two first questions: music.stackexchange.com/questions/100983/…
    – Tom
    Commented May 19, 2022 at 13:11
  • You seem to be assuming that the note-off velocity should match that of the corresponding note-on. But that's not my understanding, which is that just as the note-on velocity indicates how hard the note was struck, the note-off velocity indicates how hard the note was released. (That doesn't make physical sense for all instruments, of course.) So in general it won't match. Can anyone confirm the right interpretation?
    – gidds
    Commented May 22, 2022 at 12:16

1 Answer 1

3
  1. The MIDI norms does not specify how to handle two noteOn on the same notes for the same instrument. From the specification:

If an instrument receives two or more Note On messages with the same key number and MIDI channel, it must make a determination of how to handle the additional Note Ons. It is up to the receiver as to whether the same voice or another voice will be sounded, or if the messages will be ignored. The transmitter, however, must send a corresponding Note Off message for every Note On sent. If the transmitter were to send only one Note Off message, and if the receiver in fact assigned the two Note On messages to different voices, then one note would linger. Since there is no harm or negative side effect in sending redundant Note Off messages this is the recommended practice.

It is true that, using the velocity in the noteOff could actually makes the synth which one to shut down however this is not standard (at all) and up to the synthesizer design how to handle these events. Note that the case of two noteOn with exact same velocities would still be a problem in that case.

  1. As you can see in the previous citation, noteOff is mandatory:

The transmitter, however, must send a corresponding Note Off message for every Note On sent.

  1. There is nothing in the standard preventing two events at the same tick, however, MIDI rate is (fairly) slow: 31.25 kBaud. Hence, two events cannot be sent at the exact same time. How the sender will handle this situation (delay the second event, discard it) is, once again, probably up to the implementation.
3
  • @Anonymous Might be a bit quick to accept an answer, especially if you want other perspectives but that's up to you if this is complete enough or not!
    – Tom
    Commented May 19, 2022 at 14:26
  • Not at all. Probably one remaining small question. For point 3, what will happen to the voicing? Key on, and then key off in 1 ms. I am not sure if instrument will be able to reach its minimal attenuation during attack. Plus I would be surprised if voicing is dependent on the midi channel speed (can it is be different speed? retransmissions because of errors?) What would we expect from keying instrument on and then almost immediately off - under "normal" and "abnormal" conditions?
    – Anonymous
    Commented May 19, 2022 at 14:35
  • @Anonymous best case it will only depends on the Adsr parameters: if attack time set to zero and synth actually fast enough to process the first order (actually likely) then it will enter the release phase straight from the sustain level into the release phase, producing a sound like a pluck if release time is set long enough.
    – Tom
    Commented May 19, 2022 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.