fbpx
Skip to main content

MIDI Forum

Ways to determine i...
 
Notifications
Clear all

Ways to determine is a MIDI is Type 0 or 1

11 Posts
5 Users
0 Reactions
14.1 K Views
Nikolai
Posts: 36
Trusted Member
Topic starter
 

Except for counting number of tracks, is there a definitive way of determining a type that always work?

I am guessing a type 1 can have only 1 track, so counting is not optimal.

 
Posted : 09/11/2021 9:01 am
Geoff
Posts: 1043
Noble Member
 

Actually, it's the type 1 that can have multiple tracks, it's the tyoe 0 (zero) that has ALL the data on one track.

I think that one of the first few bytes at the start of the file indicates if it's Type 0, 1 or 2.

The first Chunk of the file comprises and it's the third of those that will be 0, 1 or 2 for the file type. Before you wonder, I've never seen a type 2 file, but this is for a single file that contains a succession of separate type 0 files. Not sure any exist?

Geoff

 
Posted : 09/11/2021 9:13 am
Jason
Posts: 438
Honorable Member
 

[quotePost id=11928]I've never seen a type 2 file, but this is for a single file that contains a succession of separate type 0 files. Not sure any exist?
[/quotePost]
I have a MASSIVE collection of MIDI files, and found a windows search called "xsearch" that lets me search hex contents of a file. It appears that I have 27 type 2 files, which I verified (at least as far as the header is concerned) with my instrument changer and Sema's midi file checker. So in case you want to test them out, here they are. Most appear to be from the same place (all Star Wars related).

 
Posted : 09/11/2021 11:46 am
Jason
Posts: 438
Honorable Member
 

For further info, what you will see in each type in the header is:

Type 0:
4D 54 68 64 MThd ID
00 00 00 06 Length of the MThd chunk is always 6.
00 00

Type 1:
4D 54 68 64 MThd ID
00 00 00 06 Length of the MThd chunk is always 6.
00 01

Type 2:
4D 54 68 64 MThd ID
00 00 00 06 Length of the MThd chunk is always 6.
00 02

 
Posted : 09/11/2021 11:49 am
Geoff
Posts: 1043
Noble Member
 

Thanks for these. I'll have a play with them.

I've had a quick look at a couple of them, both were marked as type 2. One said there were 3 tracks, which seem to be one major track and two very small ones. The other, BATTLE1, shows type 2, but the number of tracks showing is 1 (so says the header). The data seems to show 1 track only. When I load the file into SynthFont I get a message regarding the file format, suggesting that the file says it is Type 2 but is now actually Type 0. Synthfont then loads all the data in, and splits the data by track according to Channel, so I get multi-tracks. No asking me if that's what I wanted to do! I'll try playing it and see what it sounds like, I'm familiar enough with the film to know if the music is correct.

So, at least one of the files in the set WAS a type 2, but now no longer actually is??

Geoff

 
Posted : 09/11/2021 12:46 pm
Geoff
Posts: 1043
Noble Member
 

Hmm - just played BATTLE1, via SynthFont, and it sounded pretty good. A fairly complex arrangement, full range of sounds, very solid. I'll need to try it again via the normal midi/MU90r. But perfectly OK. No hint of anything that might have related to it being Type 2.

Geoff

 
Posted : 09/11/2021 1:29 pm
Jason
Posts: 438
Honorable Member
 

I was actually curious about that. It should be a series of type 0 tracks, so would that technically still be a single track?

The spec says:

A Format 1 or 2 file has a header chunk followed by one or more track chunks. Programs
which support several simultaneous tracks should be able to save and read data in format 1, a
vertically one-dimensional form, that is, as a collection of tracks. Programs which support
several independent patterns should be able to save and read data in format 2, a horizontally
one-dimensional form.

I'm not quite sure how to interpret "horizontally one-dimensional" vs "vertically one-dimensional".

If I understand it correctly, a type 2 MIDI file would play like an album if played in a normal player, one segment after another, with or without a clear delineation for when each "part" starts and ends, as opposed to a type 1, where all tracks "start" at the same time, and timing in to the song is controlled by delta time.

If this is the case, you potentially would not know just by listening that it was a type 2.

So sort of like loop points, except nothing loops, and each loop section is its own track?

 
Posted : 09/11/2021 1:36 pm
Nikolai
Posts: 36
Trusted Member
Topic starter
 

[quotePost id=11929]So in case you want to test them out, here they are.[/quotePost]

Very nice, thank you. 🙂

 
Posted : 09/11/2021 2:06 pm
Geoff
Posts: 1043
Noble Member
 

Had a play.

I don't know what's supposed to happen with a type 2 file.

