<CsoundSynthesizer><CsOptions>; Select audio/midi flags here according to platform; Audio out Audio in No messages-odac -d
; -iadc ;;;RT audio I/O; For Non-realtime ouput leave only the line below:; -o biquad.wav -W ;;; for file output any platform</CsOptions><CsInstruments>; Initialize the global variables.sr=44100kr=4410ksmps=10nchnls=2; Instrument #1.instr1; Get the values from the score.dur:i=p3amp:i=p4cps:i=cpspch(p5)fco:a=expon(100,dur,2000)rez:a=line(0.8,dur,0.99); Calculate the biquadratic filter's coefficients fcon:a=2*3.14159265*fco/sralpha:a=1-2*rez*cos(fcon)*cos(fcon)+rez*rez*cos(2*fcon)beta:a=rez*rez*sin(2*fcon)-2*rez*cos(fcon)*sin(fcon)gama:a=1+cos(fcon)m1:a=alpha*gama+beta*sin(fcon)m2:a=alpha*gama-beta*sin(fcon)den:a=sqrt(m1*m1+m2*m2)b0:a=1.5*(alpha*alpha+beta*beta)/denb1:a=b0b2:a=0a0=1a1=-2*rez*cos(fcon)a2=rez*rez; Generate an input signal.xn:a=vco(1,cps,1); Filter the input signal.yn:a=biquada(xn,b0,b1,b2,a0,a1,a2)yn*=amp/2outs(yn,yn)endin</CsInstruments><CsScore>; Table #1, a sine wave.f1016384101; Sta Dur Amp Pitchi10.05.0200006.00e</CsScore></CsoundSynthesizer>
Here is an example of the biquada opcode. It uses the file
biquada.csd.
<CsoundSynthesizer><CsOptions>; Select audio/midi flags here according to platform; Audio out Audio in No messages-odac -iadc -d ;;;RT audio I/O; For Non-realtime ouput leave only the line below:; -o biquad.wav -W ;;; for file output any platform</CsOptions><CsInstruments>; Initialize the global variables.sr=44100kr=4410ksmps=10nchnls=2; Instrument #1.instr1; Get the values from the score.idur=p3iamp=p4icps=cpspch(p5)afcoexpon100,p3,2000arezline0.8,p3,0.99; Calculate the biquadratic filter's coefficients afcon=2*3.14159265*afco/sraalpha=1-2*arez*cos(afcon)*cos(afcon)+arez*arez*cos(2*afcon)abeta=arez*arez*sin(2*afcon)-2*arez*cos(afcon)*sin(afcon)agama=1+cos(afcon)am1=aalpha*agama+abeta*sin(afcon)am2=aalpha*agama-abeta*sin(afcon)aden=sqrt(am1*am1+am2*am2)ab0=1.5*(aalpha*aalpha+abeta*abeta)/adenab1=ab0ab2=0aa0=1aa1=-2*arez*cos(afcon)aa2=arez*arez; Generate an input signal.axnvco1,icps,1; Filter the input signal.aynbiquadaaxn,ab0,ab1,ab2,aa0,aa1,aa2outsayn*iamp/2,ayn*iamp/2endin</CsInstruments><CsScore>; Table #1, a sine wave.f1016384101; Sta Dur Amp Pitchi10.05.0200006.00e</CsScore></CsoundSynthesizer>