Understand midi files
for Zeybek dance the Wed Dec 17 10:03:04 2014signature is 9/4, so have to divide 80 (tempo) with the 9*4: (/ 80.0 (* 9 4)) = 2.22222
SuperCollider code
/* Zeybek*/ f = SimpleMIDIFile.read("/Users/ari/Library/Application\ Support/SuperCollider/Extensions/Zeybek_Dance/zeybek.mid");//read the midi file f.timeMode = \seconds; (//play midi file SynthDef( "organ", { |freq = 440, sustain = 1, amp = 0.1| var sig; sig = LFCub.ar( freq * [1,2,3,5], 0, amp/[2,4,5,7] ); Out.ar( 0, Env([0,1,1,0], [0.025,sustain,0.025]).kr(2) * sig.dup ) }).add; ); x = f.p( \organ ).play; (// send OSC to OF { f.p(\drone).play; (f.noteEvents.size.asInt-1).do({|i| NetAddr("127.0.0.1", 12345).sendMsg("/note", f.noteEvents[i][4].midicps); ((f.noteEvents[i+1][1]-f.noteEvents[i][1])).wait; }) }.fork ) (// drone synth from redfrik SynthDef( \drone, {|freq = 440, fmod1= 0.11, fmod2= 0.22, fmod3= 0.33, fmoda1= 1, fmoda2=1,fmoda3= 1, pmod1= 0.1, pmod2= 0.2, pmod3= 0.3, amod1= 0.01, amod2= 0.02, amod3= 0.03,amoda1= 0.05, amoda2= 0.05, amoda3= 0.05, smod= 0.13, smoda= 5, smodm= 6, smodaa=8,smodmm=50, cmod= 1.2, cmoda= 0.6, room= 20, reverb= 5, damp= 1, input= 0.5, spread= 25, dry=0, early= 1, tail= 1, amp= 3.7, sustain=2| var signal; signal = Limiter.ar( LeakDC.ar( GVerb.ar( Splay.ar( SinOsc.ar([0.5*freq, freq, 2*freq, 4*freq]+SinOsc.ar([fmod1, fmod2, fmod3], 0, [fmoda1, fmoda2, fmoda3]), SinOsc.ar([pmod1, pmod2, pmod3], 0, 2pi), SinOsc.ar([amod1, amod2, amod3], 0, [amoda1, amoda2, amoda3])), SinOsc.ar( SinOsc.ar( SinOsc.ar(smod, 0, smoda, smodm), 0, smodaa, smodmm), 0, 1, 1), amp, SinOsc.ar(cmod, 0, cmoda) ), room, reverb, damp, input, spread, dry, early, tail))); Out.ar(0, Env([0,1,1,0], [0.0025,sustain,0.0025]).kr(2)*signal.dup)} ).add )
Gea lua scritping
mlab = of.getApp() function setup() of.setWindowTitle("play with amplitude") of.background(0) end ---------------------------------------------------- function update() of.fill() of.setColor(0,0,0,30) of.rect(0,0,of.getWidth(),of.getHeight()) of.fill() of.setColor(255,255,255,250) of.rect(500, of.getHeight(), 250, -mlab.note*1.5) end ---------------------------------------------------- function draw() end