<Cabbage>
form caption("Blumenkraft") size(400, 300), colour(58, 110, 182), pluginid("def1")
keyboard bounds(8, 158, 381, 95)
vslider bounds(4, 6, 30, 88) range(0.01, 0.5, 0.010, 1, 0.001) channel("bass_attack")
vslider bounds(36, 6, 30, 88) range(0.01, 0.5, 0.01, 1, 0.001) channel("bass_decay")
vslider bounds(68, 6, 30, 88) range(0.01, 0.3, 0, 1, 0.001) channel("bass_orch1")
vslider bounds(100, 6, 30, 88) range(0.01, 0.3, 0, 1, 0.001) channel("bass_orch2")
vslider bounds(132, 6, 30, 88) range(0, 0.2, 0, 1, 0.001) channel("bass_cello")
vslider bounds(164, 6, 30, 88) range(0, 0.2, 0, 1, 0.001) channel("bass_viola")
vslider bounds(196, 6, 30, 88) range(0, 0.2, 0, 1, 0.001) channel("bass_violin")
</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

;Author: Iain McCurdy (2012)
;http://iainmccurdy.org/csound.html
opcode	StChorusRspline,aa,aakkkkkk
	ainL,ainR,krate,kdereg,kdepth,koffset,kwidth,kmix	xin		;READ IN INPUT ARGUMENTS
	kporttime	linseg	0,0.001,0.02					;RAMPING UP PORTAMENTO VARIABLE
	kChoDepth	portk	kdepth*0.01, kporttime				;SMOOTH VARIABLE CHANGES WITH PORTK	
	kmod1		rspline	koffset,kChoDepth, krate*4+0.01, ((krate*4*kdereg)+0.01)
	kmod2		rspline	kChoDepth,koffset, krate*4+0.01, ((krate*4*kdereg)+0.01)
	kmod1		limit	kmod1,0.0001,1.2
	kmod2		limit	kmod2,0.0001,1.2
	amod1		interp	kmod1	
	amod2		interp	kmod2
	aCho1		vdelay	ainL, amod1*1000, 1.2*1000			;CREATE VARYING DELAYED / CHORUSED SIGNAL (LEFT CHANNEL) 
	aCho2		vdelay	ainR, amod2*1000, 1.2*1000			;CREATE VARYING DELAYED / CHORUSED SIGNAL (RIGHT CHANNEL)
	kpan		rspline	0,1,krate,2*krate*kdereg			;PANNING
	kpan		limit	kpan,0,1
	apan		interp	kpan
	aChoL		=	(aCho1*apan)+(aCho2*(1-apan))
	aChoR		=	(aCho2*apan)+(aCho1*(1-apan))
	aChoL		ntrpol	aChoL,aCho1,kwidth				;WIDTH PROCESSING BETWEEN AUTO-PANNED AND HARD-PANNED
	aChoR		ntrpol	aChoR,aCho2,kwidth
	aoutL		ntrpol 	ainL*0.6, aChoL*0.6, kmix			;MIX DRY AND WET SIGNAL (LEFT CHANNEL)
	aoutR		ntrpol 	ainR*0.6, aChoR*0.6, kmix			;MIX DRY AND WET SIGNAL (RIGHT CHANNEL)
			xout	aoutL,aoutR					;SEND AUDIO BACK TO CALLER INSTRUMENT
endop

;instrument will be triggered by keyboard widget
instr 1
    ; note freq and offset
    inotnum notnum
    kcps = cpsmidinn(inotnum)
    kcpsVi = cpsmidinn(inotnum - 12) * cent(2)
    kcpsCe = cpsmidinn(inotnum - 24) * cent(-1)
    
    i_bass_attack chnget "bass_attack"
    i_bass_decay chnget "bass_decay"
    
    k_bass_violin chnget "bass_violin"
    k_bass_viola chnget "bass_viola"
    k_bass_cello chnget "bass_cello"

    k_bass_env madsr i_bass_attack, 0.0001, 1, i_bass_decay  
    
    aViolin vco2 k_bass_violin, kcps
    aViola vco2 k_bass_viola, kcpsVi
    aCello vco2 k_bass_cello, kcpsCe
    
    aOut = (aViolin + aViola + aCello) * k_bass_env
    
    krate = 0.5
    kdereg = 1
    kdepth = 0.3
    koffset = 0.01
    kwidth = 0.68
    kmix = 0.5
    
    aOutL, aOutR StChorusRspline aOut,aOut, krate,kdereg,kdepth,koffset,kwidth,kmix
    
    outs aOutL, aOutR
endin

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