frequency readout

Post any examples or modules that you want to share here
BobF
Posts: 598
Joined: Mon Apr 20, 2015 9:54 pm

frequency readout

Post 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.....
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: frequency "readout"

Post 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...
BobF
Posts: 598
Joined: Mon Apr 20, 2015 9:54 pm

Re: frequency readout

Post by BobF »

Thanks a lot Martin, I should have know that one. Just was not thinking clearly I guess.
Take care, BobF.....
User avatar
MyCo
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany
Contact:

Re: frequency readout

Post 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.
Attachments
Peak Frequency (MyCo).fsm
(8.5 KiB) Downloaded 1250 times
BobF
Posts: 598
Joined: Mon Apr 20, 2015 9:54 pm

Re: frequency readout

Post by BobF »

Hi MyCo,

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

Take care, BobF.....
User avatar
Spogg
Posts: 3368
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England
Contact:

Re: frequency readout

Post 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
Attachments
Period and Frequency detector 1.0.fsm
Detects the frequency and period of an audio input.
(33.29 KiB) Downloaded 1269 times
Perfect Human Interface
Posts: 643
Joined: Sun Mar 10, 2013 7:32 pm

Re: frequency readout

Post 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!? :)
BobF
Posts: 598
Joined: Mon Apr 20, 2015 9:54 pm

Re: frequency readout

Post 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.....
User avatar
MyCo
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany
Contact:

Re: frequency readout

Post 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...
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: frequency readout

Post 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.
Post Reply