-o dac -m0 sr = 44100 ksmps = 32 nchnls = 2 0dbfs = 1 seed 0 ;frequency and amplitude multipliers for 11 partials of Risset's bell giFqs[] fillarray .56, .563, .92, .923, 1.19, 1.7, 2, 2.74, 3, 3.74, 4.07 giAmps[] fillarray 1, 2/3, 1, 1.8, 8/3, 5/3, 1.46, 4/3, 4/3, 1, 4/3 massign 0, 1 ;all midi channels to instr 1 instr 1 ;master instrument ;;scale desired deviations for maximum velocity ;frequency (cent) imxfqdv = 100 ;amplitude (dB) imxampdv = 12 ;duration (%) imxdurdv = 100 ;;get midi values ibasfreq cpsmidi ;base frequency iampmid ampmidi 1 ;receive midi-velocity and scale 0-1 ;;calculate maximum deviations depending on midi-velocity ifqdev = imxfqdv * iampmid iampdev = imxampdv * iampmid idurdev = imxdurdv * iampmid ;;trigger subinstruments indx = 0 while indx < 11 do ifqmult = giFqs[indx] ifreq = ibasfreq * ifqmult iampmult = giAmps[indx] iamp = iampmult / 20 ;scale event_i "i", 10, 0, 3, ifreq, iamp, ifqdev, iampdev, idurdev indx += 1 od endin instr 10 ;subinstrument for playing one partial ;receive the parameters from the master instrument ifreqnorm = p4 ;standard frequency of this partial iampnorm = p5 ;standard amplitude of this partial ifqdev = p6 ;maximum freq deviation in cents iampdev = p7 ;maximum amp deviation in dB idurdev = p8 ;maximum duration deviation in % ;calculate frequency icent random -ifqdev, ifqdev ;cent deviation ifreq = ifreqnorm * cent(icent) ;calculate amplitude idb random -iampdev, iampdev ;dB deviation iamp = iampnorm * ampdb(idb) ;calculate duration idurperc random -idurdev, idurdev ;duration deviation (%) iptdur = p3 * 2^(idurperc/100) p3 = iptdur ;set p3 to the calculated value ;play partial aenv transeg 0, .01, 0, iamp, p3-.01, -10, 0 apart poscil aenv, ifreq outs apart, apart endin ;example by joachim heintz