fbpx
Skip to main content

MIDI Forum

MIDI file request
 
Notifications
Clear all

MIDI file request

68 Posts
8 Users
0 Reactions
16.6 K Views
Carlos
Posts: 86
Estimable Member
Topic starter
 

[quotePost id=14581]
I've interpreted Type 2 MIDI files as being a way to store a collection of Type 0 MIDI files in a single file. I also imagined the Sequence Number and/or Sequence/Track Name meta events could be used at the beginning of each track in a Type 2 MIDI file to help identify each track as part of some overall collection. For example, I have imagined that a drum machine might export all of its drum patterns to a single Type 2 MIDI file, with each track representing one pattern, beginning with a Sequence Number meta event to store the pattern number. However, I have no idea if anything like this was ever actually done.
[/quotePost]

So each track in a format 2 file would be just as a format 0 file there is no format 1

[quotePost id=14584]The data in the separate sections are held in the main file as separate tracks. There isn't any explicit reset to 000. But the fact that it's a type 2 file means that the data is not merged to a single time frame (as would happen with a type 1 file) but the sections remain sequential.
[/quotePost]

Now I understand, I'm going to do some experiments with it.

 
Posted : 15/05/2022 9:12 am
Bavi_H
Posts: 267
Reputable Member
 

[quotePost id=14582]I found the file I was thinking of. May well have come from Jonas, you may already have got it. I think the file originates from a StarWars game of some type. [...] I attach a .zip file. This contains the original empire.mid [...][/quotePost]Yes, this empire.mid is exactly the same as the one from the previous thread Jason mentioned.

[quotePost id=14582]you will see two small sections, each of which has the delta time reset to 000. In one case, there's a note that is turned ON before the 'break', and turned OFF in the new section.[/quotePost]Note that the only places the tick position gets reset to zero is when a new track starts, so that is perfectly normal.

However, as you mentioned, near the end of the first track, there is a message to start a channel 3 G note that is never ended. And in the second track, the only note message that exists at all is a message to end the same channel 3 G note. Those unbalanced note messages are abnormal in usual circumstances.

Since these tracks are presumably MIDI snippets that a video game can switch between, it might possibly make sense to have a note split across snippets, but it would have to be handled carefully to avoid leaving a note stuck sounding. Alternatively, it could also just be some editing glitch that got left in the file.

[quotePost id=14583]doesn't it play all 3 tracks at once?[/quotePost]In a Type 2 MIDI file, the tracks are not intended to be played at the same time -- each track is a separate piece of music.

In the example Type 2 MIDI files extracted from Star Wars: Dark Forces, the tracks appear to be music snippets the game can switch between depending on the action happening in the game. According to my understanding, this seems similar to the idea behind a standard Type 2 MIDI file, but is a little bit different.

For example, I believe a standard Type 2 MIDI file should have appropriate set up messages at the beginning of every track. However in these example Type 2 MIDI files extracted from Star Wars: Dark Forces, only the first track in each file appears to have Program Change messages to set up the instrument sounds for each channel. Supposedly the other tracks would eventually be played at some point after the first track had started and reuse the same instrument sounds that were set up.

 
Posted : 15/05/2022 9:14 am
Carlos
Posts: 86
Estimable Member
Topic starter
 

[quotePost id=14586]In a Type 2 MIDI file, the tracks are not intended to be played at the same time -- each track is a separate piece of music.[/quotePost]

http://midi.teragonaudio.com/tech/midifile.htm

How do you know which sequence to play? In the case of the game file, it is special because it is controlled by the game itself. Does it have anything to do with this?
http://jac.michaeldrolet.net/SCS_10_Help/scs_options_mid_msc.htm

 
Posted : 15/05/2022 1:31 pm
Bavi_H
Posts: 267
Reputable Member
 

[quotePost id=14589] http://midi.teragonaudio.com/tech/midifile.htm [/quotePost] The MIDI Technical Fanatic's Brainwashing Center (midi.teragonaudio.com) contains pretty good descriptions of MIDI specifications, but be aware that it is not official and sometimes gets some details wrong. It's always a good idea to look at the official specifications in the midi.org Specs section first, then read other sites for comparison.

The official specification for Standard MIDI Files doesn't do a very good job of explaining the difference between Type 0, 1, and 2 MIDI files. The MIDI Technical Fanatic's Brainwashing Center page that describes Type 0, 1, and 2 MIDI files has more details. But it might still take a while of looking at example MIDI files and experimenting with MIDI file players and editors to get a good understanding of the differences.

