## DSP: The two bin solution

### DSP: The two bin solution

https://dsp.stackexchange.com/questions ... of-signals

The code demonstrates how to calculate the frequency, amplitude, and phase of a pure real tone. Although is quite efficient is also somewhat fragile. Too much noise/interference can lead to errors in the calculation and a frequency that is too close to a bin will also fare poorly. There are remedies for both situations, but have not been implemented as to not obscure the workings of the math.

I will be writing a blog article as a fuller explanation. In the meanwhile, the original explanations of the derivations of the equations are available in prior articles:

https://www.dsprelated.com/showarticle/1095.php

https://www.dsprelated.com/showarticle/787.php

The program does the following steps:

1) Generate a synthetic pure real tone signal

2) Calculates two DFT bins

3) Calculates the frequency from the two bin values

4) Calculates the amplitude and phase from the two bin values and the frequency

Don't let anybody tell you it can't be done. This code proves otherwise.

Ced

.... and carry a big stick!

- cogier
- Site Admin
**Posts:**286**Joined:**Wednesday 21st September 2016 2:22pm**Location:**Guernsey, Channel Islands

### Re: DSP: The two bin solution

This is way over my head but I see you like a puzzle.

I spent a lot of time working on the tasks at Rosetta Code. Many of my solutions are under Examples on the Gambas Playground. I have done over a hundred of these here. There is a list here of tasks that need to be completed. I managed to get Gambas up to position 93 for the languages with the most contributions, it has slipped to 245, see here.

The site prompted me to write the 15 Puzzle game which is available here

I thought you, or anybody reading this, might like to add to the list.

I spent a lot of time working on the tasks at Rosetta Code. Many of my solutions are under Examples on the Gambas Playground. I have done over a hundred of these here. There is a list here of tasks that need to be completed. I managed to get Gambas up to position 93 for the languages with the most contributions, it has slipped to 245, see here.

The site prompted me to write the 15 Puzzle game which is available here

I thought you, or anybody reading this, might like to add to the list.

### Re: DSP: The two bin solution

Hey Gogier,

That is a neat resource. If my to do list wasn't so long I would knock a few of those off.

Yeah, this is some esoteric math, but it is actually some core DSP stuff. It is not nearly as impenetrable as it appears at first glance, once you start to understand it. I've got the blog article which explains the code and references the source articles posted.

https://www.dsprelated.com/showarticle/1284.php

I'm not sure how much more useful that is to a DSP newbie, but for someone who was taught that what I did is impossible, it should be illuminating.

Ced

That is a neat resource. If my to do list wasn't so long I would knock a few of those off.

Yeah, this is some esoteric math, but it is actually some core DSP stuff. It is not nearly as impenetrable as it appears at first glance, once you start to understand it. I've got the blog article which explains the code and references the source articles posted.

https://www.dsprelated.com/showarticle/1284.php

I'm not sure how much more useful that is to a DSP newbie, but for someone who was taught that what I did is impossible, it should be illuminating.

Ced

.... and carry a big stick!