<info>
Simple band-pass filter.
Gain is post-balance.

Alexandre Burton , 1996
(rev.2/12/97 for 1.8)
</info>
<tk_interface>
cfilein source    -label "Input Soundfile"
cpopup name -label "Filter type" -value "lowpass highpass bandpass" 
ctoggle balance   -label "balance output with input (pre-gain)"
cgraph center -label "frequency" -unit Hz  -relation log   -min 20 -max 15000 -init 1000
csepar 
cslider reso -label "resonance" -unit x -min 1   -max 20  -init 2 
csepar 
cgraph gain -label "output\ngain" -unit x -rel log -min .1 -max 10 -init 1
</tk_interface>
<mono>
; mono passband filter

				     instr 1
	 
gkcenter init 400
gkwidth  init .3

kfac	=	[sinfo source sr]/sr
aing diskin "[source]", kfac, [offsource]

kband    = cpsoct(octcps(gkcenter)+gkwidth/2) - cpsoct(octcps(gkcenter)-gkwidth/2)

         if	(gkbutterwrt == 1) igoto butter 

afiltg	  reson	aing,   gkcenter, kband, 1
afiltg	  reson	afiltg, gkcenter, kband, 1
         goto bal

butter:
afiltg	  butterbp	aing, gkcenter, kband
afiltg	  butterbp	afiltg, gkcenter, kband

bal:
         if 	(gkbalance == 0 ) goto nobal
afiltg	  balance afiltg, aing

nobal:
	     out	afiltg*gkgain
	
				     endin
</mono>
<stereo>
; stereo passband filter

				     instr 1
igo	=	i(gk name)

kfac	=  [sinfo source sr]/sr 
aing,aind diskin "[source]", kfac, [offsource]  


alowg,ahig,abang	  svfilter	aing, gkcenter, gireso,2
alowd,ahid,aband	  svfilter	aind, gkcenter ,gireso  ,2  
 
if igo==1 goto hi  
if igo==2 goto band
	aoud	=	alowd
	aoug	=	alowg  
	goto outer

hi:
	aoud	=	ahid
	aoug	=	ahig
	goto outer
band:
	aoud	=	aband
	aoug	=	abang 
outer:
if gkbalance == 0 goto nobal
aoud	balance	aoud,aind
aoug	balance	aoug,aing 

nobal:
 	     outs	aoud*gkgain, aoug *gkgain
				     endin
</stereo>
<quad>

</quad>
<score>
#minimum
</score>