Unfortunately, the Type 2 MIDI file format is so rare or non-existent that most MIDI software doesn't support it at all. I can give you my idea about how I think it should work, but be aware it is mainly just something that MIDI nerds like to talk about.

[quotePost id=14589]How do you know which sequence to play?[/quotePost] I like to imagine a Type 2 MIDI file is sort of like a zip file that contains several Type 0 MIDI files. You would have to let the user choose which track to play. They might only want to play one track. They might want to play all the tracks in order one after another.

If I were creating a MIDI file editor and I wanted it to open Type 2 MIDI files, then right after the user selects the file in the Open dialog box, I might want it to show a list of the tracks and let the user pick which one to work on. Then the editor would open that track and show it the same way it would show a Type 0 MIDI file. Later, the user could go back to the special track list window to add, remove, or re-order individual tracks and save the overall Type 2 MIDI file.

Alternatively, when the user opens a Type 2 MIDI file, I might want it to add all the tracks one after another on the same timeline in the editor, but show a special dividing line between tracks, and restart the timeline number labels at 0 seconds or bar 1 at the beginning of each track.

If I were creating a MIDI file player and I wanted it to open Type 2 MIDI files, I would probably load all the tracks as separate items in a playlist, so it can just play them one after another. I would also let the user remove or re-order the items in the playlist without affecting the original Type 2 MIDI file, only the playlist would be affected.

[quotePost id=14589]Does it have anything to do with this?
http://jac.michaeldrolet.net/SCS_10_Help/scs_options_mid_msc.htm [/quotePost] That page is about MIDI Show Control messages. MIDI Show Control messages are for controlling devices for a light show, smoke effects, or fireworks at a concert.

 
Posted : 15/05/2022 8:33 pm
Carlos
Posts: 86
Estimable Member
Topic starter
 

[quotePost id=14590]I like to imagine a Type 2 MIDI file is sort of like a zip file that contains several Type 0 MIDI files. You would have to let the user choose which track to play. They might only want to play one track. They might want to play all the tracks in order one after another.[/quotePost]

That's what I was thinking but I wasn't sure if it was correct, it's still much better than just saying it's a midi type 2 which isn't supported like musescore or timidity does.

 
Posted : 16/05/2022 5:33 am
Jason
Posts: 441
Honorable Member
 

For LARGE MIDI files, you can have a look here:
http://www.midimusicadventures.com/queststudios/midi-soundtracks/complete-soundtracks/
These are soundtracks from old PC games made by Sierra/Quest Studios.

Some of the files are a collection of the entire soundtrack from a game merged in to one giant file. ROBIN-GS is 446 KB. Note though that some of the files may not be 100% "correct", as they may have artifacts left over from the original merging process (like invalid drum kits, or a mismatched MIDI file format mixed in with the others [old MT-32 vs GM vs GS]) so don't be alarmed if you come across something that doesn't look right, because there's a good chance it's not πŸ˜‰

 
Posted : 16/05/2022 4:04 pm
Sema
 Sema
Posts: 182
Reputable Member
 

Just found out...
Windows Media Player does not care about type 2 MIDI files, it plays both tracks simultaneously.
It also does not mind if a type 0 MIDI file has more than one track, just plays all as type 1.
You can try these with other players...

 
Posted : 16/05/2022 7:25 pm
Carlos
Posts: 86
Estimable Member
Topic starter
 

[quotePost id=14598]For LARGE MIDI files, you can have a look here:
http://www.midimusicadventures.com/queststudios/midi-soundtracks/complete-soundtracks/ [/quotePost]

Thanks, it has really big midi files 1.4 mb

The midi file indicates in some way if it is GM Level1 or GM Level2, because at GM level1 the notes transmitted by channel 10 are percussion, in level2 it uses channel 10 and 11, I even have a midi file that has the drums for the channel 7, it sounds like drums because it uses the bank select but I don't know how to detect that it's drums and not a piano
(strange that uncompressed midi files cannot be uploaded πŸ˜€ )

 
Posted : 18/05/2022 9:59 am
Carlos
Posts: 86
Estimable Member
Topic starter
 

[quotePost id=14599]Just found out...
Windows Media Player does not care about type 2 MIDI files, it plays both tracks simultaneously.
It also does not mind if a type 0 MIDI file has more than one track, just plays all as type 1.
You can try these with other players...[/quotePost]

Thanks.
VLC only plays file type 1.
Musescore shows only one track of type 0, two tracks of type 1 and does not open type 2
Audacity shows both tracks of the 3 files in the same way

would there be any reason to indicate an error when a file type 0 has more than one track? because it could just be opened as type 1

 
Posted : 18/05/2022 10:29 am
Jason
Posts: 441
Honorable Member
 

