pseudo code in Scilab notation time=[start_time:(1/sample_rate):(start_time+N/sample_rate)]; signal = S[1:N]; analysis_real=sin(2*%pi*time); analysis_imag=cos(2*%pi*time); output=((signal*analysis_real')^2 +(signal*analysis_imag')^2)^.5 Is that Goertzel? or Could someone point me to source code for Goertzel in BASIC or FORTRAN? I've found C/C++ source but I don't read C.

# Am I reinventing Goertzel etc?

Started by ●November 16, 2007

Reply by ●November 16, 20072007-11-16

"Richard Owlett" schrieb> pseudo code in Scilab notation > > time=[start_time:(1/sample_rate):(start_time+N/sample_rate)]; > signal = S[1:N]; > analysis_real=sin(2*%pi*time); > analysis_imag=cos(2*%pi*time); > output=((signal*analysis_real')^2 +(signal*analysis_imag')^2)^.5 > > Is that Goertzel? > > or > Could someone point me to source code for Goertzel in BASIC orFORTRAN?> I've found C/C++ source but I don't read C. >No source code, but a good explanation (IMHO, YMMV): http://www.embedded.com/story/OEG20020819S0057 HTH Martin

Reply by ●November 16, 20072007-11-16

On Fri, 16 Nov 2007 07:31:39 -0600, Richard Owlett wrote:> pseudo code in Scilab notation > > time=[start_time:(1/sample_rate):(start_time+N/sample_rate)]; > signal = S[1:N]; > analysis_real=sin(2*%pi*time); > analysis_imag=cos(2*%pi*time); > output=((signal*analysis_real')^2 +(signal*analysis_imag')^2)^.5 > > Is that Goertzel? > > or > Could someone point me to source code for Goertzel in BASIC or FORTRAN? > I've found C/C++ source but I don't read C.The Goertzel algorithm uses an IIR filter with special properties to emulate an FIR filter. You're implementing the FIR filter itself, which is arguably a better approach to the task. Absent of odd numerical effects, your algorithm will do the same as the Goertzel. -- Tim Wescott Control systems and communications consulting http://www.wescottdesign.com Need to learn how to apply control theory in your embedded system? "Applied Control Theory for Embedded Systems" by Tim Wescott Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html

Reply by ●November 16, 20072007-11-16

Martin Blume wrote:> "Richard Owlett" schrieb > >>pseudo code in Scilab notation >> >>time=[start_time:(1/sample_rate):(start_time+N/sample_rate)]; >>signal = S[1:N]; >>analysis_real=sin(2*%pi*time); >>analysis_imag=cos(2*%pi*time); >>output=((signal*analysis_real')^2 +(signal*analysis_imag')^2)^.5 >> >>Is that Goertzel? >> >>or >>Could someone point me to source code for Goertzel in BASIC or > > FORTRAN? > >>I've found C/C++ source but I don't read C. >> > > > No source code, but a good explanation (IMHO, YMMV): > http://www.embedded.com/story/OEG20020819S0057 > > HTH > Martin > >One of the articles I was using.

Reply by ●November 16, 20072007-11-16

Tim Wescott wrote:> On Fri, 16 Nov 2007 07:31:39 -0600, Richard Owlett wrote: > > >>pseudo code in Scilab notation >> >>time=[start_time:(1/sample_rate):(start_time+N/sample_rate)]; >>signal = S[1:N]; >>analysis_real=sin(2*%pi*time); >>analysis_imag=cos(2*%pi*time); >>output=((signal*analysis_real')^2 +(signal*analysis_imag')^2)^.5 >> >>Is that Goertzel? >> >>or >>Could someone point me to source code for Goertzel in BASIC or FORTRAN? >>I've found C/C++ source but I don't read C. > > > The Goertzel algorithm uses an IIR filter with special properties to > emulate an FIR filter. You're implementing the FIR filter itself, which > is arguably a better approach to the task. > > Absent of odd numerical effects, your algorithm will do the same as the > Goertzel. >I take it then that its "bandwidth" would the same dependence on sample rate and number of samples used to do the calculation.

