<Cabbage> bounds(0, 0, 0, 0)
form caption("Amateur") size(400, 300), colour(0, 51, 153),pluginid("amat")
keyboard bounds(6, 170, 381, 95) value(53)
combobox bounds(4, 38, 110, 20) channel("osc1") text("piano", "el piano (SIN)", "e-bass", "e-organ (SAW)", "distorted", "guitar (SQR)", "organ", "oboe")
combobox bounds(172, 38, 103, 20) text("piano", "el piano (SIN)", "e-bass", "e-organ (SAW)", "distorted", "guitar (SQR)", "organ", "oboe") channel("osc2") value(2)

rslider bounds(66, 2, 36, 32) range(1, 3, 2, 1, 1) channel("osc1transpose")
rslider bounds(204, 0, 37, 33) range(1, 3, 2, 1, 1) channel("osc2transpose")

rslider bounds(122, 30, 45, 37) range(0, 1, 0.5, 1, 0.001) channel("oscmix")

label bounds(106, 8, 80, 16) text("OSC")
label bounds(36, 74, 80, 16) text("ENV")
rslider bounds(4, 96, 55, 43) range(0.01, 1, 0.01, 1, 0.001) channel("attack")
rslider bounds(94, 94, 53, 45) range(0.01, 1, 0.5, 1, 0.001) channel("decay")
checkbox bounds(64, 100, 27, 30) channel("hold") value(1)
label bounds(18, 142, 34, 16) text("A")
label bounds(100, 142, 39, 16) text("D/R")
label bounds(60, 142, 34, 16) text("S")

label bounds(298, 10, 80, 16) text("FILTER")
combobox bounds(298, 38, 80, 20) channel("filter_mode") text("none", "quack", "quack & bite")


label bounds(258, 76, 80, 16) text("FX")
rslider bounds(238, 98, 42, 40) range(0, 1, 0, 1, 0.001) channel("phaser")
label bounds(230, 142, 54, 16) text("phaser")
rslider bounds(292, 98, 46, 42) range(0, 1, 0, 1, 0.001) channel("chorus")
label bounds(286, 142, 57, 16) text("chorus")
rslider bounds(346, 98, 48, 41) range(0, 1, 0, 1, 0.001) channel("reverb")
label bounds(346, 142, 49, 16) text("reverb")

vslider bounds(152, 72, 50, 87) range(0, 1, 0.5, 1, 0.001) channel("vol")
checkbox bounds(8, 272, 18, 19) channel("wheelmix")
label bounds(32, 274, 179, 17) text("mix with modwheel?") channel("wheelmix")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables. 
ksmps = 32
nchnls = 2
0dbfs = 1

giWaves[] init 9

giWaves[1] ftgen 0, 0, 0, 1, "awkf/AKWF_piano_0001.wav", 0, 0, 0
giWaves[2] ftgen 0, 0, 0, 1, "awkf/AKWF_epiano_0014.wav", 0, 0, 0
giWaves[3] ftgen 0, 0, 0, 1, "awkf/AKWF_ebass_0042.wav", 0, 0, 0
giWaves[4] ftgen 0, 0, 0, 1, "awkf/AKWF_eorgan_0033.wav", 0, 0, 0
giWaves[5] ftgen 0, 0, 0, 1, "awkf/AKWF_eguitar_0011.wav", 0, 0, 0
giWaves[6] ftgen 0, 0, 0, 1, "awkf/AKWF_eguitar_0003.wav", 0, 0, 0
giWaves[7] ftgen 0, 0, 0, 1, "awkf/AKWF_eorgan_0114.wav", 0, 0, 0
giWaves[8] ftgen 0, 0, 0, 1, "awkf/AKWF_oboe_0013.wav", 0, 0, 0

giTranspose[] init 4
giTranspose[1] = 0.5
giTranspose[2] = 1
giTranspose[3] = 2

gaOut init 0

