Page 1 of 2

frequency readout

Posted: Wed May 13, 2015 6:47 pm
by BobF
Hello all,

Could some kind person show me a simple fsm frequency readout (meter) for reading oscillator and such outputs.

Thank you, BobF.....

Re: frequency "readout"

Posted: Wed May 13, 2015 11:08 pm
by martinvicanek
There is no such thing as a frequency readout. You can readout sample values, but frequency is another quality. What you can do is analyze the signal and try to extract a frequency. Clearly, that will not work for polyphonic signals.

There are pitch extractors around here and in the SM forum based on different algorithms including counting zero crossings, ADSF, heterodyning and FFT. Perhaps that would be a good FS Guru blog topic. Hmmm...

Re: frequency readout

Posted: Thu May 14, 2015 1:06 am
by BobF
Thanks a lot Martin, I should have know that one. Just was not thinking clearly I guess.
Take care, BobF.....

Re: frequency readout

Posted: Thu May 14, 2015 11:48 am
by MyCo
You can estimate the peak freqency quite easily... but it's not accurate, and sometime you might not even get any close to what you want.

Re: frequency readout

Posted: Thu May 14, 2015 2:33 pm
by BobF
Hi MyCo,

and thanks a lot. I guess for now anything is better than nothing !

Take care, BobF.....

Re: frequency readout

Posted: Fri May 15, 2015 5:02 pm
by Spogg
Hi
I just made this quick and dirty one and it seems to work well, especially in the lower ranges (unlike the FFT one above which gets better at higher frequencies but very inaccurate for Bass).
When you trim mine to give middle A an output of 440 Hz then you get an accuracy of better than 0.3% across the useful audio range. There's also a Period output provided.
Free to a good home!
Cheers
Spogg

Re: frequency readout

Posted: Fri May 15, 2015 5:32 pm
by Perfect Human Interface
Hmm... I remember Martin was working on some pitch detection stuff that he wanted to use with bass ranges. It never occurred to me that certain methods work better for high freq while others work better for low...

Maybe there's a way to combine them!? :)

Re: frequency readout

Posted: Fri May 15, 2015 5:38 pm
by BobF
Hello Spogg,

Hey, thanks a lot. With yours and MyCo's I should be set.
Again thanks and take care.
Later then, BobF.....

Re: frequency readout

Posted: Fri May 15, 2015 7:19 pm
by MyCo
Perfect Human Interface wrote:It never occurred to me that certain methods work better for high freq while others work better for low...


There are many methods. They all have their pros and cons.
The FFT version above is just a good starting point. When you have an estimate, you could use eg. autocorrelation to fine trim your results. And this can be done fairly efficient. eg. when you have the FFT estimate, you position 2 autocorrelations, with a delay of sample_rate/(fft_peak_freq (+/-) offset). Then you'll find out, which of those 2 autocorrelations was better and in the next run you'll finetune the delays to sample_rate/(fft_peak_freq (+/-) last_best_offset + offset/2) ... and so on...

Never tested it though...

Re: frequency readout

Posted: Fri May 15, 2015 11:18 pm
by martinvicanek
It is not hard to extract the frequency of a static sine wave. You get a single peak in the FFT spectrum which you can take as it is, or you could get sub-bin resolution by taking the neighbor bins into account. Or simply measure the time between two successive zero crossings, use linear interpolation for subsample accuracy. The true challenge, however, is with real world signals: they are varying in pitch and have harmonics often stronger than the fundamental. Pitch or fundamental frequency estimation of such material requres more sophisticated algorithms than simple zero crossings or FFT peak location. A good pitch tracker should lock on the fundamental, should be accurate, and should adapt fast to pitch changes without producing artifacts. The task is even tougher if you want to do it in real time and with finite resources.