Hello somebody, does somebody have experiences with sliding Goertzel algorithm? With K, which is not integer number? And what about some differences between G. filter and G. algorithm? Last week I implemented GA in DSP (Freescale 56F8037) and it works very well for integer K, but for non-integer K this alorithm gives incorrect results. If I tried to use "normal" GA (without sliding), it began to work. Amazing :-). But I cannot understand, why it happens. Any ideas? Thank you a lot. Miroslav _____________________________ Posted through www.DSPRelated.com

# Sliding Goertzel problem

Started by ●July 3, 2013

Reply by ●July 3, 20132013-07-03

>Hello somebody, > >does somebody have experiences with sliding Goertzel algorithm? With K, >which is not integer number? And what about some differences between G. >filter and G. algorithm? > >Last week I implemented GA in DSP (Freescale 56F8037) and it works very >well for integer K, but for non-integer K this alorithm gives incorrect >results. If I tried to use "normal" GA (without sliding), it began towork.>Amazing :-). But I cannot understand, why it happens. Any ideas? > >Thank you a lot. > >Miroslav > >Ouh, I have made a mistake in the first line of my question. Instead"Hello somebody" I wanted to write: "Hello everybody" :-). As I said it some days before, my English is terrible. I am sorry...> > > >_____________________________ >Posted through www.DSPRelated.com >_____________________________ Posted through www.DSPRelated.com

Reply by ●July 3, 20132013-07-03

On Wednesday, July 3, 2013 3:09:09 AM UTC-4, Mimar wrote:> Hello somebody, > > > > does somebody have experiences with sliding Goertzel algorithm? With K, > > which is not integer number? And what about some differences between G. > > filter and G. algorithm? > > > > Last week I implemented GA in DSP (Freescale 56F8037) and it works very > > well for integer K, but for non-integer K this alorithm gives incorrect > > results. If I tried to use "normal" GA (without sliding), it began to work. > > Amazing :-). But I cannot understand, why it happens. Any ideas? > > > > Thank you a lot. > > > > Miroslav > > > > > > > > > > > > _____________________________ > > Posted through www.DSPRelated.comHello Mimar, There are several ways to think about the Goertzel algo and then the sliding Goertzel. First of all, it is a way to recursively compute the DFT of a block of data for a given frequency. If your frequency is such that you have an integral number of cycles within the block, then your results (apart from numerical precision) will be the same as expected with the DFT. Normally one doesn't try to compute the DFT with non-integral frequecies since many of the DFT's properties will no longer be true. The other way of thinking about the Goertzel algo is as a 2nd order filter with its poles on the unit circle. Here one seems decoupled from the integer frequency requirement since filters are generally adjustable. However, if you stray away form the integral frequencies, then some of the DFT's properties no longer apply. You just have to keep that in mind. The sliding Goertzel is a way to calculate the Goertzel over and over again on overlapping blocks of data. The Goertzel algo is normally presented as a driven biquad oscillator - that formulation (although he didn't call it a filter - he gave the actual formula for the recursion) is what is in Goerzel's original paper. However it is easy to use other oscillator structures to achieve the same result and some of these other structures have superior numerical properties when compared to the classic Goertzel algo. IHTH, Clay

Reply by ●July 3, 20132013-07-03

On Wed, 03 Jul 2013 02:21:43 -0500, Mimar wrote:>>Hello somebody, >> >>does somebody have experiences with sliding Goertzel algorithm? With K, >>which is not integer number? And what about some differences between G. >>filter and G. algorithm? >> >>Last week I implemented GA in DSP (Freescale 56F8037) and it works very >>well for integer K, but for non-integer K this alorithm gives incorrect >>results. If I tried to use "normal" GA (without sliding), it began to > work. >>Amazing :-). But I cannot understand, why it happens. Any ideas? >> >>Thank you a lot. >> >>Miroslav >> >>Ouh, I have made a mistake in the first line of my question. Instead > "Hello somebody" I wanted to write: "Hello everybody" :-). As I said it > some days before, my English is terrible. I am sorry...Well, you wanted everybody to look, but you were hoping that somebody would answer. So nobody would say that you were entirely wrong, and anybody could see what you meant. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com

Reply by ●July 3, 20132013-07-03

On Wed, 03 Jul 2013 02:09:09 -0500, Mimar wrote:> Hello somebody, > > does somebody have experiences with sliding Goertzel algorithm? With K, > which is not integer number? And what about some differences between G. > filter and G. algorithm? > > Last week I implemented GA in DSP (Freescale 56F8037) and it works very > well for integer K, but for non-integer K this alorithm gives incorrect > results. If I tried to use "normal" GA (without sliding), it began to > work. > Amazing :-). But I cannot understand, why it happens. Any ideas?It's hard to say without knowing the details. Any filter that tries to find the amplitude of a sine wave from a non-integer number of cycles is going to be subject to difficulties, Goertzel or not. Is it possible to post a _succinct_ expression of the algorithm? Not 50 lines of code, but maybe 5 lines of math? -- Tim Wescott Wescott Design Services http://www.wescottdesign.com

Reply by ●July 3, 20132013-07-03

