fbpx
Skip to main content

MIDI Forum

SMF Format 1 Tracks...
 
Notifications
Clear all

SMF Format 1 Tracks and Channels

7 Posts
4 Users
0 Reactions
13.3 K Views
Malcolm
Posts: 9
Active Member
Topic starter
 

Hi there.

I'm writing some software that can read and write Standard MIDI Files, and there's one aspect about which I'm a little unsure.

As far as I can tell, it is consistent with the specification that a track in a Format 1 file carries messages for multiple channels. However, no files I have ever seen does this, and I cannot see any discussion of this possibility anywhere I've searched.

Can anyone here confirm that a file like this is definitely conformant and whether other SMF implementations might be expected to handle it correctly? (It would be great if someone could point me somewhere which explicitly clarifies this question.)

By contrast, I have seen it mentioned in several places that more than one track can have messages for the same channel, and I have seen such files in the wild. I'm going to assume that files with this property are conformant.

Thanks for any advice,

Malcolm

 
Posted : 02/05/2021 2:11 am
Geoff
Posts: 1039
Noble Member
 

What would be the point of having multiple channels in a single track?

In most cases, you are limited to 16 channels, but most software offers many time that number of tracks. For simple tidyness, one would assign each channel to it's own track, and maybe multiple tracks to the same channel. There is usually no shortage/limit to tracks.

I have however seen cases where a single track might be used for multiple instruments, with PC commands to switch, but using the same channel. This again is more to do with tidyness, no point in leaving each instrument on a whole track if it's there for a few bars only.

Certainly, a single track in a type 1 midi file could happily carry messages for multiple channels, exactly as the single track in a type 0 midi file would do. Just makes managing the data more complicated.

Geoff

 
Posted : 02/05/2021 6:03 am
Bavi_H
Posts: 266
Reputable Member
 

TRACK WITH MULTIPLE CHANNELS

I interpret the spec as technically allowing a Format 1 track to contain multiple channels, since it doesn't specifically mention otherwise. [EDIT 2021-05-03: On the Standard MIDI Files specifications page I noticed the specification "SMF Device Name and Program Name Meta Events" mentions "Each track of a MIDI File can contain one MIDI stream, including SysEx and up to 16 channels." So it looks like the MMA supports a track containing multiple channels.] But my experience with various MIDI software is that the results of doing this are mixed. MIDI sequencers are often designed around the idea that each track should only contain a single channel.

From my memories, some software will force a track's messages to a single channel. Some software will move each additional channel in a track out to their own separate tracks. Some software's track list window will display a track with the first channel number it finds in the track, obscuring the fact that there are multiple channels in the track.

This variable software behavior can make it difficult to tell how the original tracks in the MIDI file are actually set up, and make it confusing to talk about the MIDI file with other people using different software. It can become a mess of misunderstanding and people thinking the other person's MIDI software is broken or the MIDI file is corrupt.

Take a look at this thread about a problematic MIDI file with tracks containing multiple channels. The file discussed in this thread is a demo medley of different pieces, possibly made by someone copying and pasting different MIDI files into one, but it looks the composer gave up and left the end of the MIDI file empty and incomplete. The file contains 15 note tracks having multiple channels, but as an example, one post shows screenshots of a Yamaha MIDI sequencer that splits them into many more tracks each with a single channel.

CHANNEL ON MULTIPLE TRACKS

Storing a particular channel's messages on multiple tracks is less problematic because they're easily visible in MIDI software, but there can still be issues. When a channel is on multiple tracks, the tracks could inadvertently contain conflicting messages, such as different volume or pitch bend.

The biggest issue to watch out for is multiple notes of the same pitch and channel starting or ending at the same time. Take a look at this example I encountered in a MIDI file I made (the MIDI file attached to this post):

Track 3 and 4 use the same channel. Track 3 has an E-flat starting a measure 19, beat 4. Track 4 has an E-flat ending at measure 19, beat 4.

In one MIDI sequencer I use, that Track 3 note sounds like a blip because the Track 3 note is started, then immediately ended by the Track 4 note ending message.

Other MIDI sequencers and players I use happen to work in this instance. I guess when there are messages at the exact same time on different tracks that both start a note and end a note of the same pitch and channel, they decide the note ending message should be sent first, even if it appears on a later track than the note starting message.

SUGGESTIONS

I sometimes dream about how I would design MIDI software to handle these cases (a track with multiple channels, or a channel on multiple tracks having conflicting messages). I'd want these cases to be visible and not secretly changed -- I think it's important to show exactly what's in the MIDI file. But I'd also want them to be highlighted as potential issues and maybe provide a way to convert it to a format that is more compatible with other MIDI software.

If you are composing MIDI files, my suggestion is to avoid putting multiple channels in a track, it will likely cause issues and confusion in lots of MIDI software.

If you want to put a channel on multiple tracks, be sure to check for conflicting messages on the different tracks. Consider if just using different channels will be easier.

 
Posted : 02/05/2021 6:43 am
Eddie Lotter
Posts: 295
Reputable Member
 

As others have mentioned, it is perfectly legal to use multiple channels in a single track. It is only a convention to use a single channel per track.

This is very useful because, as a practical example, you might have a six-string lead guitar on track 1 that uses channels 1 through 6, and a four-string bass guitar on track 2 that uses channels 11 through 14.

 
Posted : 02/05/2021 7:15 am
Malcolm
Posts: 9
Active Member
Topic starter
 

Thanks Geoff and Bavi! That's really useful info.

I conclude that it is legal, as I suspected and feared. However, your answers have persuaded me that it is clearly not advised and probably very rare.

I think I won't jump through hoops to support this scenario, or at least, support it in a convenient way.

Thanks again!

Malcolm

 
Posted : 02/05/2021 7:24 am
Malcolm
Posts: 9
Active Member
Topic starter
 

Thanks also Eddie. Useful to know.

After some iteration, I have a way of supporting this scenario. I will privilege the first channel encountered, but if additional channel messages are present, the data is accessible, just not quite as naturally. Since my application currently has 0 users, I do not expect too many complaints.

Malcolm

 
Posted : 02/05/2021 8:26 am
Bavi_H
Posts: 266
Reputable Member
 

Oh, by the way, on the Standard MIDI Files specifications page I noticed the specification "SMF Device Name and Program Name Meta Events" mentions "Each track of a MIDI File can contain one MIDI stream, including SysEx and up to 16 channels." So it looks like the MMA supports a track containing multiple channels.

 
Posted : 03/05/2021 6:46 pm
Share: