4

I am working with the V3.0.0 Maestro Dataset. One of the midi files in particular, /2017/MIDI-Unprocessed_043_PIANO043_MID--AUDIO-split_07-06-17_Piano-e_1-03_wav--4.midi had a track that has something like the following

15185 note_on channel=0 note=96 velocity=87 time=1
15190 note_on channel=0 note=96 velocity=0 time=7
15200 note_on channel=0 note=96 velocity=94 time=2
15205 note_on channel=0 note=96 velocity=98 time=2

In almost all the other files, there is a note_on message with a velocity=0 before the same note is played again. However in this file, this is not present. The messages also only contain note_on and do not contain note_off.

Is this a mistake, or am I missing something here?

7
  • I think note on v=0 is the new note off Commented Nov 18, 2021 at 0:59
  • 1
    Both events are acceptable, and it's part of the MIDI specification: a NoteOn with 0 velocity is considered the same as a NoteOff (with any velocity) and any input capable MIDI-compliant device should consider them the same as well. Some use the former, others the latter; some advanced devices/programs allow choosing which one to use (with a -possibly- configurable default off velocity) or allow conversion from a 0-NoteOn to a NoteOff event (usually with 127 velocity) and/or viceversa. Commented Nov 18, 2021 at 4:37
  • @musicamante Your comment looks like it would make an excellent answer to me! Would you like to post it?
    – Kevin
    Commented Nov 18, 2021 at 5:22
  • 1
    It’s called running status. On phone so limited ability to answer
    – Tetsujin
    Commented Nov 18, 2021 at 6:59
  • 2
    As Tetsujin says, this was introduced as an optimisation. MIDI note on/off messages normally take 3 bytes: a status byte (0x9n for note on, or 0x8n for note off, where n is the MIDI channel), and two data bytes (the note number and velocity). But a MIDI feature called running status lets you to skip the status byte if it's the same as before. So if a note on with velocity 0 means the same as note off, then you can send a whole bunch of note ons and offs without repeating the status byte — a speed-up of nearly 33%, which is very significant at MIDI's slow data rate.
    – gidds
    Commented Nov 18, 2021 at 13:12

2 Answers 2

7

Starting another instance of a note with the same channel and key as a note that is already sounding is technically allowed in MIDI, but I believe it is not normal.

In particular, the three notes mentioned in the question look like this in a sequencer:

piano roll

event list

It seems likely the overlapping notes are supposed to be separated and have a similar duration as the surrounding notes. Perhaps a glitch in the MIDI capture process didn't catch the correct release of those notes. (This MIDI file also contains a few notes that are 1 tick in duration -- 1/960 of a second in this MIDI file, which seems unlikely to be how the pianist originally preformed them.)

Technical Information

In MIDI, each message that starts a note (a Note On message for a particular channel and key with non-zero velocity) must eventually be followed by a message that ends the same note (a Note On message for the same channel and key with zero velocity, or a Note Off message for the same channel and key with any velocity).

It is possible to start another instance of a note with the same channel and key as a note that is already sounding, but each instance must eventually have a message that ends the note.

However, when there are overlapping notes with the same channel and key, it is ambiguous which end goes with which start. For example, if you encounter the following sequence of messages on the same channel at beat intervals:

start C5, start C5, end C5, end C5.

The sequence could be interpreted two ways:

start a, start b, end b, end a.
or
start a, start b, end a, end b.

Displayed another way, imagine the following two staves are two voices on the same track and channel. The first and second measures show the two interpretations above.

staff notation of the two interpretations

Because of this ambiguity, I believe overlapping notes of the same channel and key are usually avoided in MIDI.

MIDI Specification

Here is what the MIDI spec has to say about this. From the MIDI 1.0 Detailed Specification document version 4.2.1, PDF page 67 (printed page A-4):

ASSIGNMENT OF NOTE ON/OFF COMMANDS

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.

1
  • 1
    There's two more ways the example can be interpreted: start a, start b, end [a&b], end [] and start a, start b ending a, end b, end []. In fact, most instruments would probably interpret it in one of these ways, well knowing that MIDI can't be trusted to get its note-offs right, and that spurious ringing notes are generally more annoying to the user than spurious cut-off notes. Commented Nov 18, 2021 at 17:30
6

No, that's OK. A new note can be played while the same note is still ringing.

This is something you can also do on a piano: play a note, then press the sustain pedal (so the note won't stop when you release the key) and then play the same note again.

Or on a guitar: play a note, and then, without stopping it first, play it again.

Same thing with MIDI. You can play a note and then play it again at any time, without having to stop it first.

One thing to be aware, however, might be this: depending on the synthesizer (hardware or software) if you play the same note twice, and then release it (volume=0, or note-off), then on some synths both played notes will stop, while on other synths only one of the two notes will stop -- i.e. you will have to play a note-off twice if you played a note-on twice. Experiment or read the fine print to figure out which is which. (On most synth a single note-off will stop all previous note-ons, but I've come across a few where I had to send separate note-offs)

3
  • Thanks for the response! When I tried to recreate this using MuseScore (play a note, press the sustain, and press the note again), the exported midi file still said that the velocity goes to 0. What am I doing wrong? The dataset I am working with has 100GB of audio data (60 MB of midi files), yet there are only 5 instances of this behavior, so I don't believe it is something as simple as this, though I could be mistaken.
    – QiLin Xue
    Commented Nov 18, 2021 at 2:43
  • 2
    @QiLinXue while the effect is very similar, the pressed sustain pedal doesn't change the fact that a note has been released. MIDI messages have to be consistent with the events, not how they are perceived when the instrument plays those events. Commented Nov 18, 2021 at 4:26
  • @QiLinXue I don't think you are doing anything wrong, it's probably the software that is designed like that, i.e. to ensure a note is stopped before it is played again. If the software allows you to add or remove individual events manually, you can try to remove that particular event and see if the result is more similar to what you want, or not.
    – MMazzon
    Commented Nov 18, 2021 at 12:13

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.