-odac -iadc -d -m0 -b2048 -B4096 -+rtaudio=alsa -+rtmidi=alsa /* add -M0 if you have MIDI (possibly -+rtmidi=virtual) */ sr=44100 ksmps=64 nchnls=2 gamix init 0 gkchk init 0 gkfun init 400 massign 1, 11 instr 11 gkchk = 1 /* activates MIDI input */ gkfun cpsmidib /* gets the key freq */ endin /* oscillator 1 */ instr 1 kon init 1 /* initially ON */ if gkchk == 1 then /* if MIDI is present, checks for key press */ kon active 11 /* checks for key press to control amp */ endif iamp = p4 kamp init 0 kp chnget "pitch1" kfun tonek gkfun*kp, 10 if kon == 0 then kamp = 0 /* amp = 0 if not ON */ else kamp chnget "vol1" /* otherwise amp comes from mixer */ endif kamp tonek kamp, 10 asig oscili p4, kfun, 1 gamix = gamix + asig*ampdb(kamp-100) endin instr 2 kon init 1 if gkchk == 1 then kon active 11 endif iamp = p4 kamp init 0 kp chnget "pitch2" kfun tonek gkfun*kp, 10 if kon == 0 then kamp = 0 else kamp chnget "vol2" endif kamp tonek kamp, 10 asig buzz p4, kfun, sr/(2*kfun), 2 gamix = gamix + asig*ampdb(kamp-100) endin instr 10 kon init 1 /* initially ON */ if gkchk == 1 then /* if MIDI is present, checks for key press */ kon active 11 /* checks for key press to control amp */ endif if kon == 0 then k1 = 0 /* fr = 0 if not ON */ else k1 chnget "frequency" /* otherwise amp comes from mixer */ endif ain1,ain2 ins ain = (ain1+ain2)/2 anoi rand 16000 ;k1 chnget "frequency" kcf port k1, 0.05 k2 chnget "resonance" kres tonek k2, 10 k3 chnget "noise" knoi tonek k3, 10 k4 chnget "mic" kin tonek k4, 10 asig = gamix + anoi*ampdb(knoi-100) + ain*ampdb(kin-100) afil moogvcf2 asig, kcf, kres outs afil*10,afil*10 gamix = 0 endin instr 100 k1 init 1 kb1 chnget "osc1" if kb1 == 1 then if k1 == 1 then event "i", 1, 0, -1, 16000 k1=0 endif else if k1 == 0 then event "i", -1, 0, -1, 16000 k1=1 endif endif k2 init 1 kb2 chnget "osc2" if kb2 == 1 then if k2 == 1 then event "i", 2, 0, -1, 16000 k2=0 endif else if k2 == 0 then event "i", -2, 0, -1, 16000 k2=1 endif endif endin f1 0 16384 10 1 .5 .4 .3 .2 .1 .05 .04 .03 .02 .01 .01 .01 .01 f2 0 16384 10 1 i10 0 60000 i100 0 60000