You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
thanks for creating mido!
These are more questions than issues:
Could you please clarify: what is the meaning of the time attribute for events in a MIDI file track (talking about MIDI type 1 files here)?
I know that normally, time in MIDI streams is expressed as "delta time in ticks from the previous message".
But mido groups events per track, and it looks like the time attribute is then "delta time in ticks since the previous message on that same track".
Is this correct?
And also: is this then relative to note events only, or also relative to other events in that track?
For example, this is what I see for a simple note sequence of C D C D, where the C's are played on 1 track, and the D's on another track (note that I've also added a tempo change event somewhere in the middle of the first D note):
Since my goal is to convert note on/off events to notes with an absolute start/end time in seconds, am I right that this is the way to handle this with mido:
create a tempo map from the set_tempo events (each item has a time in ticks and the tempo value being set at that moment)
start at time 0 s with the tempo of the first tempo map item (at tick 0)
iterate over the note on/off events of each track while each time accumulating the time in ticks
if a next tempo change is not reached, simply accumulate the time in seconds by using tick2second(delta_time_ticks, ppqn, tempo)
if a next tempo change is reached, accumulate the time in seconds by using tick2second for all the tempo changes since the last one, taking into account the ticks between these tempo changes + the amount of ticks since the last note event in this track spent at each tempo
For that 1st D note in my example, it would mean that its absolute duration in seconds is calculated:
for the 1st part using tick2second with 960/2 ticks and the initial tempo
for the 2nd part using tick2second with 960/2 ticks and the second tempo
So essentially, do I need to do the bookkeeping myself of which ticks were spent at which tempo, on a track per track basis?
Or is there already something available in mido that handles this for MIDI files?
This discussion was converted from issue #595 on November 08, 2024 18:00.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
thanks for creating mido!
These are more questions than issues:
I know that normally, time in MIDI streams is expressed as "delta time in ticks from the previous message".
But mido groups events per track, and it looks like the time attribute is then "delta time in ticks since the previous message on that same track".
Is this correct?
And also: is this then relative to note events only, or also relative to other events in that track?
For example, this is what I see for a simple note sequence of C D C D, where the C's are played on 1 track, and the D's on another track (note that I've also added a tempo change event somewhere in the middle of the first D note):
For that 1st D note in my example, it would mean that its absolute duration in seconds is calculated:
So essentially, do I need to do the bookkeeping myself of which ticks were spent at which tempo, on a track per track basis?
Or is there already something available in mido that handles this for MIDI files?
Beta Was this translation helpful? Give feedback.
All reactions