Frequency detector


    Apr 16 2011 | 2:18 pm
    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?

    • Apr 16 2011 | 3:19 pm
      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...
    • Apr 16 2011 | 5:07 pm
      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.
    • Apr 16 2011 | 5:39 pm
      >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!!!
    • Apr 16 2011 | 8:50 pm
      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...
    • Apr 16 2011 | 9:43 pm
      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.
    • Apr 17 2011 | 4:20 pm
      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?
    • Apr 17 2011 | 5:37 pm
      I imagine that the Axon technique could work on many/most sounds, but it would need to be trained for different classes of sounds.
    • Apr 18 2011 | 10:14 am
      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.
    • Apr 18 2011 | 2:14 pm
      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)
    • Apr 18 2011 | 5:55 pm
      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
    • Apr 18 2011 | 9:55 pm
      @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 :(
    • May 12 2011 | 4:32 pm
      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.
    • Apr 19 2016 | 7:30 pm
      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.