|
------------------------- bd4004m.orc -----------------------
sr = 44100
kr = 44100
ksmps = 1
nchnls = 1
/* convert MIDI note number to frequency */
#define MIDI2CPS(xmidikey)
# (440.0*exp(log(2.0)*(($xmidikey)-69.0)/12.0)) #
/* convert frequency to MIDI note number */
#define CPS2MIDI(xfreqcps)
# (12.0*(log(($xfreqcps)/440.0)/log(2.0))+69.0) #
/* convert velocity to amplitude */
#define VELOC2AMP(xvelocity)
# (0.0039+(($xvelocity)*($xvelocity))/16192.0) #
/* convert amplitude to velocity */
#define AMP2VELOC(xamplitude)
# (sqrt((($xamplitude)-0.0039)*16192.0)) #
seed 0
instr 1
kgoto start01
/*-------------------------------------------------------- */
ivol = 0.6 /* volume */
ibpm = 140.0 /* tempo */
irel = 0.1667 /* release time (sec.) */
idel = 0.02 /* delay time */
imod0 = 0.0025 /* random mod. of delay (sec.) */
imod1 = 0.005 /* rnd. mod. of velocity */
if01 = 5.3333 /* osc. start frequency (rel.) */
ifd1 = 14.0 /* freq. envelope decay speed */
ibw01 = 0.5 /* OSC1 BP bandwidth (rel.) */
ihp1 = 0.0625 /* OSC1 HP frequency (rel.) */
iapf1 = 1.0 /* OSC1 allp. flt. start freq. (rel.) */
iapf2 = 1.0 /* OSC1 allp. flt. end freq. */
iapdx = 8 /* OSC1 allp. flt. envelope speed */
ifr3 = 8 /* OSC2 HP1 freq. / base frq. */
imx3 = -5 /* OSC2 HP1 mix */
ifr4 = 0.5 /* OSC2 output HP f. / note f. */
imx2 = -0.4 /* OSC2 output gain */
ihp2 = 1.5 /* output HP frq. / note f. */
ibw02 = 2.0 /* output HP resonance */
ifr1 = 8 /* out. LP start f. 1 / note f. */
ifdx1 = 8 /* out. LP freq. 1 env. speed */
ifr2 = 8 /* out. LP start f. 2 / note f. */
ifdx2 = 8 /* out. LP freq. 2 env. speed */
ifxBP1 = 7040 /* noise BP start frq. (Hz) */
ifxBP2 = 7040 /* noise BP end frequency */
ibw1 = 2 /* noise BP bandwidth/freq. */
ifxLP1 = 3520 /* noise LP start frq. (Hz) */
ifxLP2 = 55 /* noise LP end frequency */
ifxd = 12 /* noise filter envelope speed */
iattn1 = 0.01 /* noise attack time (sec.) */
idecn1 = 3 /* noise decay speed */
imxn = 0.6 /* noise mix */
/* ------------------------------------------------------- */
i001 = 1/65536
imkey = p4 /* note number */
imvel = p5 /* velocity */
ivel = $VELOC2AMP(imvel) /* convert velocity */
im0 unirand 2
im1 unirand 2
ivel = ivel*(1+(im1-1)*imod1) /* rand. veloc. */
idel = idel+((im0-1)*imod0) /* rand. delay */
ibtime = 60/ibpm /* beat time */
i002 = exp(log(i001)*(idel+irel+16/kr)/irel)
ivol = ivel*ivol
icps = $MIDI2CPS(imkey) /* base freq. */
ifmax = sr*0.48 /* max. allowed freq. */
ihp2 = ihp2*icps
ibw02x = ihp2/ibw02
ifxLP2 = ifxLP2-ifxLP1
ifxBP2 = ifxBP2-ifxBP1
iapf2 = iapf2-iapf1
ixtime = (irel+idel+16/kr)
p3 = p3+ixtime /* increase note length */
start01:
kenvn1 expseg 1,ibtime/idecn1,0.5 /* noise generator */
kenvn2 linseg 0,iattn1,1,1,1
aenvn interp kenvn1*kenvn2
kenvn3 expseg 1,ibtime/ifxd,0.5
kenvn3 = (1-kenvn3)
kfxBPf = ifxBP1+(kenvn3*ifxBP2)
a1l unirand 2
a1l butterbp imxn*32768*(a1l-1)*aenvn,kfxBPf,kfxBPf*ibw1
a1l butterlp a1l,ifxLP1+(ifxLP2*kenvn3)
/* envelopes */
kamp1 expseg 1,p3-ixtime,1,ixtime,i002
kfrq1 expseg 1,ibtime/ifd1,0.5
kfrq = icps*(1+kfrq1*(if01-1))
kapfr expseg 1,ibtime/iapdx,0.5
kapfr = kfrq*(iapf1+iapf2*(1-kapfr))
kfrx1 expseg 1,ibtime/ifdx1,0.5
kfrx2 expseg 1,ibtime/ifdx2,0.5
kfrx = kfrq*(kfrx1*ifr1+kfrx2*ifr2)
kfrx = (kfrx>ifmax ? ifmax : kfrx)
/* kfrq = osc. frequency, kapfr = allpass filter frequency */
/* kfrx = LP filter frequency */
/* oscillator */
knumh = sr/(2*kfrq)
a1 buzz sr/(10*3.14159265), kfrq, knumh, 256, 0.25
a2 buzz sr/(10*3.14159265), kfrq, knumh, 256, 0.75
a1 tone (a1-a2)*16384, 10
a2 = a1 /* a1 = a2 = osc. signal */
a1 butterhp a1,kfrq*ihp1 /* filters */
a1 butterbp a1,kfrq,kfrq*ibw01
a1x tone a1,kapfr
a1 = 2*a1x-a1
a3 butterhp a2,kfrq*ifr3
a2 = a2+a3*imx3
a2 butterhp a2,kfrq*ifr4
a0x = a2*imx2+a1
atmp butterbp a0x*ibw02,ihp2,ibw02x
a0x butterhp a0x+atmp,ihp2
a0x butterlp a0x,kfrx
a0y delay (a0x+a1l)*ivol*kamp1,idel
out a0y
endin
--------------------------- bd4004m.sco ---------------------
t 0.00 140.000 /* tempo */
#define rhytm1(STIME) #
i 1 [$STIME+0.0000] 0.4375 33 120
i 1 [$STIME+0.9900] 0.4375 33 112
i 1 [$STIME+1.9900] 0.4375 33 124
i 1 [$STIME+2.9950] 0.4375 33 112
i 1 [$STIME+4.0000] 0.4375 33 116
i 1 [$STIME+4.9900] 0.4375 33 112
i 1 [$STIME+5.9900] 0.4375 33 116
i 1 [$STIME+6.9950] 0.4000 33 112
#
$rhytm1(0)
$rhytm1(8)
i 1 15.5 0.4 33 116
/* ------------------------------------------------------- */
f 256 0 262144 10 1
e /* end of score */
-------------------------------------------------------------
|