fbpx


The MIDI Forum

  Tuesday, 09 November 2021
  10 Replies
  588 Visits
4
Votes
Undo
  Subscribe
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.
2 weeks ago
·
#11928
Accepted Answer
1
Votes
Undo
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 <Chunk Type> <length> <format> <ntracks> <division> 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
2 weeks ago
·
#11928
Accepted Answer
1
Votes
Undo
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 <Chunk Type> <length> <format> <ntracks> <division> 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
Nikolai selected the reply #11928 as the answer for this post — 2 weeks ago
2 weeks ago
·
#11929
1
Votes
Undo
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?

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).
2 weeks ago
·
#11930
0
Votes
Undo
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
2 weeks ago
·
#11931
0
Votes
Undo
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
2 weeks ago
·
#11932
0
Votes
Undo
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
2 weeks ago
·
#11933
0
Votes
Undo
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?
2 weeks ago
·
#11934
0
Votes
Undo
So in case you want to test them out, here they are.


Very nice, thank you. :)
2 weeks ago
·
#11935
0
Votes
Undo
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
0
Votes
Undo
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


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.
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:


> 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


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.
  • Page :
  • 1
There are no replies made for this post yet.
Be one of the first to reply to this post!