Skip to content

Is there a way to detect a measure with a whole rest? #524

Discussion options

You must be logged in to vote

Hi and welcome!

The short answer: no, not directly.

The long answer:
First, note_off does not represent a rest but the time at which the corresponding note_on shall stop sounding.
Furthermore, when reading from a MIDI file, the time attribute is a delta-time expressed in ticks from the previous event. You can't be certain that the previous event is the note_on, it can be any event from any channel or track (depending on the MIDI file format aka type) including meta-events. Plus sometimes note off is expressed using a note_on with its velocity set to 0 to take advantage of the running status feature of the protocol.
So, in summary, rests don't exist per-se in MIDI files and you have to be …

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@rdoursenaud
Comment options

@bearcatjamboree
Comment options

@rdoursenaud
Comment options

@bearcatjamboree
Comment options

Answer selected by bearcatjamboree
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants