diff options
author | Richard <q@1bpm.net> | 2021-11-09 21:10:12 +0000 |
---|---|---|
committer | Richard <q@1bpm.net> | 2021-11-09 21:10:12 +0000 |
commit | 69d812698d8b6b4e963d49d0953ebeca05fa6500 (patch) | |
tree | e7fcf987afe9cd1ca290cbee3011bd6b3deacb8a /BUG5/instruments.udo | |
parent | dae3d836d099b1abf8b4e6e935d148eccb90f96e (diff) | |
download | csd-unfixedbugs1-69d812698d8b6b4e963d49d0953ebeca05fa6500.tar.gz csd-unfixedbugs1-69d812698d8b6b4e963d49d0953ebeca05fa6500.tar.bz2 csd-unfixedbugs1-69d812698d8b6b4e963d49d0953ebeca05fa6500.zip |
BUG4 finished
Diffstat (limited to 'BUG5/instruments.udo')
-rw-r--r-- | BUG5/instruments.udo | 312 |
1 files changed, 312 insertions, 0 deletions
diff --git a/BUG5/instruments.udo b/BUG5/instruments.udo new file mode 100644 index 0000000..834f942 --- /dev/null +++ b/BUG5/instruments.udo @@ -0,0 +1,312 @@ +#ifndef UDO_INSTRUMENTS +#define UDO_INSTRUMENTS ## +/* + Debugger - Unfixed Bugs : BUG #5 + + Sound generators + Names should correspond to those used in BID file, prepended with play_ +*/ + + +#include "wavetables.udo" +#include "bussing.udo" +#include "bid.udo" + + +instr play_hat1 + iamp = bid_getparameter(p4, p5, 2) + idel1 = random(0.01, 0.03) + idel2 = random(0.01, 0.03) + xtratim(max(idel1, idel2)) + p3 = 0.22 + kfreq linseg 1000, p3*0.2, 300, p3*0.8, 500 ; mid as 500 not 300 + aenv expsega .1, .0005, 1, p3 - .0005, .01 + asqr1 oscil 1, kfreq, gifnSquare, -1 + asqr2 oscil 1, kfreq*1.4471, gifnSquare, -1 + asqr3 oscil 1, kfreq*1.6170, gifnSquare, -1 + asqr4 oscil 1, kfreq*1.9265, gifnSquare, -1 + asqr5 oscil 1, kfreq*2.5028, gifnSquare, -1 + asqr6 oscil 1, kfreq*2.6637, gifnSquare, -1 + a808 sum asqr1, asqr2, asqr3, asqr4, asqr5, asqr6 + a808 butterhp a808, 3270 + a808 butterhp a808, 3270 + aout = a808 * aenv * iamp + aL delay aout, idel1 + aR delay aout, idel2 + bus_mix("master", aL, aR) +endin + + +instr play_hat2 + iamp = bid_getparameter(p4, p5, 2) + idel1 = random(0.005, 0.02) + idel2 = random(0.005, 0.02) + xtratim(max(idel1, idel2)) + kfreq init 415.3*0.8 + aenv expsega .1, .0005, 1, p3 - .0005, .01 + asqr1 oscil 1, kfreq, gifnSquare, -1 + asqr2 oscil 1, kfreq*1.4471, gifnSquare, -1 + asqr3 oscil 1, kfreq*1.6170, gifnSquare, -1 + asqr4 oscil 1, kfreq*1.9265, gifnSquare, -1 + asqr5 oscil 1, kfreq*2.5028, gifnSaw, -1 + asqr6 oscil 1, kfreq*2.6637, gifnSaw, -1 + a808 sum asqr1, asqr2, asqr3, asqr4, asqr5, asqr6 + a808 butterhp a808, 3270 + a808 butterhp a808, 3270 + aout = a808 * aenv * iamp + aL delay aout, idel1 + aR delay aout, idel2 + bus_mix("master", aL, aR) +endin + +instr play_bass + iamp = bid_getparameter(p4, p5, 2) + inote = tab_i(random(1, ftlen(gibid_chordfn) - 3), gibid_chordfn) - 24 + a1 foscil 0.56, cpsmidinn(inote), 1, 2, random(0, 6), gifnSine + a1 pareq a1, 150, 0.24, 0.9 + a1 pareq a1, 80, 1.3, 0.9 + kenv linseg 1, p3, 0 + aout = a1*kenv + bus_mix("master", aout, aout) +endin + + +instr play_kick ; 808 style kick + iamp = bid_getparameter(p4, p5, 2) + + idist = 0.35 ;= (i(gksection) == 1) ? 0.55 : 0.35 + xtratim 0.1 + krelease release + ktune init 0 + kmul transeg 0.2, p3*0.5, -15, 0.01, p3*0.5, 0, 0 + kbend transeg 0.5, 1.2, -4, 0, 1, 0, 0 + asig gbuzz 0.5, 50*octave(ktune)*semitone(kbend), 20, 1, kmul, gifnCosine + aenv transeg 1, p3-0.004, -6, 0 + gkpump = k(aenv) + aatt linseg 0, 0.004, 1 + asig = asig*aenv*aatt + aenv linseg 1, 0.07, 0 + acps expsega 400, 0.07, 0.001, 1, 0.001 + aimp oscili aenv, acps*octave(ktune*0.25) + amix = ((asig*0.7)+(aimp*0.35))*2*iamp + gkpump = min(rms(amix) * 7, 1) + aout1 distort amix, idist, gifnSine + + + aout1 *= 1.6 + bus_mix("master", aout1, aout1) +endin + + +instr play_snare + icps0 = 211 + iamp = bid_getparameter(p4, p5, 2) + ;p3 = random(0.03, 0.5) + icps1 = 2.0 * icps0 + kcps port icps0, 0.007, icps1 + kcpsx = kcps * 1.5 + + kfmd port 0.0, 0.01, 0.7 + aenv1 expon 1.0, 0.03, 0.5 + kenv2 port 1.0, 0.008, 0.0 + aenv2 interp kenv2 + aenv3 expon 1.0, 0.025, 0.5 + + a_ oscili 1.0, kcps + a1 oscili 1.0, kcps * (1.0 + a_*kfmd) + a_ oscili 1.0, kcpsx + a2 oscili 1.0, kcpsx * (1.0 + a_*kfmd) + + a3 unirand 2.0 + a3 = a3 - 1.0 + a3 butterbp a3, 3200, 1500 + a3 = a3 * aenv2 + + a0 = a1 + a2*aenv3 + a3*1.0 + a0 = a0 * aenv1 + a0 butterhp a0, 210 + aout = a0*iamp + bus_mix("master", aout, aout) + +endin + + +/* + Convenience opcode for playing current chord on given instrument, passing p4 as note and p5 as amp + + chordinstrument Sinstrument + + Sinstrument the instrument name + ipos position in pattern + idataindex section specific data index; pointer to ftable +*/ +opcode chordinstrument, 0, Sii + Sinstrument, ipos, idataindex xin + iamp = bid_getparameter(ipos, idataindex, 2) + index = 1 ; index 0 is chordgroup length + while (index < ftlen(gibid_chordfn)) do + event_i "i", Sinstrument, 0, p3, tab_i(index, gibid_chordfn), iamp + index += 1 + od + +endop + + + +instr play_clap + iamp = bid_getparameter(p4, p5, 2) + ;p3 = 0.065 + aL noise 1, 0.9 + aR noise 0.5, 0.4 + aL butterbp aL, 1200, 1100 + aR butterbp aR, 1200, 1100 + aL butterhp aL, 400 + aR butterhp aR, 400 + kamp1 linseg 1, p3*0.1, 0, p3*0.1, 1, p3*0.2, 0.1, p3*0.3, 0.5, p3*0.2, 0, p3*0.05, 0.4, p3*0.05, 0 + kamp2 linseg 1, p3*0.15, 0, p3*0.15, 1, p3*0.1, 0.1, p3*0.2, 0.5, p3*0.3, 0, p3*0.05, 0.4, p3*0.05, 0 + + aL = aL*kamp1*12*iamp + aR = aR*kamp2*12*iamp + bus_mix("master", aL, aR) + bus_mix("reverb", aL*0.2, aR*0.2) +endin + +instr play_mel1 + iamp = bid_getparameter(p4, p5, 2) + inote = tab_i(1, gibid_chordfn) ;tab_i(random(1, ftlen(gibid_chordfn) - 3), gibid_chordfn) - 12 + inote2 = tab_i(2, gibid_chordfn) ;tab_i(random(1, ftlen(gibid_chordfn) - 3), gibid_chordfn) - 12 + aL moog 0.6*iamp, cpsmidinn(inote - 12), 0.1, 0.02, 4, 0.01, gifnSine, gifnSaw, gifnSine + aR moog 0.6*iamp, cpsmidinn(inote2 - 12), 0.1, 0.002, 4, 0.01, gifnSine, gifnSaw, gifnSine + kenv linseg 1, p3*0.8, 0, p3*0.2, 0 + aL *= kenv + aR *= kenv + bus_mix("master", aL, aR) +endin + +instr string + if (random(0, 1) > 0.8) then + ifqc = cpsmidinn(p4) + else + ifqc = cpsmidinn(p4+12) + endif + iamp = p5 +idur = p3 + ifm1 = ifqc + ifm2 = ifqc*3 + ifm3 = ifqc*4 + indx1 = 7.5/log(ifqc) ;range from ca 2 to 1 + indx2 = 15/sqrt(ifqc) ;range from ca 2.6 to .5 + indx3 = 1.25/sqrt(ifqc) ;range from ca .2 to .038 + + irise = 0.1 + idec = 0.4 + inoisdur= .1 + ivibdel = 0.25 + ivibwth = 0.01 + ivibrte = 5.5 + + kvib init 0 + kvbctl linen 1,.5,p3-ivibdel,.1 ; vibrato control envelope + krnd randi .0075,2 ; random deviation vib width + kvib oscili kvbctl*ivibwth+krnd,ivibrte*kvbctl ; generator + + ktrans linseg 1,inoisdur,0,1,0 ; transient envelope + anoise randi ktrans*iamp/4,.2*ifqc ; attack noise... + attack oscili anoise,2000 ; ...centered around 2kHz + + amod1 oscili ifm1*(indx1+ktrans),ifm1 + amod2 oscili ifm2*(indx2+ktrans),ifm2 + amod3 oscili ifm3*(indx3+ktrans),ifm3 + asig oscili iamp,(ifqc+amod1+amod2+amod3)*(1+kvib) + asig linen (asig+attack),irise,idur,idec + asig butterhp asig, 800 + asig butterhp asig, 200 + kenv linseg 0, p3*0.25, 0.7, p3*0.5, 1, p3*0.25, 0 + asig *= kenv + asig *= 0.2 + aL = asig + aR = asig + bus_mix("delay1", aL, aR) +bus_mix("reverb", aL, aR) + + +endin + + +instr play_303 + iamp = bid_getparameter(p4, p5, 2) + ifilter = random(50, 70) + inote = tab_i(random(1, ftlen(gibid_chordfn) - 1), gibid_chordfn) + + ifrq1 = 440 * exp(log(2) * (ifilter - 69) / 12) ; filter start freq. + kamp linseg 1, p3-0.01, 1, 0.025, 0, 1, 0 ; release envelope + kcps init cpsmidinn(inote) + kffrq port 0, 60/150, ifrq1 ; filter frequency + a1 phasor kcps ; oscillator + a1 = 1 - 2 * a1 + + a1x butterbp a1, kffrq, kcps * 1.0 ; filters + a1x = a1x * (2 + kffrq / kcps) ; correct amplitude + a1 = a1x + a1 * 0.25 ; 0.5 + a1 butterlp a1, kffrq + + a1 = taninv(a1 * 4 * iamp) ; distortion ; 2.5 + + keqf limit kffrq * 4, 10, sr * 0.48 ; EQ frequency + a1 pareq a1 * 0.4, keqf, 4.0, 1.0, 2 + a1 butterhp a1, 250 + a1 = a1 * kamp * 0.72 + aL, aR pan2 a1, random(0.3, 0.7) + bus_mix("reverb", aL*0.3, aR*0.3) + bus_mix("master", aL*0.8, aR*0.8) +endin + +instr chord1 + inote = p4 + iamp = p5 + kfreq init cpsmidinn(inote) + + aphs1 phasor kfreq + aphs2 phasor kfreq + koda = abs(oscil(random(0, 2), random(0, 1))) + a1 tablei aphs1, gifnSine, 1, 0, 1 + a1 *= linseg(1, p3*0.9, 0) + + av1L linseg 3, p3, 0 + aL tablei (aphs2+a1)+av1L+koda, gifnSine, 1, 0, 1 + + av1R linseg 4, p3, 0 + aR tablei (aphs2+a1)+av1R+koda, gifnSine, 1, 0, 1 + + kfi linseg 0, p3*0.2, 1, p3*0.8, 1 + aL phaser1 aL*kfi, oscil:k(7400, 0.1, gifnSine, random(0, 0.5)) + 1000, 8, .9 + aR phaser1 aR*kfi, oscil:k(7400, 0.1, gifnSine, random(0, 0.5)) + 1000, 8, .9 + aL *= 0.16 * iamp + aR *= 0.16 * iamp + aL butterhp aL, 520 + aR butterhp aR, 520 + if (i(gksection) == 3) then + aL butterlp aL, 1000 + aR butterlp aR, 1000 + endif + bus_mix("delay1", aL, aR) + ;bus_mix("master", aL, aR) +endin + + +/* + Play chord1 above, called from BID +*/ +instr play_chord1 + chordinstrument "chord1", p4, p5 + turnoff +endin + +instr play_stringchord + chordinstrument "string", p4, p5 + turnoff +endin + + + +#end |