[quotePost id=14608]The midi file indicates in some way if it is GM Level1 or GM Level2, because at GM level1 the notes transmitted by channel 10 are percussion, in level2 it uses channel 10 and 11, I even have a midi file that has the drums for the channel 7, it sounds like drums because it uses the bank select but I don't know how to detect that it's drums and not a piano[/quotePost]
This file is an XG file. There are three major formats of MIDI files: GM (GM1 and GM2, soon to add GM 2.0); GS; XG

Each one has specific things it uses to set percussion.

Here's a screenshot from my instrument switcher which shows the breakdown of what's what in this file.
It has 3 GM SYSEX commands, and an additional 82 XG SYSEX commands (one being the XG System On/Reset).
It has percussion on 4, 5, and 7.

GM percussion is always on Channel 10.
GM2 percussion can be on 10 and/or 11, set with MSB = 120 (instrument channels have MSB = 121)

GS percussion can be on any channel, and is set with a SYSEX command. Here's my code comments for checking this
[code type=markup]
// GS Custom Percussion Assignment
// F0 0A 41 (10) 42 12 [40 1A 15] [02] 0F F7
// [.. 1x ..] x = part# / (probably) ch# 1-9, 0, A-F
// [0y] y = type: 0 = standard, 1 = drum map 1, 2 = drum map 2
[/code]

XG sets percussion with bank selects MSB = 127 (normal percussion kits), MSB = 126 (SFX percussion kits), MSB = 64 (individual SFX bank)

[quotePost](strange that uncompressed midi files cannot be uploaded πŸ˜€ )[/quotePost]
We all agree πŸ˜‰

 
Posted : 18/05/2022 11:31 am
Jason
Posts: 441
Honorable Member
 

I learned a LOT about MIDI over the past year+. If you click on my profile and go to my posts, you can see all of the questions I've asked along the way, many of which seem to be a point you might be at now in developing your own software. This forum is very helpful for such things πŸ™‚

 
Posted : 18/05/2022 12:44 pm
Geoff
Posts: 1047
Noble Member
 

Hello,

Very interesting to be reminded about the website re the adventures/queststudios.

I'd been to that site some time ago, but lost the links to it. Seeing it again, I note the reference to the long/complete soundtracks. I need to check some of them out.

I use the Roland card LAPC-I as part of my midi system, this is MT-32 compat, so it will respond to the SYSEX load of the special sounds (instruments & sound effects). I've heard bits from other soundtracks and these special sounds can add a LOT to the effectiveness of the soundtrack. This is of course one of the interesting aspects of the Roland card, there are so many 'extras' readily available. My Yamaha MU90r has a C/M mode as an alternative to the default XG mode, and this will cope with the 'normal' MT-32 sound set, but this does NOT allow the special/extra sounds as the sound programming is totally different.

Geoff

 
Posted : 18/05/2022 1:58 pm
Carlos
Posts: 86
Estimable Member
Topic starter
 

[quotePost id=14610]
GM percussion is always on Channel 10.
GM2 percussion can be on 10 and/or 11, set with MSB = 120 (instrument channels have MSB = 121)

GS percussion can be on any channel, and is set with a SYSEX command.
[/quotePost]

Finding what instrument is playing is harder than it seems and here I thought I could completely ignore sysex messages.
I found https://midi.org/forum/8860-general-midi-level-2-ch-11-percussion according to what I understand I must first search SYSEX to know if it is GM, GS or XG what are the sysex messages for each one ? Can there be more than one at a time?.
The bank selector allows many different instruments, is there a list with the names? although perhaps there are too many more than 2 million, right?
what if you have an instrument (program) 113 to 120 on a channel other than 10?

I don't understand this
[code type=markup]
// F0 0A 41 (10) 42 12 [40 1A 15] [02] 0F F7
// [.. 1x ..] x = part# / (probably) ch# 1-9, 0, A-F
// [0y] y = type: 0 = standard, 1 = drum map 1, 2 = drum map 2
[/code]
where does 1x and 0y go?
[code type=markup]F0 -> start sysex
0A -> variable length of 10 bytes
41
10 -> ΒΏchannel?
42
12
40
1A -> 1x?
15
02 -> 0y?
0F
F7 -> end sysex[/code]

 
Posted : 18/05/2022 4:02 pm
Jason
Posts: 441
Honorable Member
 

I found https://midi.org/forum/8860-general-midi-level-2-ch-11-percussion according to what I understand I must first search SYSEX to know if it is GM, GS or XG what are the sysex messages for each one ? Can there be more than one at a time?.