;Author: Iain McCurdy (2012)
opcode	Phaser,a,akkkKki
	ain,krate,kdepth,kfreq,kstages,kfback,ishape	xin		;READ IN INPUT ARGUMENTS
	if ishape=1 then
	 klfo	lfo	kdepth*0.5, krate, 1				;LFO FOR THE PHASER (TRIANGULAR SHAPE)
	elseif ishape=2 then
	 klfo	lfo	kdepth*0.5, krate, 0				;LFO FOR THE PHASER (SINE SHAPE)
	elseif ishape=3 then
	 klfo	lfo	kdepth*0.5, krate, 2				;LFO FOR THE PHASER (SQUARE SHAPE)
	elseif ishape=4 then
	 klfo	lfo	kdepth*0.5, krate, 4				;LFO FOR THE PHASER (SAWTOOTH)
	elseif ishape=5 then
	 klfo	lfo	kdepth*0.5, krate, 5				;LFO FOR THE PHASER (SAWTOOTH)
	elseif ishape=6 then
	 klfo	randomi	-kdepth*0.5, kdepth*0.5, krate*8		;LFO FOR THE PHASER (RANDOMI SHAPE)
	 klfo	portk	klfo, 1/(krate*8)				;SMOOTH CHANGES OF DIRECTION
	elseif ishape=7 then
	 klfo	randomh	-kdepth*0.5, kdepth*0.5, krate			;LFO FOR THE PHASER (RANDOMH SHAPE)
	endif	
	aout	phaser1	ain, cpsoct((klfo+(kdepth*0.5)+kfreq)), kstages, kfback	;PHASER1 IS APPLIED TO THE INPUT AUDIO
		xout	aout							;SEND AUDIO BACK TO CALLER INSTRUMENT
endop

/* ------- */

;instrument will be triggered by keyboard widget
instr 1
    kbnd pchbend 0, 100
    kcps = p4 + kbnd
    
    iosc1 chnget "osc1"
    iosc1_transpose chnget "osc1transpose"
    aOutA poscil3 0.6, kcps * giTranspose[iosc1_transpose], giWaves[iosc1]
    
    iosc2 chnget "osc2"
    iosc2_transpose chnget "osc2transpose"
    aOutB poscil3 0.6, kcps * giTranspose[iosc2_transpose], giWaves[iosc2]
    
    iwheelmix chnget "wheelmix"
    if iwheelmix==1 then
        koscmix midictrl 1 , 0 , 1
        printk(0.2,koscmix)
    else
        koscmix chnget "oscmix"
    endif 
    aOut ntrpol aOutA, aOutB, koscmix
    
    iattack chnget "attack"
    idecay chnget "decay"
    isustain chnget "hold"
    
    if isustain == 1 then
        kEnv madsr iattack, 0.0001, 1, idecay+iattack
    else
        kEnv linsegr 0, iattack, 1, idecay, 0, iattack+idecay, 0
    endif
    
    ifilter_mode chnget "filter_mode"
    if ifilter_mode == 2 then
        aOut moogladder aOut, 12000, 0
    elseif ifilter_mode == 3 then
        aOut moogladder aOut, 12000, 0.3
    endif
            
    gaOut += aOut*kEnv
endin

instr 2
    aOut = gaOut
    
    kphaser chnget "phaser"
    aPhased Phaser aOut, 0.5, 4, 8, 8, 0.36, 1
    aOut ntrpol aOut, aPhased, kphaser
    
    aL = aOut
    aR = aOut
    
    kchorus chnget "chorus"
    kchorus = kchorus / 2
    
    ; chorus
    amod1 = randi:a(3,.75)+oscili(2,.35)+31
    amod2 = randi:a(2,.65)+oscili(3,.55)+29
    a1 = vdelay(aL*.5,amod1,35)
    a2 = vdelay(aR*.5,amod2,35)

    aLchorus = aL + a1
    aRchorus = aR + a2
    
    aL ntrpol aL, aLchorus, kchorus
    aR ntrpol aR, aRchorus, kchorus
    
    ; reverb
    kreverb chnget "reverb"
    kreverb = kreverb / 3 
    
    aLreverb, aRreverb reverbsc aL, aR, 0.8, 12000
    
    aL = aL + (aLreverb * kreverb)
    aR = aR + (aRreverb * kreverb)
    
    ; volume
    
    kVol chnget "vol"
    
    aL clip aL*kVol, 0, 0.9
    aR clip aR*kVol, 0, 0.9
    
    outs aL, aR
    gaOut = 0
endin

schedule 2, 0, -1





</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z
</CsScore>
</CsoundSynthesizer>
