Hi All,

I'm not sure if this there is a bug in my code or if this is something
to do with UDO's.  I have the following CSD:

<CsoundSynthesizer>

<CsInstruments>
sr=48000
ksmps=16
nchnls=2





	opcode lpf2,a,aii

/* FILTSET CODE */
setksmps 1
ain, icfreq, izeta	xin

ixval	= tan( 3.14159265358979323846 * icfreq/sr);
ixval1	= ixval+1.0 ;
ixval2	= ixval*ixval;


/* first order filter coefs */
ifparms0	= ixval / ixval1;
ifparms1	= (1.0 - ixval) / ixval1;
ifparms2	= 1.0 / ixval1;

idenom		= ixval2 + (2.0 * izeta * ixval) + 1.0;


/* second order filter coefs */
ifparms3	= 2.0 * (1.0-ixval2) / idenom;
ifparms4	= -(ixval2 - 2.0*izeta*ixval + 1.0) / idenom;
ifparms5	= ixval / idenom;
ifparms6	= ixval2 / idenom;
ifparms7	= (ixval2+1.0) / idenom;
ifparms8	= 1.0 / idenom;


/* **********************************************************************************
*/

afstate0	init 0
afstate1	init 0 	

/* LPF2 CODE */

av1	= ain + ifparms3 * afstate0  + ifparms4* afstate1;
av2	= afstate1 + 2.0 * afstate0;

afstate1 = afstate0
afstate0 = av1

aout = ifparms6 * ( av1 + av2 )

	xout	aout

	endop


	instr 1	;Sound
;insert instrument text here

ipch = 220

aout	vco2	10000, ipch
aout	lpf2	aout, ipch * 4, .707

kenv	adsr	0.1, .05, .9, .2

aout	= aout * kenv

outs aout, aout
	endin


</CsInstruments>

<CsScore>

i1	0.0	2.0	
e

</CsScore>

</CsoundSynthesizer>


(The lpf2 is a direct translation of lpf2 in Music4C.)  If I either
set ksmps=1 in the project or use setksmps 1 as in the above, things
sound correctly.  If I don't use setksmps or ksmps=1, the sound is
wrong.  However, looking at the code, all of the calculations in lpf2
*should* run at arate and calculate correctly without having to set
ksmps.

Is there something wrong with my assumption or is there a bug either
in my code or in UDO's?

Any help appreciated!
steven