This post has useful info about the SYSEX resets:

https://midi.org/forum/8742-do-midi-files-store-gm-gs-xg-indicator-info

While it is helpful for them to be in a MIDI file, sometimes they are not. Actual MIDI hardware can be set to already be in a specific mode, so wouldn't need the reset per se. Some players will automatically detect the type, and if one can't be determined, will revert to GM.

Things that I look for in my program when parsing a MIDI file:
SYSEX resets
- GM1, GM2, GS, XG
Bank Selects
- GM1 does not have bank selects, so if there are none, there's a good chance it's GM1.
- GM2 should have MSB set to 121 for instruments, MSB set to 120 for percussion (though some of the files I have are they not all properly set)
- XG will have LSB values set (GM and GS do not generally use LSB values, while XG does the opposite and uses mostly LSB values)

Finding what instrument is playing is harder than it seems and here I thought I could completely ignore sysex messages.

Welcome to the club πŸ˜‰ The more I learn, the more I have to fix my program.

The bank selector allows many different instruments, is there a list with the names? although perhaps there are too many more than 2 million, right?
what if you have an instrument (program) 113 to 120 on a channel other than 10?

Theoretically there could be a maximum of 2,097,152 if every MSB and LSB and Program Change were used. But thankfully they are not.

As for a list, I have several taken from instrument definition files for Cakewalk, which are the most complete that I have found. I got some of them from just searching on Google, I think a few also came from the website for Seikaju.
The Roland SC-8850 was the last GS device to be released by Roland (I believe) and has the largest GS compatibility/instrument list (that I am aware of).
I have lists from a couple of the most recent Yamaha XG devices.
GM1 is a standard list of 128 instruments and... I forget how many percussion. GM2 added additional banks of instruments and percussion. I have another file that includes those.

See attachments for these lists. You can also look in the official manuals for the SC-8850 and the assorted Yamaha manuals, but I found it much easier (after spending DAYS compiling my own lists from the manuals) to use the pre-made instrument definition files.
GM1_GM2.ins - GM1 and GM2 names
sw1000xg.ins - big list of (shorter) XG names
9000PROv100.ins - smaller, but nicer list of XG names (I read in all the shorter names from sw1000xg, then replace any matches with nicer names from this list)
Roland_SC-8850.ins - GS names
plus a few extra that I ended up not using.

where does 1x and 0y go?

Where you have them. πŸ™‚

I don't understand this

That is my own comments for how I handle it. I ignore the parts in ( ), as it can contain different numbers (device ID I believe) that I don't need to determine if it is a GS reset.
The "part #" and "type" are described in the Roland user manuals for different devices. I think one of my previous posts we talked about it, but I am too tired at the moment to be able to think about it any more tonight. πŸ˜‰

Hopefully this helps out a bit.

 
Posted : 18/05/2022 9:52 pm
Jason
Posts: 441
Honorable Member
 

Ahh, so now that I am more awake, here's what I check for each of the SYSEX. This is what works for my particular usage, You may or may not need the same.

I scan the file byte by byte, and a SYSEX event is found and flagged with F0. I then check the length byte, and from there further check the rest of the SYSEX to see if it a reset.

For GM1 System On and GM2 System On
[code type=markup]
// GM reset
// F0 7E 7F 09 01 F7 (GM1 hardware)
// F0 05 7E 7F 09 01 F7 (GM1 software)
// F0 7E 7F 09 03 F7 (GM2 hardware)
// F0 05 7E 7F 09 03 F7 (GM2 software)
case 0x05:
cur_pos = buffer_tell(global.edit_buffer);
if ((buffer_peek(global.edit_buffer, cur_pos, buffer_u8) == 0x7E) &&
(buffer_peek(global.edit_buffer, cur_pos + 1, buffer_u8) == 0x7F) &&
(buffer_peek(global.edit_buffer, cur_pos + 2, buffer_u8) == 0x09) &&
((buffer_peek(global.edit_buffer, cur_pos + 3, buffer_u8) == 0x01) || (buffer_peek(global.edit_buffer, cur_pos + 3, buffer_u8) == 0x03)) &&
(buffer_peek(global.edit_buffer, cur_pos + 4, buffer_u8) == 0xF7))
[/code]

