«Import midinote, dur, amp and sustain from midi file using SimpleMIDIFile» by grirgz
on 30 Dec'21 01:57 inThere is the .p method (see http://sccode.org/1-5aT) but here is also a way to retrieve the values directly
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
m = SimpleMIDIFile.read( "~/Téléchargements/Super Mario Bros 2 - Mario Dreams.mid" ); ( TempoClock.default.tempo = m.tempo/60; Pdef(\bla, Pbind( \instrument, \default, [\midinote, \dur, \sustain, \amp], Prout({ arg ev; var timescale = 1/16/60; var prevev; m.noteSustainEvents.collect({ arg item, idx; // [track, absTime, \noteOn, channel, note, velo, dur, upVelo] if(idx == 0) { prevev = [item[4], item[1], item[6] * timescale, item[5]/127] } { prevev[1] = item[1] - prevev[1] * timescale; ev = prevev.yield; prevev = [item[4], item[1], item[6] * timescale, item[5]/127]; }; }); prevev[1] = prevev[2]; ev = prevev.yield; }), ) ).play )
reception
comments