When I load the EMPIRE file into SynthFont (this is the file that looks like type 2, and the data is mostly the main sequence, then followed by a very small sequence and then a slightly larger one, SynthFont seems to disregard the separate sequences, and in effect merges the lot into one file, so I get no noticeable gap between the main Seq, and a small gap between the first and second 'extra' segments. Looking at the Events List within SynthFont, there is no evidence of the extra sequences, everything is run together, and the closing events are correct for the data in the second add-on. The loaded file plays correctly, pause and all.

The data in the main midi file shows as:

All normal up to end of first seq.
one note is turned ON, no OFF yet.
First Seq ends, Track End.
Delta time in midi file is reset to zero
Delay on new delta time
Note OFF on note that was left ON
More delay on delta time
End of track
Start of new track
delta time reset again to 0
delay on delta time
a handful of notes ON and OFF
delay on delta time
End of track

This all ties up with what I hear on playback. The only oddity is that all trace of the separate extra sequences has vanished, the data has been merged into the main sequence, the delta times have been accumulated onto the delta time in the main file, the events occur (correctly) at the new accumulated delta time. Not really sure what the POINT therefore of the type 2 file is.

Although...

If you use a midi text process, you could take say 3 midi files and just edit them together as text and run them as-is as a type 2 file and not bother to adjust the delta times in the add-on segments?

Maybe other sequencer systems could merge in separate modules in the same way?

Geoff

 
Posted : 09/11/2021 3:41 pm
Clemens Ladisch
Posts: 323
Reputable Member
 

[quotePost id=11933]If I understand it correctly, a type 2 MIDI file would play like an album if played in a normal player, one segment after another[/quotePost]

No, it is not specified how the segments relate to each other. A generic player cannot know how to handle them; type 2 files cannot be used as an interchange format.

A typical application would be a looping segment, and intros/outros.

 
Posted : 09/11/2021 10:07 pm
Pedro Lopez-Cabanillas
Posts: 154
Estimable Member
 

I have a MASSIVE collection of MIDI files, and found a windows search called "xsearch" that lets me search hex contents of a file.

Another method is the Unix utility file, which in my Linux box outputs this for your collection:

[code type=markup]
> file *.mid

battle1.mid: Standard MIDI data (format 2) using 1 track at 1/480
Battle2.mid: Standard MIDI data (format 2) using 1 track at 1/480
boss3.mid: Standard MIDI data (format 2) using 3 tracks at 1/480
cargo.mid: Standard MIDI data (format 2) using 1 track at 1/480
cloak.mid: Standard MIDI data (format 2) using 1 track at 1/480
closcred2.mid: Standard MIDI data (format 2) using 1 track at 1/480
closcred.mid: Standard MIDI data (format 2) using 1 track at 1/480
closing2.mid: Standard MIDI data (format 2) using 1 track at 1/480
crixmus.mid: Standard MIDI data (format 2) using 3 tracks at 1/480
Dark_Forces.mid: Standard MIDI data (format 2) using 2 tracks at 1/480
dfdemo.mid: Standard MIDI data (format 2) using 1 track at 1/480
Empire.mid: Standard MIDI data (format 2) using 3 tracks at 1/480
empshort.mid: Standard MIDI data (format 2) using 1 track at 1/480
executor.mid: Standard MIDI data (format 2) using 6 tracks at 1/480
fight_1.mid: Standard MIDI data (format 2) using 4 tracks at 1/480
Fight6.mid: Standard MIDI data (format 2) using 2 tracks at 1/480
frigate.mid: Standard MIDI data (format 2) using 3 tracks at 1/480
gromas.mid: Standard MIDI data (format 2) using 1 track at 1/480
jabba2.mid: Standard MIDI data (format 2) using 1 track at 1/480
media.mid: Standard MIDI data (format 2) using 1 track at 1/480
starwars09.mid: Standard MIDI data (format 2) using 1 track at 1/480
starwarsmedley.mid: Standard MIDI data (format 2) using 1 track at 1/480
Stately.mid: Standard MIDI data (format 2) using 1 track at 1/480
sw2_1.mid: Standard MIDI data (format 2) using 1 track at 1/480
tesb_impmarch_slow.mid: Standard MIDI data (format 2) using 2 tracks at 1/480
tiedemo.mid: Standard MIDI data (format 2) using 1 track at 1/480
Trainpod_1.mid: Standard MIDI data (format 2) using 1 track at 1/480
[/code]

Most appear to be from the same place (all Star Wars related).

Yes, I think that they come from one or several video games set in the movie series universe.

It makes sense for a video game to use format 2 SMF, but gook luck guessing how to play the sequences outside of the game if there is more than one track. For instance, "boss3" may be background music for a "boss" level, with a main theme (track 1) playing in loop until the boss character is defeated or wins, and then one of the other tracks is played.

 
Posted : 10/11/2021 12:47 am
Share: