title: Autocorrelation and Fundamental Frequency
body: <p>I am trying to figure out fundamental frequency of sound</p>
  
  <p>I try to detect fundamental frequency with autocorrelation.</p>
  
  <p>I found this code:</p>
  
  <pre><code>corr = np.correlate(signal, signal, mode='full')
  maxcorr = np.argmax(corr)
  corr = corr / corr[maxcorr]
  corr = corr[corr.size / 2:]
  </code></pre>
  
  <p>I got this graph from the code above:
      <a href="https://i.stack.imgur.com/NT3oa.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NT3oa.jpg" alt="enter image description here"></a></p>
  
  <p>index of maximum value is 3145.
  and my sample rate is 44100.</p>
  
  <p>so... I got fundamental frequency 44100/3145 = 14.02.</p>
  
  <p>This is way too wrong since the sound is Piano C4 which should be around 261Hz.</p>
  
  <p>How can I get fundamental frequency with autocorrelation?</p>
  
  <p><strong>ADDED:</strong></p>
  
  <p>this is a graph of C4 of piano
  <a href="https://i.stack.imgur.com/MjoiD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MjoiD.jpg" alt="enter image description here"></a></p>