On 7/3/13 9:57 AM, Tim Wescott wrote:> On Wed, 03 Jul 2013 02:09:09 -0500, Mimar wrote: > > > It's hard to say without knowing the details. Any filter that tries to > find the amplitude of a sine wave from a non-integer number of cycles is > going to be subject to difficulties, Goertzel or not. >isn't that what window functions are for? -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."

Reply by ●July 3, 20132013-07-03

On Wed, 03 Jul 2013 11:12:58 -0700, robert bristow-johnson wrote:> On 7/3/13 9:57 AM, Tim Wescott wrote: >> On Wed, 03 Jul 2013 02:09:09 -0500, Mimar wrote: >> >> >> It's hard to say without knowing the details. Any filter that tries to >> find the amplitude of a sine wave from a non-integer number of cycles >> is going to be subject to difficulties, Goertzel or not. >> >> > isn't that what window functions are for?Well, one question to ask is if he's using a window function. That's why I was asking for details! -- Tim Wescott Wescott Design Services http://www.wescottdesign.com

Reply by ●July 3, 20132013-07-03

On 7/3/13 11:26 AM, Tim Wescott wrote:> On Wed, 03 Jul 2013 11:12:58 -0700, robert bristow-johnson wrote: > >> On 7/3/13 9:57 AM, Tim Wescott wrote: >>> On Wed, 03 Jul 2013 02:09:09 -0500, Mimar wrote: >>> >>> >>> It's hard to say without knowing the details. Any filter that tries to >>> find the amplitude of a sine wave from a non-integer number of cycles >>> is going to be subject to difficulties, Goertzel or not. >>> >>> >> isn't that what window functions are for? > > Well, one question to ask is if he's using a window function.he's gotta be using *some* window function. if he doesn't know, then it's likely the rect(). and a sliding rect() window applied to a sinusoid that does not have an integer number of cycles in the width of that rect() "is going to be subject to difficulties". it will matter much in how that rect() window lands on top of the waveform. but with a decent window with decaying tails on both sides, it might not matter so much how the window lands on top of the waveform. and if he's tracking a known frequency (that is not at the center of the DFT bin), he should be able to use the sliding DFT for the closest DFT bin and the adjacent bins and interpolate results. but then, if he knew the exact frequency, the dot product that he's doing with the DFT could be using the exact frequency, rather than the nice DFT bin frequencies.> That's why I was asking for details!details are for the anal retentive. :-) -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."

Reply by ●July 3, 20132013-07-03

>Hello somebody, > >does somebody have experiences with sliding Goertzel algorithm? With K, >which is not integer number? And what about some differences between G. >filter and G. algorithm? > >Last week I implemented GA in DSP (Freescale 56F8037) and it works very >well for integer K, but for non-integer K this alorithm gives incorrect >results. If I tried to use "normal" GA (without sliding), it began towork.>Amazing :-). But I cannot understand, why it happens. Any ideas? > >Thank you a lot. > >Miroslav >Could you elaborate on what you mean by incorrect results? _____________________________ Posted through www.DSPRelated.com

Reply by ●July 4, 20132013-07-04

>On Wed, 03 Jul 2013 02:09:09 -0500, Mimar wrote: > >> Hello somebody, >> >> does somebody have experiences with sliding Goertzel algorithm? With K, >> which is not integer number? And what about some differences between G. >> filter and G. algorithm? >> >> Last week I implemented GA in DSP (Freescale 56F8037) and it works very >> well for integer K, but for non-integer K this alorithm gives incorrect >> results. If I tried to use "normal" GA (without sliding), it began to >> work. >> Amazing :-). But I cannot understand, why it happens. Any ideas? > >It's hard to say without knowing the details. Any filter that tries to >find the amplitude of a sine wave from a non-integer number of cycles is >going to be subject to difficulties, Goertzel or not. > >Is it possible to post a _succinct_ expression of the algorithm? Not 50 >lines of code, but maybe 5 lines of math? > >-- > >Tim Wescott >Wescott Design Services >http://www.wescottdesign.com > >Hello,this a part of my code I have used to simulate of G. algorithm lately. It is written in Matlab. So I have already mentioned, for K = integer (usually K = 1) it works as well as I want. %........Goertzel.................................................. k = 1; N = 48: %fs = 2400 Hz pik_term = 2 * pi * k./N; const_cos = 2 * cos(pik_term); const_exp = cos(pik_term) - 1i*sin(pik_term); xn_M = 0; fifo = zeros(1, N); % buffer s0 = 0; % states s1 = 0; s2 = 0; y_G = zeros(1, signal_length); for n = 1 : 1 : signalľength % loop fifo = [fifo(2:N), signal(n)]; % sample in buffer input = signal(n) - xn_M; s0 = s1 * const_cos - s2 + input; y_G(n) = (s0 - s1 * const_exp)*exp(-1i*2*pi*k); s2 = s1; % 1/z s1 = s0; % 1/z % y_G(i) = s0 - temp; xn_M = fifo(1); end y_G = y_G/N; y_G = 2*abs(y_G); % result If I saw this code is functional I overwrote it in C and assembler for 56F8300 Freescale core last week. I used fixed point Q7.24 format to get good accuracy. But the problem with real number K continues still :-(. _____________________________ Posted through www.DSPRelated.com