Forums > MaxMSP

Creating a Midi file

April 15, 2008 | 12:55 am

Certainly it must be possible to generate a midi file with a time signature in it. The midi file created by my patch should open 3/8 instead of the standard 4/4. Is there ways to do such from within max? Or do I have to wait until 22nd…

_
johan


April 15, 2008 | 2:44 am

The seq object in max does not record midi meta events including time
signatures and key signatures. Maybe in Max 5? Multi-track sequences too?

Cheers
Gary Lee Nelson
Oberlin College
http://www.timara.oberlin.edu/GaryLeeNelson

> From: jvkr
> Organization: Cycling ’74
> Reply-To:
> Date: Tue, 15 Apr 2008 02:55:21 +0200
> To:

> Subject: [maxmsp] Creating a Midi file
>
>
> Certainly it must be possible to generate a midi file with a time signature in
> it. The midi file created by my patch should open 3/8 instead of the standard
> 4/4. Is there ways to do such from within max? Or do I have to wait until
> 22nd…
>
> _
> johan


May 3, 2008 | 9:20 am

Quote: Gary Lee Nelson wrote on Tue, 15 April 2008 04:44
—————————————————-
> The seq object in max does not record midi meta events including time
> signatures and key signatures. Maybe in Max 5? Multi-track sequences too?

As this is not the case…

> > Certainly it must be possible to generate a midi file with a time signature in
> > it. The midi file created by my patch should open 3/8 instead of the standard
> > 4/4. Is there ways to do such from within max? Or do I have to wait until
> > 22nd…

… replying to myself (for the record), changing or adding meta events is possible with javascript. A good start is the example for file i/o and the midi file-format description to be found eg here:

http://www.borg.com/~jglatt/tech/midifile.htm

_
johan


May 4, 2008 | 7:27 am

Cheers
Gary Lee Nelson
TIMARA Department
Oberlin College
http://www.timara.oberlin.edu/GaryLeeNelson

On May 3, 2008, at 11:20 AM, jvkr wrote:

>
> Quote: Gary Lee Nelson wrote on Tue, 15 April 2008 04:44
> —————————————————-
>> The seq object in max does not record midi meta events including time
>> signatures and key signatures. Maybe in Max 5? Multi-track
>> sequences too?
>
> As this is not the case…

Which part is not the case. i haven’t checked recently but when I
did try, seq ignored mete events.
I wrote my own program in APL to accept text based midi data and
create a multitrack midi file
(using the spec below) that includes time signatures, titles, etc. I
am currently testing MaxScore
for this so I can go directly to a MusicXML file that Finale
understands.

This works for exporting to Finale and Sibelius. What I am missing
is an object that will read and
play type 1 midi files made perhaps with finale, sibelius or other
programs that write midi files.

>
>
>>> Certainly it must be possible to generate a midi file with a time
>>> signature in
>>> it. The midi file created by my patch should open 3/8 instead of
>>> the standard
>>> 4/4. Is there ways to do such from within max? Or do I have to
>>> wait until
>>> 22nd…
>
> … replying to myself (for the record), changing or adding meta
> events is possible with javascript. A good start is the example for
> file i/o and the midi file-format description to be found eg here:
> http://www.borg.com/~jglatt/tech/midifile.htm
>
This spec is well known to me. I have been handling midi files in
Pascal and C since the spec came out.

> _
> johan
>


June 5, 2008 | 12:26 am

I’d also like to know of a way to record changing time signature MIDI meta events while recording sequences within Max using seq, detonate, or another approach that can write a standard MIDI sequence file once the data is recorded.

Does anyone know if this capability is available now in an object in Max 5?

Any pointers to more information or help is greatly appreciated.

–B


June 18, 2008 | 3:21 pm

I have come across an object by John MacCallum at CNMAT called "mxj midifile" that enables playing and recording midi meta events along with other midi data. This is done using the "addMetaEvent" time-stamped message which is followed by the data needed for each type of meta message (see MIDI spec for meta event numbers and necessary data). Mxj midifile reads and writes type 0 (and type 1, I think) standard midi files much like seq and detonate.

John MacCallum’s object can be found at the CNMAT download site:

http://cnmat.berkeley.edu/downloads

