Csound Csound-dev Csound-tekno Search About

[Csnd] Implementing Goertzel algorithm with standard filters?

Date2020-07-15 21:15
From"Jeanette C."
Subject[Csnd] Implementing Goertzel algorithm with standard filters?
Hey hey,
the Goertzel algorithm is an optimised DFT to only detect one frequency at a 
time.

On Wikipedia it says that it's basically an IIR filter followed by an FIR 
filter:
https://en.wikipedia.org/wiki/Goertzel_algorithm#The_algorithm

Are there standard filters in Csound that can be used to implement that, or 
would it be necessary/ more expedient to implement the given formulae directly 
working on the sample level?

Best wishes and TIA,

Jeanette

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * SoundCloud: https://soundcloud.com/jeanette_c
  * Twitter: https://twitter.com/jeanette_c_s
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

For whatever reason,
I feel like I've been wanting you all my life <3
(Britney Spears)

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2020-07-15 21:52
FromVictor Lazzarini
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Implementing Goertzel algorithm with standard filters?
as an aside, this seems to be similar to the sliding DFT algorithm (which is used for thr full spectrum).

Prof. Victor Lazzarini
Maynooth University
Ireland

> On 15 Jul 2020, at 21:15, Jeanette C.  wrote:
> 
> *Warning*
> 
> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
> 
> Hey hey,
> the Goertzel algorithm is an optimised DFT to only detect one frequency at a
> time.
> 
> On Wikipedia it says that it's basically an IIR filter followed by an FIR
> filter:
> https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FGoertzel_algorithm%23The_algorithm&data=02%7C01%7CVictor.Lazzarini%40mu.ie%7C7c86cfc6500745ae1b4d08d828fbdc8f%7C1454f5ccbb354685bbd98621fd8055c9%7C1%7C0%7C637304409486808919&sdata=4dnYLC49waDevdVhyGT1OU6rHBDtwG%2FUnjdaHdPLnBw%3D&reserved=0
> 
> Are there standard filters in Csound that can be used to implement that, or
> would it be necessary/ more expedient to implement the given formulae directly
> working on the sample level?
> 
> Best wishes and TIA,
> 
> Jeanette
> 
> --
> * Website: https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fjuliencoder.de%2F&data=02%7C01%7CVictor.Lazzarini%40mu.ie%7C7c86cfc6500745ae1b4d08d828fbdc8f%7C1454f5ccbb354685bbd98621fd8055c9%7C1%7C0%7C637304409486808919&sdata=428oRsHijiS%2Bd1Q8UHWlltYzCNgZcsaTb6UZ%2BCQesEU%3D&reserved=0 - for summer is a state of sound
> * Youtube: https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.youtube.com%2Fchannel%2FUCMS4rfGrTwz8W7jhC1Jnv7g&data=02%7C01%7CVictor.Lazzarini%40mu.ie%7C7c86cfc6500745ae1b4d08d828fbdc8f%7C1454f5ccbb354685bbd98621fd8055c9%7C1%7C0%7C637304409486808919&sdata=GujOO95%2B0yoaE2gYYn8SJqbxRaT2BOaLEXxT6cCY7eE%3D&reserved=0
> * SoundCloud: https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsoundcloud.com%2Fjeanette_c&data=02%7C01%7CVictor.Lazzarini%40mu.ie%7C7c86cfc6500745ae1b4d08d828fbdc8f%7C1454f5ccbb354685bbd98621fd8055c9%7C1%7C0%7C637304409486808919&sdata=1GJavtI8DC2IznAp2n01rNjCzLnUuCusgxFrwNCzltQ%3D&reserved=0
> * Twitter: https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Ftwitter.com%2Fjeanette_c_s&data=02%7C01%7CVictor.Lazzarini%40mu.ie%7C7c86cfc6500745ae1b4d08d828fbdc8f%7C1454f5ccbb354685bbd98621fd8055c9%7C1%7C0%7C637304409486818911&sdata=cQ43GBLdYwOeBe4FJvwjNxSzm5O8nVqAADYnH1ZSndw%3D&reserved=0
> * Audiobombs: https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.audiobombs.com%2Fusers%2Fjeanette_c&data=02%7C01%7CVictor.Lazzarini%40mu.ie%7C7c86cfc6500745ae1b4d08d828fbdc8f%7C1454f5ccbb354685bbd98621fd8055c9%7C1%7C0%7C637304409486818911&sdata=bjhflx%2FyonXAr3poM9vOaHdlUUhpk7uDCKj4L462F%2BI%3D&reserved=0
> * GitHub: https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjeanette-c&data=02%7C01%7CVictor.Lazzarini%40mu.ie%7C7c86cfc6500745ae1b4d08d828fbdc8f%7C1454f5ccbb354685bbd98621fd8055c9%7C1%7C0%7C637304409486818911&sdata=40H1U2l9uoSUetdg9Ge9QS8qzVdozwYRRDPl0Y1XNao%3D&reserved=0
> 
> For whatever reason,
> I feel like I've been wanting you all my life <3
> (Britney Spears)
> 
> Csound mailing list
> Csound@listserv.heanet.ie
> https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flistserv.heanet.ie%2Fcgi-bin%2Fwa%3FA0%3DCSOUND&data=02%7C01%7CVictor.Lazzarini%40mu.ie%7C7c86cfc6500745ae1b4d08d828fbdc8f%7C1454f5ccbb354685bbd98621fd8055c9%7C1%7C0%7C637304409486818911&sdata=tfwPFa2u9ywJ4LTFcAXnwjoI%2BgsMhJ%2BHrwbLLdzHwLU%3D&reserved=0
> Send bugs reports to
>       https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcsound%2Fcsound%2Fissues&data=02%7C01%7CVictor.Lazzarini%40mu.ie%7C7c86cfc6500745ae1b4d08d828fbdc8f%7C1454f5ccbb354685bbd98621fd8055c9%7C1%7C0%7C637304409486818911&sdata=T7cVzFBRhp%2B2QA72YyUnQplQddI8h00dmJNVqLNz%2FW0%3D&reserved=0
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2020-07-16 09:51
FromJana Hübenthal
SubjectRe: [Csnd] Implementing Goertzel algorithm with standard filters?
Hi Jeanette,

