-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmidifile-help.pd
440 lines (440 loc) · 14.2 KB
/
midifile-help.pd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
#N canvas 583 98 399 237 12;
#N canvas 24 112 1136 834 midifile_write 0;
#X obj 324 -2 bng 45 250 50 0 empty empty choose 5 23 0 10 #3c50fc #fcac44 #ffffff;
#X obj 67 65 tgl 45 0 empty empty record 2 23 0 12 #fc2828 #e8e828 #ffffff 0 1;
#X floatatom 553 780 15 0 0 0 tick - - 0;
#X obj 67 150 metro 2;
#X floatatom 120 125 15 0 0 0 - - - 0;
#X msg 120 99 2.005;
#X msg 506 590 verbose \$1;
#X text 525 544 verbosity defaults to 1;
#X obj 324 54 savepanel;
#X msg 409 493 240 1 2 3 4 247;
#X text 536 492 a sysex message;
#X obj 553 750 float;
#X floatatom 506 564 5 0 0 0 - - - 0;
#X msg 324 408 write \$1 \$2 \$3;
#X msg 350 199 29;
#X msg 388 199 30;
#X msg 235 199 0;
#X floatatom 405 275 5 0 0 0 ticks_per_frame - - 0;
#X text 80 301 (ticks per quarter note if frames per second is zero);
#X msg 312 199 25;
#X msg 272 199 24;
#X text 79 322 25 20 will give accurate timing with metro ticks at 2ms;
#X obj 324 375 pack s 25 20;
#X obj 559 663 midifile;
#X text 7 199 time code frames per second:;
#X text 509 432 default is 90 ticks per quarter note;
#X msg 349 433 write filename.mid;
#X msg 374 458 write filename.mid 77;
#X text 555 457 77 ticks per quarter note;
#X msg 442 526 flush;
#X obj 268 146 cnv 15 200 20 empty empty empty 20 12 0 14 #f8fc00 #404040 0;
#X floatatom 514 145 5 0 0 0 note - - 0;
#X floatatom 514 175 5 0 0 0 velocity - - 0;
#X obj 558 333 pack 144 0 0;
#X obj 577 179 sel 0;
#X obj 558 206 t b f;
#X obj 558 307 f;
#X text 553 565 set to 3 to debug input;
#X obj 558 125 notein;
#X obj 102 8 cnv 15 220 20 empty empty empty 20 12 0 14 #f8fc00 #404040 0;
#X text 104 10 1: open a file for writing:;
#X obj 116 64 cnv 15 150 20 empty empty empty 20 12 0 14 #f8fc00 #404040 0;
#X text 118 67 2: start recording;
#X obj 122 524 cnv 15 300 20 empty empty empty 20 12 0 14 #f8fc00 #404040 0;
#X text 130 526 4: stop recording and save the file:;
#X floatatom 512 230 5 0 0 0 channel - - 0;
#X obj 609 287 +;
#X msg 577 235 127;
#X msg 609 207 143;
#X floatatom 919 103 5 0 0 0 value - - 0;
#X floatatom 919 134 5 0 0 0 controller - - 0;
#X floatatom 917 183 5 0 0 0 channel - - 0;
#X obj 965 83 ctlin;
#X obj 965 237 pack 176 0 0;
#X obj 965 269 print ctl>;
#X obj 579 374 print note>;
#X obj 965 119 t b f;
#X obj 965 183 f;
#X obj 1020 126 + 175;
#X text 285 143 3: input MIDI as lists;
#X msg 778 551 track \$1;
#X msg 971 519 144 60 0;
#X msg 882 518 144 60 64;
#X msg 863 549 144 67 64;
#X msg 953 549 144 67 0;
#X obj 778 500 hradio 15 1 0 8 empty empty empty 0 -8 0 10 #fcfcfc #000000 #000000 0;
#X obj 708 633 r midiwrite;
#N canvas 141 452 1100 497 meta_messages 0;
#X text 71 6 FF 51 3 tttttt Set Tempo (in microseconds per MIDI quarter-note);
#X obj 539 526 s midiwrite;
#X text 407 196 Instrument Name;
#X text 399 220 Lyric;
#X text 385 126 Text Event (should be at start of track);
#X text 224 102 Sequence Number (must be at start of track);
#X text 419 150 Copyright Notice;
#X text 398 173 Sequence/Track Name;
#X msg 372 339 meta 81 500000;
#X text 495 338 Set Tempo (microseconds per MIDI quarter-note);
#X msg 136 103 meta 0 678;
#X text 439 244 Marker;
#X text 463 268 Cue Point;
#X msg 326 293 meta 32 5;
#X text 405 292 MIDI Channel Prefix;
#X msg 349 316 meta 47;
#X text 414 315 End of Track;
#X text 6 42 raw mode;
#X text 44 104 meta method;
#X msg 74 41 255 81 3 500000;
#X text 544 361 SMPTE Offset (hr mi se fr ff);
#X msg 395 362 meta 84 0 1 30 4 5;
#X text 555 384 Time Signature;
#X msg 418 385 meta 88 6 3 36 8;
#X msg 441 408 meta 89 0 0;
#X text 538 407 Key Signature (number of sharps(+) / flats(-) 0 or 1 for major or minor;
#X msg 481 448 meta 127 0 1 22 33 44 55;
#X text 683 449 Sequencer-Specific Meta-Event;
#X msg 509 476 meta 52;
#X text 574 475 unknown;
#X msg 230 197 meta 4 twisted_guitar;
#X msg 278 245 meta 6 another_part;
#X msg 302 269 meta 7 "drops_ball";
#X msg 160 127 meta 1 Some_text_goes_here.;
#X msg 184 151 meta 2 (C)2018_Nobody_At_All;
#X msg 207 174 meta 3 amazing_sequence;
#X msg 254 221 meta 5 "what_the";
#X text 575 143 Underscore will be replaced by space in text metas;
#X connect 8 0 1 0;
#X connect 10 0 1 0;
#X connect 13 0 1 0;
#X connect 15 0 1 0;
#X connect 19 0 1 0;
#X connect 21 0 1 0;
#X connect 23 0 1 0;
#X connect 24 0 1 0;
#X connect 26 0 1 0;
#X connect 28 0 1 0;
#X connect 30 0 1 0;
#X connect 31 0 1 0;
#X connect 32 0 1 0;
#X connect 33 0 1 0;
#X connect 34 0 1 0;
#X connect 35 0 1 0;
#X connect 36 0 1 0;
#X restore 561 87 pd meta_messages;
#X obj 506 532 hradio 15 1 0 5 empty empty verbosity 0 -6 0 12 #3c50fc #e8e828 #000000 0;
#X obj 174 86 cnv 15 380 20 empty empty empty 20 12 0 14 #f8fc00 #404040 0;
#X text 180 86 Maybe add some meta messages before we start:;
#X text 780 478 choose track to write;
#X text 753 744 Martin Peach \, 2010 - 2018;
#X connect 0 0 8 0;
#X connect 1 0 3 0;
#X connect 3 0 23 0;
#X connect 4 0 3 1;
#X connect 5 0 4 0;
#X connect 6 0 23 0;
#X connect 8 0 22 0;
#X connect 9 0 23 0;
#X connect 11 0 2 0;
#X connect 12 0 6 0;
#X connect 13 0 23 0;
#X connect 14 0 22 1;
#X connect 15 0 22 1;
#X connect 16 0 22 1;
#X connect 17 0 22 2;
#X connect 19 0 22 1;
#X connect 20 0 22 1;
#X connect 22 0 13 0;
#X connect 23 1 11 1;
#X connect 23 2 11 0;
#X connect 26 0 23 0;
#X connect 27 0 23 0;
#X connect 29 0 23 0;
#X connect 33 0 23 0;
#X connect 33 0 55 0;
#X connect 34 0 47 0;
#X connect 34 1 48 0;
#X connect 35 0 36 0;
#X connect 35 1 33 1;
#X connect 36 0 33 0;
#X connect 38 0 31 0;
#X connect 38 0 35 0;
#X connect 38 1 32 0;
#X connect 38 1 34 0;
#X connect 38 1 33 2;
#X connect 38 2 45 0;
#X connect 38 2 46 1;
#X connect 46 0 36 1;
#X connect 47 0 46 0;
#X connect 48 0 46 0;
#X connect 52 0 49 0;
#X connect 52 0 56 0;
#X connect 52 1 50 0;
#X connect 52 1 53 1;
#X connect 52 2 51 0;
#X connect 52 2 58 0;
#X connect 53 0 54 0;
#X connect 53 0 23 0;
#X connect 56 0 57 0;
#X connect 56 1 53 2;
#X connect 57 0 53 0;
#X connect 58 0 57 1;
#X connect 60 0 23 0;
#X connect 61 0 23 0;
#X connect 62 0 23 0;
#X connect 63 0 23 0;
#X connect 64 0 23 0;
#X connect 65 0 60 0;
#X connect 66 0 23 0;
#X connect 68 0 12 0;
#X restore 76 116 pd midifile_write;
#N canvas 240 205 914 702 midifile_read 0;
#X obj 544 149 bng 15 250 50 0 empty empty step_one_tick 18 7 0 12 #0400fc #f8fc00 #000000;
#X obj 12 69 openpanel;
#X obj 12 16 bng 45 250 50 0 empty empty choose 3 23 0 12 #3c50fc #fcac44 #fc2828;
#X obj 116 151 tgl 45 0 empty empty play -45 23 0 12 #14e814 #000000 #fc2828 0 1;
#X msg 391 478 rewind;
#X text 235 477 go to start of file;
#X floatatom 461 570 15 0 0 0 current_tick - - 0;
#X obj 235 301 hradio 15 1 0 16 empty empty dump_track_number 0 -6 0 12 #3c50fc #e8e828 #000000 0;
#X msg 235 322 dump \$1;
#X msg 354 441 68050;
#X msg 179 266 track \$1;
#X obj 179 226 hradio 15 1 0 16 empty empty play_track_number 0 -6 0 12 #3c50fc #e8e828 #000000 0;
#X obj 116 203 metro 2;
#X text 193 542 creation arguments: midi_file_name;
#X text 298 321 parse this track to main window;
#X floatatom 709 660 15 0 0 0 last_tick - - 0;
#X msg 311 398 verbose \$1;
#X text 123 398 verbosity defaults to 1;
#X text 63 11 1: choose a MIDI file to play;
#X text 169 145 2: start playing it;
#X obj 435 424 spigot;
#X obj 480 390 tgl 25 0 empty empty loop -45 12 0 12 #0400fc #f8fc00 #fc0400 0 1;
#X msg 12 99 read \$1;
#X floatatom 311 374 5 0 0 0 - - - 0;
#X obj 311 355 hradio 15 1 0 5 empty empty verbosity 0 -6 0 12 #3c50fc #e8e828 #000000 0;
#X obj 179 243 - 1;
#X obj 65 505 ctlout 123;
#X msg 65 475 123;
#X msg 39 126 read I_Wanna_Be_Sedated.mid;
#X obj 65 447 bng 15 250 50 0 empty empty all_notes_off 17 7 0 10 #fc0400 #f8fc00 #000000;
#X obj 718 590 t b b;
#X floatatom 134 263 5 0 0 0 - - - 0;
#X obj 750 617 bng 15 250 50 0 empty empty end 17 7 0 10 #fc0400 #f8fc00 #000000;
#X floatatom 632 433 9 0 0 0 loop_start_tick: - - 0;
#X text 214 243 -1 = play all tracks;
#X obj 709 638 f;
#X obj 435 450 f 0;
#N canvas 302 192 1058 600 route_events 0;
#X obj 20 89 inlet;
#X floatatom 172 185 5 0 0 0 note - - 0;
#X floatatom 249 185 5 0 0 1 velocity - - 0;
#X obj 172 110 route 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159, f 80;
#X obj 172 163 unpack 0 0;
#X obj 178 242 route 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143, f 79;
#X obj 76 206 print note_on;
#X obj 76 320 print note_off;
#X obj 705 321 noteout 1;
#X obj 786 321 noteout 2;
#X obj 865 321 noteout 3;
#X obj 945 321 noteout 4;
#X floatatom 178 407 5 0 0 0 controller - - 0;
#X floatatom 252 407 5 0 0 1 value - - 0;
#X obj 178 383 unpack 0 0;
#X obj 52 432 print controller;
#X obj 706 419 ctlout 1;
#X text 172 90 route note-on events by channel:;
#X text 235 222 route note off events by channel:;
#X text 225 325 route controller events by channel:;
#X text 505 322 send events to MIDI devices:;
#X obj 179 483 route 240;
#X obj 179 562 print sysex;
#X obj 76 178 spigot;
#X obj 95 84 inlet;
#X obj 23 131 tgl 15 0 empty empty print_status_names 17 7 0 10 #00fc04 #000000 #000000 0 1;
#X obj 77 292 spigot;
#X obj 52 405 spigot;
#X obj 179 523 spigot;
#X obj 239 523 spigot;
#X text 505 419 send events to MIDI devices:;
#X obj 776 419 ctlout 2;
#X obj 846 419 ctlout 3;
#X obj 916 419 ctlout 4;
#X obj 177 349 route 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191, f 80;
#X text 104 28 This is just an example on parsing the MIDI events. Not all possible MIDI events are handled., f 51;
#X text 60 28 NOTE:;
#X obj 614 37 ../doc/7.stuff/tools/miditester;
#X text 539 39 See also:;
#X obj 266 562 print other;
#X connect 0 0 3 0;
#X connect 3 0 4 0;
#X connect 3 0 8 0;
#X connect 3 0 23 0;
#X connect 3 1 9 0;
#X connect 3 2 10 0;
#X connect 3 3 11 0;
#X connect 3 16 5 0;
#X connect 4 0 1 0;
#X connect 4 1 2 0;
#X connect 5 0 8 0;
#X connect 5 0 26 0;
#X connect 5 1 9 0;
#X connect 5 2 10 0;
#X connect 5 3 11 0;
#X connect 5 16 34 0;
#X connect 14 0 12 0;
#X connect 14 1 13 0;
#X connect 21 0 28 0;
#X connect 21 1 29 0;
#X connect 23 0 6 0;
#X connect 24 0 25 0;
#X connect 25 0 23 1;
#X connect 25 0 26 1;
#X connect 25 0 27 1;
#X connect 25 0 28 1;
#X connect 25 0 29 1;
#X connect 26 0 7 0;
#X connect 27 0 15 0;
#X connect 28 0 22 0;
#X connect 29 0 39 0;
#X connect 34 0 14 0;
#X connect 34 0 16 0;
#X connect 34 0 27 0;
#X connect 34 1 31 0;
#X connect 34 2 32 0;
#X connect 34 3 33 0;
#X connect 34 16 21 0;
#X restore 435 593 pd route_events;
#N canvas 114 197 1088 523 route_info 0;
#X obj 34 13 inlet;
#X floatatom 34 73 3 0 0 1 format - - 0;
#X floatatom 142 73 5 0 0 1 tracks - - 0;
#X floatatom 252 73 5 0 0 1 ticks_per_quarternote - - 0;
#X floatatom 360 140 5 0 0 1 tracks - - 0;
#X symbolatom 546 190 40 0 0 0 - - - 0;
#X obj 538 224 unpack 0 0;
#X floatatom 615 278 15 0 0 0 last_tick - - 0;
#X floatatom 538 250 5 0 0 1 track - - 0;
#X floatatom 449 190 5 0 0 1 track - - 0;
#X obj 449 164 unpack 0 s;
#X obj 627 316 unpack 0 0 0 0;
#X floatatom 627 352 3 0 0 1 / - - 0;
#X floatatom 663 353 3 0 0 1 - - - 0;
#X floatatom 699 353 5 0 0 1 clocks_per_click - - 0;
#X floatatom 736 379 5 0 0 1 32nds_per_quarternote - - 0;
#X floatatom 716 136 15 0 0 0 microsec_per_quarternote - - 0;
#X obj 229 354 /;
#X floatatom 442 374 15 0 0 0 microsec_per_tick - - 0;
#X obj 229 395 / 1000;
#X floatatom 229 426 15 0 0 0 millisec_per_tick - - 0;
#X obj 906 190 print other_meta;
#X obj 360 103 route seq_num name end time_sig microsec_per_quarternote;
#X obj 805 161 route key_sig;
#X obj 805 218 unpack 0 0 s;
#X symbolatom 898 323 10 0 0 0 key - - 0;
#X floatatom 805 247 5 0 0 1 +sharps/-flats - - 0;
#X obj 851 276 tgl 15 0 empty empty minor 17 7 0 10 #fcfcfc #000000 #000000 0 1;
#X obj 546 164 list prepend;
#X obj 898 297 list prepend;
#X obj 34 43 route format tracks ticks_per_quarternote;
#X obj 228 477 s msec_per_tick;
#X obj 405 211 print name:;
#X text 503 352 time signature:;
#X connect 0 0 30 0;
#X connect 6 0 8 0;
#X connect 6 1 7 0;
#X connect 10 0 9 0;
#X connect 10 1 28 0;
#X connect 11 0 12 0;
#X connect 11 1 13 0;
#X connect 11 2 14 0;
#X connect 11 3 15 0;
#X connect 17 0 18 0;
#X connect 17 0 19 0;
#X connect 19 0 20 0;
#X connect 19 0 31 0;
#X connect 22 0 4 0;
#X connect 22 1 10 0;
#X connect 22 1 32 0;
#X connect 22 2 6 0;
#X connect 22 3 11 0;
#X connect 22 4 16 0;
#X connect 22 4 17 0;
#X connect 22 5 23 0;
#X connect 23 0 24 0;
#X connect 23 1 21 0;
#X connect 24 0 26 0;
#X connect 24 1 27 0;
#X connect 24 2 29 0;
#X connect 28 0 5 0;
#X connect 29 0 25 0;
#X connect 30 0 1 0;
#X connect 30 1 2 0;
#X connect 30 2 3 0;
#X connect 30 2 17 1;
#X connect 30 3 22 0;
#X restore 785 589 pd route_info;
#X obj 718 562 route bang;
#X text 222 441 goto tick 68050:;
#X obj 386 147 r msec_per_tick;
#X floatatom 386 186 9 0 0 0 - - - 0;
#X text 81 593 MIDI messages are output on first outlet as lists:;
#X text 386 108 milliseconds per tick is calculated from metadata at start of file. Step one tick to get the initial value.;
#X obj 435 542 midifile;
#X text 548 541 meta data \, bang at end of file on third outlet;
#X obj 573 578 tgl 15 1 empty empty print_status_names 17 7 0 10 #00fc04 #000000 #000000 0 1;
#X text 728 676 Martin Peach \, 2011-2020;
#X connect 0 0 45 0;
#X connect 1 0 22 0;
#X connect 2 0 1 0;
#X connect 3 0 12 0;
#X connect 4 0 45 0;
#X connect 7 0 8 0;
#X connect 8 0 45 0;
#X connect 9 0 45 0;
#X connect 10 0 45 0;
#X connect 11 0 25 0;
#X connect 12 0 45 0;
#X connect 16 0 45 0;
#X connect 20 0 36 0;
#X connect 21 0 20 1;
#X connect 22 0 45 0;
#X connect 23 0 16 0;
#X connect 24 0 23 0;
#X connect 25 0 10 0;
#X connect 25 0 31 0;
#X connect 27 0 26 0;
#X connect 28 0 45 0;
#X connect 29 0 27 0;
#X connect 30 0 20 0;
#X connect 30 1 35 0;
#X connect 30 1 32 0;
#X connect 33 0 36 1;
#X connect 35 0 15 0;
#X connect 36 0 45 0;
#X connect 39 0 30 0;
#X connect 39 1 38 0;
#X connect 41 0 42 0;
#X connect 42 0 12 1;
#X connect 45 0 37 0;
#X connect 45 1 6 0;
#X connect 45 1 35 1;
#X connect 45 2 39 0;
#X connect 47 0 37 1;
#X restore 76 83 pd midifile_read;
#X text 15 10 midifile reads and writes MIDI files.;
#N canvas 403 187 587 265 META 0;
#X text 12 185 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan Wilkes for Pd version 0.42.;
#X text 12 25 LICENSE GPL v2 or later;
#X text 12 165 AUTHOR Martin Peach;
#X text 12 5 KEYWORDS control MIDI;
#X text 12 45 DESCRIPTION read and write MIDI files;
#X text 12 105 OUTLET_0 list;
#X text 12 125 OUTLET_1 float;
#X text 12 65 INLET_0 bang float list rewind read track dump verbose write meta flush;
#X text 12 145 OUTLET_2 bang \, list;
#X restore 335 202 pd META;
#X text 148 203 2020/06/10 Martin Peach;