// title: Import midinote, dur, amp and sustain from midi file using SimpleMIDIFile // author: grirgz // description: // There is the .p method (see http://sccode.org/1-5aT) but here is also a way to retrieve the values directly // code: 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 )