first to say, the underlying math of the Goertzel is quite a bit beyond my scope...

But: it is usually used to detect single frequencies in a spectrum. Why not use a "normal" bandpass filter, feeding its output into an amplitude follower? 

That would be my approach, from a practical view. Maybe you are more on an academic road, so the real Goertzel may be the one to try.

Best,
Jana

> Jeanette C.  hat am 15. Juli 2020 22:15 geschrieben:
> 
>  
> Hey hey,
> the Goertzel algorithm is an optimised DFT to only detect one frequency at a 
> time.
> 
> On Wikipedia it says that it's basically an IIR filter followed by an FIR 
> filter:
> https://en.wikipedia.org/wiki/Goertzel_algorithm#The_algorithm
> 
> Are there standard filters in Csound that can be used to implement that, or 
> would it be necessary/ more expedient to implement the given formulae directly 
> working on the sample level?
> 
> Best wishes and TIA,
> 
> Jeanette
> 
> -- 
>   * Website: http://juliencoder.de - for summer is a state of sound
>   * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
>   * SoundCloud: https://soundcloud.com/jeanette_c
>   * Twitter: https://twitter.com/jeanette_c_s
>   * Audiobombs: https://www.audiobombs.com/users/jeanette_c
>   * GitHub: https://github.com/jeanette-c
> 
> For whatever reason,
> I feel like I've been wanting you all my life <3
> (Britney Spears)
> 
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2020-07-16 10:00
From"Jeanette C."
SubjectRe: [Csnd] Implementing Goertzel algorithm with standard filters?
Hi Jana!
Jul 16 2020, Jana Hübenthal has written:
...
> Why not use a "normal" bandpass filter, feeding its output into an amplitude follower?
That was an idea and that approach was used in telecommunications.
>
> That would be my approach, from a practical view. Maybe you are more on an academic road, so the real Goertzel may be the one to try.
It's not exactly an academic project, but curiosity and the thought that
this algorithm in practise should be very efficient and "simple", for a
given value of simplicity. :) Otherwise it wouldn't be usable in "slow"
embedded hardware.

If standard Csound filters can't be used in an easy manner, I probably
will go for the filterbank approach.
...

Best wishes,

Jeanette

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * SoundCloud: https://soundcloud.com/jeanette_c
  * Twitter: https://twitter.com/jeanette_c_s
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

