# Parallel Goertzel filters in C# [closed]

I have 2 frequencies in my application: $12000\mathrm{Hz}$, $13000\mathrm{Hz}$. I want to set a parallel Goertzel filters and every 100ms I want to take the bigger magnitude for detecting the tone received.

Is there any way to implement this? That is, how can I evaluate two functions in parallel in C#?

I work on WPF, C#

Thanks

## closed as off-topic by jojek♦, MBaz, lennon310, Peter K.♦May 21 '15 at 16:44

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "General programming questions are off-topic here, but can be asked on Stack Overflow." – jojek, MBaz, lennon310, Peter K.
If this question can be reworded to fit the rules in the help center, please edit the question.

• Yes, there is a way to implement this. Next question, please. – JRE May 21 '15 at 8:36
• My question is not: "Hey, Give me a link for something that works". But: How making this filters in c# run parallel to each other? Or, in other words, how can I run 2 codes in the same time? – axcelenator May 21 '15 at 8:42
• Is your question about concurrency in C# or a parallel filter topology? It sounds like the latter, but reads like the former. If you can be more clear (add some images, give some background that shows you've done your research), you will get better answers. – ruoho ruotsi May 21 '15 at 16:39

## 1 Answer

First of all, a link to an example of the Goertzel algorithm.

Second, the goertzel algorithm is so fast that you don't need to get into multithreading.

Just create a class that does the goertzel algorithm for a frequency and sampling rate that you define when you create an instance.
Make a list or array of instances of that class, then for every sample, run through that array and have it calculate the goertzel for that sample.

In your case, you just need two instances so you don't really need an array of instances. Fast and simple.
I've done this very thing with several hundred instances on a fairly old PC, and updating the GUI causes more of a load than the processing.