Reply by ●November 16, 20072007-11-16

On Nov 16, 5:31 am, Richard Owlett <rowl...@atlascomm.net> wrote:> pseudo code in Scilab notation > > time=[start_time:(1/sample_rate):(start_time+N/sample_rate)]; > signal = S[1:N]; > analysis_real=sin(2*%pi*time); > analysis_imag=cos(2*%pi*time); > output=((signal*analysis_real')^2 +(signal*analysis_imag')^2)^.5 > > Is that Goertzel?Goertzel seems to refer to the filter method above, but with calculating the sine and cosine coefficients using a recurrence formula in the form of an IIR resonator (but I've seen using various other recurrences referred to here as Goertzel-XYZ for various XYZ). They work roughly the same as a 1-bin DFT, but have slightly different accuracy and efficiency characteristics. IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M

Reply by ●November 16, 20072007-11-16

Richard Owlett wrote:> Tim Wescott wrote: > >> On Fri, 16 Nov 2007 07:31:39 -0600, Richard Owlett wrote: >> >> >>> pseudo code in Scilab notation >>> >>> time=[start_time:(1/sample_rate):(start_time+N/sample_rate)]; >>> signal = S[1:N]; >>> analysis_real=sin(2*%pi*time); >>> analysis_imag=cos(2*%pi*time); >>> output=((signal*analysis_real')^2 +(signal*analysis_imag')^2)^.5 >>> >>> Is that Goertzel? >>> >>> or >>> Could someone point me to source code for Goertzel in BASIC or FORTRAN? >>> I've found C/C++ source but I don't read C. >> >> >> The Goertzel algorithm uses an IIR filter with special properties to >> emulate an FIR filter. You're implementing the FIR filter itself, which >> is arguably a better approach to the task. >> >> Absent of odd numerical effects, your algorithm will do the same as the >> Goertzel. >> > > I take it then that its "bandwidth" would the same dependence on sample > rate and number of samples used to do the calculation. >Yes. Instead of saying "Absent of ..." I should have said "Your algorithm does _exactly_ what the Goertzel does". Conclusions for A apply to B, and visa versa. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" gives you just what it says. See details at http://www.wescottdesign.com/actfes/actfes.html

Reply by ●November 17, 20072007-11-17

Tim Wescott wrote:> Richard Owlett wrote: > >> Tim Wescott wrote: >> >>> On Fri, 16 Nov 2007 07:31:39 -0600, Richard Owlett wrote: >>> >>> >>>> pseudo code in Scilab notation >>>> >>>> time=[start_time:(1/sample_rate):(start_time+N/sample_rate)]; >>>> signal = S[1:N]; >>>> analysis_real=sin(2*%pi*time); >>>> analysis_imag=cos(2*%pi*time); >>>> output=((signal*analysis_real')^2 +(signal*analysis_imag')^2)^.5 >>>> >>>> Is that Goertzel? >>>> >>>> or >>>> Could someone point me to source code for Goertzel in BASIC or FORTRAN? >>>> I've found C/C++ source but I don't read C. >>> >>> >>> >>> The Goertzel algorithm uses an IIR filter with special properties to >>> emulate an FIR filter. You're implementing the FIR filter itself, which >>> is arguably a better approach to the task. >>> >>> Absent of odd numerical effects, your algorithm will do the same as the >>> Goertzel. >>> >> >> I take it then that its "bandwidth" would the same dependence on >> sample rate and number of samples used to do the calculation. >> > Yes. Instead of saying "Absent of ..." I should have said "Your > algorithm does _exactly_ what the Goertzel does". Conclusions for A > apply to B, and visa versa. >Hmmm. Is it valid to stretch things a little further. In my pseudo code, I wrote "signal = S[1:N]" with the explicit presumption that S[1:N] was a pure sinusoid. What if I replaced it with the DFT of a desired frequency response? If viable, how would I specify the frequency response to account for the folding around Nyquist frequency that is observed when going from time --> frequency domain?

Reply by ●November 17, 20072007-11-17

"Tim Wescott" schrieb> > > pseudo code in Scilab notation > > > > time=[start_time:(1/sample_rate):(start_time+N/sample_rate)]; > > signal = S[1:N]; > > analysis_real=sin(2*%pi*time); > > analysis_imag=cos(2*%pi*time); > > output=((signal*analysis_real')^2 +(signal*analysis_imag')^2)^.5 > > > > Is that Goertzel? > > > > or > > Could someone point me to source code for Goertzel > > in BASIC or FORTRAN? > > I've found C/C++ source but I don't read C. > > The Goertzel algorithm uses an IIR filter with special propertiesto> emulate an FIR filter. You're implementing the FIR filter itself,which> is arguably a better approach to the task. > > Absent of odd numerical effects, your algorithm will do the > same as the Goertzel. >Sorry for being so dumb, could you elucidate a little bit more just how this is equivalent to a Goertzel algorithm? For instance, where does the frequency of interest for the filter come in? I'm not fluent in Scilab, what does the "%" in> analysis_real = sin(2*%pi*time)mean? Shouldn't there be a frequency term somewhere in this formula? What does sin(12 seconds) mean? Please help me. Martin

Reply by ●November 17, 20072007-11-17

On Sat, 17 Nov 2007 07:02:10 -0600, Richard Owlett wrote:> Tim Wescott wrote: >> Richard Owlett wrote: >> >>> Tim Wescott wrote: >>> >>>> On Fri, 16 Nov 2007 07:31:39 -0600, Richard Owlett wrote: >>>> >>>> >>>>> pseudo code in Scilab notation >>>>> >>>>> time=[start_time:(1/sample_rate):(start_time+N/sample_rate)]; >>>>> signal = S[1:N]; >>>>> analysis_real=sin(2*%pi*time); >>>>> analysis_imag=cos(2*%pi*time); >>>>> output=((signal*analysis_real')^2 +(signal*analysis_imag')^2)^.5 >>>>> >>>>> Is that Goertzel? >>>>> >>>>> or >>>>> Could someone point me to source code for Goertzel in BASIC or FORTRAN? >>>>> I've found C/C++ source but I don't read C. >>>> >>>> >>>> >>>> The Goertzel algorithm uses an IIR filter with special properties to >>>> emulate an FIR filter. You're implementing the FIR filter itself, which >>>> is arguably a better approach to the task. >>>> >>>> Absent of odd numerical effects, your algorithm will do the same as the >>>> Goertzel. >>>> >>> >>> I take it then that its "bandwidth" would the same dependence on >>> sample rate and number of samples used to do the calculation. >>> >> Yes. Instead of saying "Absent of ..." I should have said "Your >> algorithm does _exactly_ what the Goertzel does". Conclusions for A >> apply to B, and visa versa. >> > > Hmmm. Is it valid to stretch things a little further. > > In my pseudo code, I wrote "signal = S[1:N]" with the explicit > presumption that S[1:N] was a pure sinusoid. What if I replaced it with > the DFT of a desired frequency response? If viable, how would I specify > the frequency response to account for the folding around Nyquist > frequency that is observed when going from time --> frequency domain?Do you mean if you used the DFT instead of a Goertzel, or if you replaced your signal with it's DFT? In the former case, the DFT and Goertzel will still be identical. They'll act on S[1:N], _as sampled_, which means the aliasing has already happened. If you want to show the response going from frequencies in the time domain to the output of your DFT or Goertzel, then figure out the effects of any anti-alias filtering, then the effects of sampling, then the effect of the sampled-time filtering. For more about sampling see this: http://www.wescottdesign.com/articles/Sampling/sampling.html. For even more, see a good book on DSP (such as Rick Lyons' book). -- Tim Wescott Control systems and communications consulting http://www.wescottdesign.com Need to learn how to apply control theory in your embedded system? "Applied Control Theory for Embedded Systems" by Tim Wescott Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html