For Yamaha XG Reset
[code type=markup]
// Yamaha XG reset
// F0 43 (10) 4C 00 00 7E 00 F7 (hardware)
// F0 08 43 (10) 4C 00 00 7E 00 F7 (software)
case 0x08:
cur_pos = buffer_tell(global.edit_buffer);
if ((buffer_peek(global.edit_buffer, cur_pos, buffer_u8) == 0x43) &&
/*(buffer_peek(global.edit_buffer, cur_pos + 1, buffer_u8) == 0x10) &&*/
(buffer_peek(global.edit_buffer, cur_pos + 2, buffer_u8) == 0x4C) &&
(buffer_peek(global.edit_buffer, cur_pos + 3, buffer_u8) == 0x00) &&
(buffer_peek(global.edit_buffer, cur_pos + 4, buffer_u8) == 0x00) &&
(buffer_peek(global.edit_buffer, cur_pos + 5, buffer_u8) == 0x7E) &&
(buffer_peek(global.edit_buffer, cur_pos + 6, buffer_u8) == 0x00) &&
(buffer_peek(global.edit_buffer, cur_pos + 7, buffer_u8) == 0xF7))
[/code]

And for Roland GS Reset
[code type=markup]
// GS reset
// F0 41 (10) 42 12 40 00 7F 00 41 F7 (hardware)
// F0 0A 41 (10) 42 12 40 00 7F 00 41 F7 (software)
case 0x0A:
cur_pos = buffer_tell(global.edit_buffer);
if ((buffer_peek(global.edit_buffer, cur_pos, buffer_u8) == 0x41) &&
/*(buffer_peek(global.edit_buffer, cur_pos + 1, buffer_u8) == 0x10) &&*/
(buffer_peek(global.edit_buffer, cur_pos + 2, buffer_u8) == 0x42) &&
(buffer_peek(global.edit_buffer, cur_pos + 3, buffer_u8) == 0x12) &&
(buffer_peek(global.edit_buffer, cur_pos + 4, buffer_u8) == 0x40) &&
(buffer_peek(global.edit_buffer, cur_pos + 5, buffer_u8) == 0x00) &&
(buffer_peek(global.edit_buffer, cur_pos + 6, buffer_u8) == 0x7F) &&
(buffer_peek(global.edit_buffer, cur_pos + 7, buffer_u8) == 0x00) &&
(buffer_peek(global.edit_buffer, cur_pos + 8, buffer_u8) == 0x41) &&
(buffer_peek(global.edit_buffer, cur_pos + 9, buffer_u8) == 0xF7))
[/code]

The GM1 and GM2 System On do not specify a device.
The XG and GS DO specify a device ID of some sort. For my purposes, it is not relevant, so I check every byte except for the ID byte.

And finally, for the GS percussion channel assignment SYSEX.
Information about this can be found.... in the manual? I'll have to dig through my stuff when I have more time to see where I got it from. I just did a quick look through the SC-8850 manual but didn't see it, but I'm sure it's in there. SYSEX explanations start around page 229.
https://cdn.roland.com/assets/media/pdf/SC-8850_OM.pdf
[code type=markup]
// GS Custom Percussion Assignment
// F0 0A 41 (10) 42 12 [40 1A 15] [02] 0F F7
// [.. 1x ..] x = part# / (probably) ch# 1-9, 0, A-F
// [0y] y = type: 0 = standard, 1 = drum map 1, 2 = drum map 2
else if ((buffer_peek(global.edit_buffer, cur_pos, buffer_u8) == 0x41) &&
/*(buffer_peek(global.edit_buffer, cur_pos + 1, buffer_u8) == 0x10) &&*/
(buffer_peek(global.edit_buffer, cur_pos + 2, buffer_u8) == 0x42) &&
(buffer_peek(global.edit_buffer, cur_pos + 3, buffer_u8) == 0x12) &&
(buffer_peek(global.edit_buffer, cur_pos + 4, buffer_u8) == 0x40) &&
/*(buffer_peek(global.edit_buffer, cur_pos + 5, buffer_u8) == 0x00) &&*/
(buffer_peek(global.edit_buffer, cur_pos + 6, buffer_u8) == 0x15) &&
/*(buffer_peek(global.edit_buffer, cur_pos + 7, buffer_u8) == 0x00) &&*/
(buffer_peek(global.edit_buffer, cur_pos + 8, buffer_u8) == 0x0F) &&
(buffer_peek(global.edit_buffer, cur_pos + 9, buffer_u8) == 0xF7))
{
part_num = buffer_peek(global.edit_buffer, cur_pos + 5, buffer_u8);
part_num -= 0xF;
part_type = buffer_peek(global.edit_buffer, cur_pos + 7, buffer_u8);
global.custom_drums[part_num - 1] = part_type;
}
[/code]

 
Posted : 19/05/2022 6:17 am
Page 2 / 5
Share: