Hi! On Mon, 27 Sep 2004 14:40:58 -0700, Andrew Warren wrote: > > I guessed that A was amplitude, and tried various values; I set > initial X1 to 1. X0 output just cycled through four values, no > matter how I adjusted ToneFreq, SampleRate, A, and X1... So I > assume that I'm missing something important. It's a standard algorithm, and a very good one to implement using fixed point arithmetic. It's simpler to describe it this way: x(0) = Amplitude x(1) = x(0) - e/2 x(n) = (2-e) x(n-1) - x(n-2) = 2*x(n-1) - e * x(n-1) - x(n-2) Then, the frequency is: f = sampleRate * acos(1-e/2) / (2pi) I once run a simulator to search "best values" of "A" and "e", using fixed point arithmetic. Using 8.8 bits (ie, 16 bit add and mult), I found it to be really stable. Daniel _______________________________________________ http://www.piclist.com View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist