Multitrack MIDI or Multiple MIDI files

artmusicsouth's icon

I haven't used MIDI files in MAX before so forgive the ignorance.

I have some MIDI data that I can either load as one multitrack MIDI file or load at one time as multiple MIDI files (stored somehow). I then want to send that info to drive a poly~ synth. Not sure exactly how to achieve this as detonate help/ref and seq help/ref don't seem to reference loading or playing either multiple MIDI files or a multitrack file.

broc's icon

I think using multiple MIDI files is the only option in Max. But you could try to implement a "multifile" player by putting detonate into poly~ and use some file name numbering to automate loading the files into corresponding instances of detonate.

artmusicsouth's icon

Thanks, will give it a go.

seejayjames's icon

[detonate] can play Type 1 MIDI files, but it takes a bit to get the output to parse correctly. The help file needs some studying ;) ...it's not immediately plug-and-play, quite, but it does give you a lot of flexibility.

[seq] is more straightforward but only does Type 0 files. Just have as many [seq] objects as you need, running at the same time, should work fine with a master control for all at once...that is, unless you want to start offsetting some tracks, playing some faster or slower, transposing them, etc...

I'd definitely work these options into the setup (they're very easy to implement) because you'll be able to expand the possibilities of a given MIDI file a lot. And it's easy enough to have a "Default" button which would set all the [seq] objects (MIDI tracks from your file) back to playing normally. Slap some presets for the tweaking controls and you're off and running...live improvisation using a single MIDI file that previously only played back one way!

artmusicsouth's icon

That's helpful seejayjames. What I am not sure about in detonate is how to separate each track and route it to its own synth (most likely poly~). How does detonate differentiate between pitch data from multiple tracks if they are coming out simultaneously from the pitch outlet?

seejayjames's icon
Max Patch
Copy patch and select New From Clipboard in Max.

They shouldn't be exactly simultaneous, though I'm not sure how that works with timing. Anyway, try a [gate] with the Track outlet to see if you can filter out the notes from specific tracks, like this (probably are other ways to do it too):

artmusicsouth's icon

That looks interesting. I could then create multiple select --> objects that correspond to each track being sent from outlet 6 (track) and then send that data to the poly~ synth. But this assumes that the pitch data is tied directly to a track in order for the gate to only pass track specific information. Do I understand that correctly?

artmusicsouth's icon

To follow up saw this in the reference.

"In 6th inlet: The number of a track on which to record the note event. Overdub recording is not possible with detonate, but each recorded note can be tagged with a track number for storing separate tracks of notes internally. If no track number has ever been received, notes are recorded on track 1."

What I plan to do is have detonate read a Type 1 MIDI file which I will then send tracks and pitch data to drive a poly~synth.

I'll see how it goes.

Thanks again for all your help.

broc's icon
Max Patch
Copy patch and select New From Clipboard in Max.

You could use the track number to control a gate with multiple outlets.

artmusicsouth's icon

Making headway on this.

Is the first track of a type 2 midi file (the one that contains tempo data, etc.) labeled track 0 or track 1?

broc's icon

I guess you mean type 1 midi files (type 2 is quite unusual).

In my experience with midi files generated in Logic, track numbering starts at 1. So even if the first track doesn't contain midi notes, it is labeled track 1.

artmusicsouth's icon

I did mean type 1. Sorry.

I see the same thing in Logic and other programs as well. I just wonder if those programs offset the track to read as 1 even though inside the MIDI file it is a 0.

broc's icon

The tracks in a midi file are simply stored one after the other without numbering.

artmusicsouth's icon

very helpful

artmusicsouth's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Finally got around to trying to work through this. Below is the patch I built based off seejay's example. I want to plug this into a poly~ synth but I am not able to get any data out (it appears) when I hit start. (It is not connected to a MIDI keyboard at all; all internal). Any help on troubleshooting would be great.

artmusicsouth's icon

Bump for rising frustration in not getting it to work.

Looked at ajm.midi2coll and note~ but still no luck.

Alexandre's icon

Dl the cnmat stuff: http://cnmat.berkeley.edu/downloads and try midifile.help.pat

Alexandre's icon

hmm finally it seems ftm.play.maxhelp is more versatile to me (from http://ftm.ircam.fr/index.php/Main_Page )