Is there a way to detect a measure with a whole rest? #524
-
I'm using Python and trying the following to get a list of indexes that have whole rests:
But I'm not getting it to identify measures with rests. Any ideas? Basically, I just want to make clips from a large file with many, many empty measure that are filled with a single whole rest in 4/4 time. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hi and welcome! The short answer: no, not directly. The long answer: |
Beta Was this translation helpful? Give feedback.
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 correspondingnote_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 thenote_on
, it can be any event from any channel or track (depending on the MIDI fileformat
akatype
) including meta-events. Plus sometimes note off is expressed using anote_on
with its velocity set to0
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 …