There's no time to loose
And next week,
You might not see me here <3
(Britney Spears)

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2020-07-16 15:50
FromJustin Smith
SubjectRe: [Csnd] Implementing Goertzel algorithm with standard filters?
my understanding is that most of the complexity of FFT is in
decomposing the filters so that partial calculated results can be
reused

if you only care about one frequency, a band pass suffices, and the
simple (AKA does the least CPU work) version of that is a low-pass
followed by a high-pass, with a shared cut-off band

On Thu, Jul 16, 2020 at 2:00 AM Jeanette C.  wrote:
>
> Hi Jana!
> Jul 16 2020, Jana Hübenthal has written:
> ...
> > Why not use a "normal" bandpass filter, feeding its output into an amplitude follower?
> That was an idea and that approach was used in telecommunications.
> >
> > That would be my approach, from a practical view. Maybe you are more on an academic road, so the real Goertzel may be the one to try.
> It's not exactly an academic project, but curiosity and the thought that
> this algorithm in practise should be very efficient and "simple", for a
> given value of simplicity. :) Otherwise it wouldn't be usable in "slow"
> embedded hardware.
>
> If standard Csound filters can't be used in an easy manner, I probably
> will go for the filterbank approach.
> ...
>
> Best wishes,
>
> Jeanette
>
> --
>   * Website: http://juliencoder.de - for summer is a state of sound
>   * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
>   * SoundCloud: https://soundcloud.com/jeanette_c
>   * Twitter: https://twitter.com/jeanette_c_s
>   * Audiobombs: https://www.audiobombs.com/users/jeanette_c
>   * GitHub: https://github.com/jeanette-c
>
> There's no time to loose
> And next week,
> You might not see me here <3
> (Britney Spears)
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2020-07-16 15:59
FromJustin Smith
SubjectRe: [Csnd] Implementing Goertzel algorithm with standard filters?
I posted too soon.

on further consideration, if you want amplitude following with
smoothing, putting the high pass before the low pass probably makes
more sense, and depending on the slope characteristics of the filters
being used, you might want to experiment with the cutoff frequencies
to trade off tightness and stability

going back to the original question, there's likely something to the
FIR / IIR combo that's escaping me at the moment, and do consider that
most filters are made of chained / sequenced single or double pole FIR
or IIR. I think filter2 or zfilter2 might be a good building block
depending on your comfort with the math. I've a vague idea that some
professionals will use an engineering tool like matlab to design
filter coefficients then plug them into an opcode when they find the
set that work.

On Thu, Jul 16, 2020 at 7:50 AM Justin Smith  wrote:
>
> my understanding is that most of the complexity of FFT is in
> decomposing the filters so that partial calculated results can be
> reused
>
> if you only care about one frequency, a band pass suffices, and the
> simple (AKA does the least CPU work) version of that is a low-pass
> followed by a high-pass, with a shared cut-off band
>
> On Thu, Jul 16, 2020 at 2:00 AM Jeanette C.  wrote:
> >
> > Hi Jana!
> > Jul 16 2020, Jana Hübenthal has written:
> > ...
> > > Why not use a "normal" bandpass filter, feeding its output into an amplitude follower?
> > That was an idea and that approach was used in telecommunications.
> > >
> > > That would be my approach, from a practical view. Maybe you are more on an academic road, so the real Goertzel may be the one to try.
> > It's not exactly an academic project, but curiosity and the thought that
> > this algorithm in practise should be very efficient and "simple", for a
> > given value of simplicity. :) Otherwise it wouldn't be usable in "slow"
> > embedded hardware.
> >
> > If standard Csound filters can't be used in an easy manner, I probably
> > will go for the filterbank approach.
> > ...
> >
> > Best wishes,
> >
> > Jeanette
> >
> > --
> >   * Website: http://juliencoder.de - for summer is a state of sound
> >   * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
> >   * SoundCloud: https://soundcloud.com/jeanette_c
> >   * Twitter: https://twitter.com/jeanette_c_s
> >   * Audiobombs: https://www.audiobombs.com/users/jeanette_c
> >   * GitHub: https://github.com/jeanette-c
> >
> > There's no time to loose
> > And next week,
> > You might not see me here <3
> > (Britney Spears)
> >
> > Csound mailing list
> > Csound@listserv.heanet.ie
> > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> > Send bugs reports to
> >         https://github.com/csound/csound/issues
> > Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here