Thanks to John and the folks at CNMAT.

Bill

an example:

max v2;
#N vpatcher 29 53 774 896;
#P origin 0 -52;
#P window setfont "Sans Serif" 9.;
#P window linecount 6;
#P comment 110 352 52 196617 Elasped time (ms) used for time-stamping events;
#P window setfont "Sans Serif" 10.;
#P window linecount 1;
#P comment 24 29 686 196618 Based on mxj midifile by John Mccallum (CNMAT) — modified here by W. Kleinsasser;
#P comment 24 16 686 196618 Play and record standard midi file sequences including meta events (tempo changes , time signature changes , key signature changes);
#P window setfont "Sans Serif" 9.;
#P newex 416 487 34 196617 r key;
#P newex 297 487 45 196617 r tempo;
#P newex 141 487 62 196617 r time_sigs;
#P newex 30 487 42 196617 r notes;
#P newex 563 341 34 196617 s key;
#P newex 481 341 45 196617 s tempo;
#P newex 349 341 62 196617 s time_sigs;
#P newex 224 341 42 196617 s notes;
#N vpatcher 10 59 413 670;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 146 275 57 196617 1 = minor;
#P number 107 259 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P comment 146 260 57 196617 0 = major;
#P comment 98 220 235 196617 negative numbers indicate number of flats;
#P number 59 204 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 207 62 79 196617 r master_clock;
#P newex 59 178 58 196617 unpack 0 0;
#P newex 59 357 34 196617 t b i;
#P newex 59 392 27 196617 int;
#P newex 60 119 27 196617 t b l;
#P message 59 158 108 196617 0 0;
#P newex 60 94 62 196617 prepend set;
#P newex 59 415 59 196617 pack 0 0 0;
#P newex 77 472 142 196617 prepend set addMetaEvent 89;
#P newex 60 436 27 196617 t b l;
#P message 60 512 157 196617 addMetaEvent 89 470 0 0;
#P window linecount 0;
#P comment 77 63 91 196617 event in;
#P comment 288 64 91 196617 clock in;
#P inlet 60 62 15 0;
#P window linecount 1;
#P comment 81 537 179 196617 as timestamped key_signature change;
#P outlet 60 537 15 0;
#P window linecount 0;
#P comment 98 205 235 196617 positive numbers indicate number of sharps;
#P connect 12 1 11 0;
#P connect 12 0 11 0;
#P connect 11 0 15 0;
#P connect 15 0 17 0;
#P connect 17 0 14 0;
#P connect 14 0 13 0;
#P connect 13 0 9 0;
#P connect 3 0 10 0;
#P connect 10 0 12 0;
#P connect 9 0 7 0;
#P connect 7 0 6 0;
#P connect 8 0 6 0;
#P connect 6 0 1 0;
#P fasten 16 0 13 1 212 384 81 384;
#P connect 7 1 8 0;
#P connect 14 1 9 1;
#P connect 15 1 20 0;
#P connect 20 0 9 2;
#P pop;
#P newobj 416 506 124 196617 p convert key_sig events;
#P comment 561 402 72 196617 key sig events;
#P comment 484 402 72 196617 tempo events;
#P comment 352 402 100 196617 time sig events;
#P comment 224 402 100 196617 note events;
#P message 561 384 34 196617 0 0;
#P newex 561 363 62 196617 prepend set;
#P window setfont "Sans Serif" 18.;
#P comment 24 454 670 196626 RECORD SEQUENCE MAINTAINING META EVENTS (TIME SIG , TEMPO , KEY SIG);
#P window setfont "Sans Serif" 9.;
#P comment 29 91 178 196617 http://cnmat.berkeley.edu/downloads;
#P window linecount 2;
#P comment 295 55 260 196617 Unlike seq and detonate , mxj midifile can record time signature , tempo , and key signature midi meta events;
#P window linecount 1;
#P newex 261 626 32 196617 sel 1;
#P newex 261 606 32 196617 r tog;
#P message 483 384 34 196617 120.;
#P newex 483 363 62 196617 prepend set;
#P hidden message 31 133 14 196617 1;
#P hidden newex 31 109 48 196617 loadbang;
#P window setfont "Sans Serif" 14.;
#P number 38 354 71 14 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont "Sans Serif" 9.;
#N vpatcher 10 59 213 256;
#P window setfont "Sans Serif" 9.;
#P newex 96 126 79 196617 s master_clock;
#P outlet 77 125 15 0;
#P number 77 103 76 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 77 60 32 196617 r tog;
#P newex 77 81 52 196617 clocker 1;
#P connect 1 0 0 0;
#P connect 0 0 2 0;
#P connect 2 0 3 0;
#P connect 2 0 4 0;
#P pop;
#P newobj 38 332 59 196617 p clock;
#P button 375 185 15 0;
#P button 356 185 15 0;
#P newex 356 223 32 196617 s tog;
#P message 375 203 14 196617 0;
#P message 356 203 14 196617 1;
#P message 223 384 92 196617 64 0 10;
#P newex 223 363 62 196617 prepend set;
#P message 350 384 92 196617 5 8. 12 8;
#P window setfont "Sans Serif" 14.;
#P window linecount 2;
#P comment 30 52 250 196622 mxj midifile object by John MacCallum (CNMAT);
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 328 286 240 196617 < - bangs when done playing or dumping sequence;
#P button 310 283 15 0;
#P button 580 170 15 0;
#P window linecount 2;
#P comment 624 207 68 196617 start time in miliseconds;
#P flonum 580 189 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P message 580 211 44 196617 play $1;
#P flonum 31 153 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 31 175 97 196617 setTempoFactor $1;
#P message 249 170 35 196617 pause;
#P newex 350 363 62 196617 prepend set;
#P message 285 170 29 196617 stop;
#P newex 178 418 43 196617 noteout;
#P newex 178 310 510 196617 route note time_sig tempo key_sig;
#P message 210 170 38 196617 play 0;
#P message 178 170 30 196617 read;
#P newex 178 258 209 196617 mxj midifile 16;
#B color 8;
#N vpatcher 10 59 443 647;
#P window setfont "Sans Serif" 9.;
#P window linecount 0;
#P newex 278 50 79 196617 r master_clock;
#P number 89 318 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 89 294 71 196617 expr 60./$f1;
#P flonum 89 271 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 89 248 64 196617 / 1000000.;
#P newex 89 167 177 196617 unpack 0 0 0;
#P newex 89 346 48 196617 t b i;
#P newex 89 381 27 196617 int;
#P number 89 219 53 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 89 191 177 196617 expr $i1 * 65536 + $i2 * 256 + $i3;
#P newex 90 108 27 196617 t b l;
#P message 89 147 108 196617 120.;
#P newex 90 83 62 196617 prepend set;
#P comment 125 319 81 196617 Tempo in BPM;
#P newex 89 404 48 196617 pack 0 0;
#P newex 107 461 142 196617 prepend set addMetaEvent 81;
#P newex 90 425 27 196617 t b l;
#P message 90 501 157 196617 addMetaEvent 81 470 7;
#P comment 146 220 141 196617 microsecs per quarter note;
#P comment 125 272 180 196617 duration (sec) of each beat);
#P comment 107 52 91 196617 event in;
#P comment 359 52 91 196617 clock in;
#P inlet 90 51 15 0;
#P window linecount 1;
#P comment 111 526 147 196617 as timestamped tempo change;
#P outlet 90 526 15 0;
#P connect 14 0 13 0;
#P connect 14 1 13 0;
#P connect 13 0 19 0;
#P connect 19 0 15 0;
#P connect 15 0 16 0;
#P connect 16 0 20 0;
#P connect 20 0 21 0;
#P connect 21 0 22 0;
#P connect 22 0 23 0;
#P connect 23 0 18 0;
#P connect 18 0 17 0;
#P connect 17 0 10 0;
#P connect 2 0 12 0;
#P connect 12 0 14 0;
#P connect 10 0 8 0;
#P connect 8 0 7 0;
#P connect 9 0 7 0;
#P connect 7 0 0 0;
#P fasten 24 0 17 1 283 371 111 371;
#P connect 8 1 9 0;
#P connect 18 1 10 1;
#P connect 19 1 15 1;
#P connect 19 2 15 2;
#P pop;
#P newobj 297 506 116 196617 p convert tempo events;
#N vpatcher 10 59 396 480;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 209 38 79 196617 r master_clock;
#P window linecount 2;
#P comment 99 356 183 196617 Only the time must be specified–all other arguments can be set as defaults.;
#P window linecount 3;
#P comment 99 311 183 196617 A list is comprised of time (ms) , midi note , duration (ms) , velocity (0-127) , channel (0-16);
#P window linecount 0;
#P message 90 75 46 196617 60 60 1;
#P newex 72 130 30 196617 t b i;
#P newex 72 186 97 196617 pack 0. 0 0 0;
#P newex 72 106 99 196617 unpack 0 0 0;
#P newex 72 157 128 196617 int;
#P message 72 286 85 196617 160342. 60 60 1;
#P newex 72 224 27 196617 t b l;
#P message 89 254 84 196617 set $1 $2 $3 $4;
#P comment 89 39 100 196617 event in;
#P inlet 72 37 16 0;
#P outlet 72 314 15 0;
#P comment 289 40 100 196617 clock in;
#P connect 2 0 8 0;
#P connect 11 0 8 0;
#P connect 8 0 10 0;
#P connect 10 0 7 0;
#P connect 7 0 9 0;
#P connect 9 0 5 0;
#P connect 4 0 6 0;
#P connect 5 0 6 0;
#P connect 6 0 1 0;
#P connect 5 1 4 0;
#P fasten 10 1 9 1 97 152 106 152;
#P fasten 8 1 9 2 121 152 135 152;
#P connect 8 2 9 3;
#P fasten 14 0 7 1 214 151 195 151;
#P pop;
#P newobj 30 506 108 196617 p convert note events;
#P comment 346 764 240 196617 < - bangs when done playing or dumping sequence;
#P button 328 764 15 0;
#P button 427 537 15 0;
#P newex 167 738 32 196617 print;
#P window linecount 2;
#P comment 471 575 68 196617 start time in miliseconds;
#P flonum 427 557 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P message 427 579 44 196617 play $1;
#P message 566 558 41 196617 getInfo;
#P comment 408 742 240 196617 default channel;
#P comment 408 728 240 196617 default velocity;
#P comment 408 714 240 196617 default duration;
#P comment 408 700 240 196617 number of tracks (creates one inlet for each track);
#P comment 408 686 100 196617 args (optional):;
#P message 555 536 87 196617 tellmeeverything;
#P toggle 233 554 15 0;
#P message 233 576 56 196617 mute 2 $1;
#P toggle 176 554 15 0;
#P message 176 576 52 196617 solo 2 $1;
#P flonum 588 605 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 588 627 97 196617 setTempoFactor $1;
#P message 325 576 35 196617 pause;
#P newex 266 722 58 196617 print dump;
#P newex 250 786 101 196617 print meta_message;
#P message 336 597 29 196617 stop;
#P newex 204 786 43 196617 noteout;
#P newex 204 738 56 196617 route note;
#P message 578 580 33 196617 dump;
#P message 261 647 33 196617 clear;
#P message 311 557 38 196617 play 0;
#P message 350 617 35 196617 write;
#P newex 204 699 196 196617 mxj midifile 15 500;
#B color 8;
#P comment 175 539 100 196617 solo or mute a track;
#N vpatcher 12 44 601 625;
#P origin -63 23;
#P window setfont "Sans Serif" 9.;
#P window linecount 2;
#P comment 182 275 91 196617 convert to power of 2 format;
#P window linecount 1;
#P newex 355 39 79 196617 r master_clock;
#P number 144 303 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 0;
#P newex 144 281 34 196617 + 0.5;
#P newex 144 258 29 196617 sqrt;
#B color 5;
#P newex 47 300 78 196617 t b i;
#P newex 47 324 27 196617 int;
#P newex 47 347 35 196617 t 88 i;
#P newex 47 378 102 196617 pack 88 0 0 0 24 32;
#P newex 64 434 127 196617 prepend set addMetaEvent;
#P newex 47 402 27 196617 t b l;
#P message 47 475 188 196617 addMetaEvent 88 160064 5 3 24 32;
#P message 240 475 278 196617 addMetaEvent 88


Viewing 6 posts - 1 through 6 (of 6 total)