How does delta time work for different tracks within a midi file?
I am currently writing a midi generator using preexisting midi files. I'm getting confused as each midi file I download seems to be saved in a slightly different format. I particularly getting confused as to what tracks are and how they effect time. In the midi files docs it states:
File Types
There are three types of MIDI files:
type 0 (single track): all messages are saved in one track
type 1 (synchronous): all tracks start at the same time
type 2 (asynchronous): each track is independent of the others
When creating a new file, you can select type by passing the type keyword argument, or by setting the type attribute:
mid = MidiFile(type=2)
mid.type = 1
Type 0 files must have exactly one track. A ValueError is raised if you attempt to save a file with no tracks or with more than one track.
My questions are
1. When it makes the distinction between synchronous and asynchronous tracks, does this mean synchronous means delta time 're-starts from 0' for each new track whereas asynchronous are consecutive in terms of timing? If not what does this mean?
2. If my above assumption is correct, in which situation would you use asynchronous files?
3. How does one split up tracks if type 2?
Essentially I am trying to regularise all the different ways of formatting midi files so that I can manipulate the data more easily between types. Any help with this would be appreciated.
Cheers
1 Comments
Sorted by latest first Latest Oldest Best
asynchronous in type 2 means that each track is an independent sequence : type 2 track are not meant to be played simultaneously. This differs from type 1 where tracks are meant to be played simultaneously. In type 1, timing of each track starts at zero time. Type 1 often has a "tempo track" as first track containing all tempo information.
I've not seen type 2 beeing used very often. It's just a way to store multiple sequences in a single midifile. Think of it as an archive midifile.
Not meant for that.
So i think type 0 is what you need as you only have to do your split joins operation for a single track.
Terms of Use Privacy policy Contact About Cancellation policy © freshhoot.com2025 All Rights reserved.