Frequency detector

periklis's icon

Hi guys,

here is my question: i need a frequency detector which works without fft. Is there any autocorrelation patch or some idea of how i could detect frequency of a (relative...) periodic signal?

mudang's icon

In the FTM library there's an external called gbr.yin~. It implements the Yin algorithm which is a kind of improved autocorrelation and works quite well for monophonic sources.

If you have a very "clean" signal, zerox~ might also do the job...

Chris Muir's icon

The old-school guitar synthesizer method is to clip the signal until you have a more or less square wave, then analyze the period of the square wave. It doesn't work all that well, though. You probably want to low-pass filter the signal before you clip it.

periklis's icon

>If you have a very "clean" signal, zerox~ might also do the job...

I tried zerox~ but there is this problem with the signal vector. To get a good response out of it, concerning the number of crossings-which by the way should EXACTLY do what i am looking for-i have to push mr. vector at 2048 samples which is (theoretically at least...) bringing some latency to the output. But i'll try the yin~ thing right now!

Thanks a lot both of you guys!!!

mudang's icon

Latency is always an issue with frequency detection - no matter if you use fft, autocorrelation or zero counting.
This of course depends on the lowest frequency you want to be able to detect.

For autocorrelation you'll need twice the period length of the lowest frequency.

There seem to be techniques to do a frequency detection within a fraction of the period length (used in guitar to midi boxes, f.e.) - but I've never found any details on them...

Chris Muir's icon

The best one I know of is the Axon / Blue Chip method, licensed to Yamaha, who appear to be sitting on it these days. It supposedly used a pre-trained neural network to look at the slope of the wave and make a decision based on the first quarter-cycle.

I have the Yamaha G-50, which incorporates this, and it is way faster than anything by Roland, which mostly uses period detection.

Jean-Francois Charles's icon

Thanks Chris for the insight.
Do you know if it works as well for other instruments than guitar, or is this technique really optimized for guitar and less performant on other instruments?

About autocorrelation vs FFT analysis: when you use FFT, you need to use a window which size is a power-of-two number of samples. With autocorrelation, you can tune the window size more precisely to the lowest frequency you are looking for.

Anybody knows what kind of method the Eventide boxes use?

Chris Muir's icon

I imagine that the Axon technique could work on many/most sounds, but it would need to be trained for different classes of sounds.

mudang's icon

The neural net is used to find the pluck impulse and the first (bridge) and second (fret) reflection on a string.

The second trick they use is to only count zero crossings with a maximum slope. As far as I understand it, this is only to avoid octave-errors due to strong harmonics.

periklis's icon

This is very helpful. Thanks! very clever also :-))
I also used the yin~ object and it does an excellent job! And i must say, that pushing the vector at 2048 (for doing simple zerox detection) didn't caused me any latency problems (even with other more demanding patches)

mzed's icon

I've also done pitch detection using a wavelet transform. You still need a fair number of samples (say 512) before you get the result, but unlike fft's the resolution is pretty good in the lower frequencies.

mz

mudang's icon

@mzed:
How do you do the wavelet transform in max ?

At the moment i'm writing a polyphonic pitch detection using fft. To get a good enough resolution to discern 12TET steps in the lower frequency i need to have a 8192 fft window :(

mzed's icon

I've done the transform and detection as an external object written in C. IMHO, doing this kind of analysis is pretty inefficient, both on the programming side and when its running.

Adam Bowman's icon

Hey, I'm interested in this subject as well. Do any of you know if the latency produced using any of these objects is most consistent? I want to use pitch detection with inaudible pitches to make an external device that hears sequences of 8 different unique inaudible pitches(pretty much just an inaudible repeating melody)per computer to be played along side each other at the same tempo on two different computers and than measure the difference in time of one specified pitch corresponding to a number in the cycle on one computer with another pitch corresponding to the same number of the cycle on the other computer and use that difference to synchronize a count of 8 between max patches on separate computers. the external hardware will be powered by an Arduino Uno logic board. It doesn't really matter if there is latency, I just need the latency to be consistent for this to work worth anything.