title: Graphing the pitch (frequency) of a sound
body: <p>I want to plot the pitch of a sound into a graph.</p>
  
  <p>Currently I can plot the amplitude. The graph below is created by the data returned by <code>getUnscaledAmplitude()</code>:</p>
  
  <p><img src="https://i.stack.imgur.com/a2pVM.jpg" alt="alt text"></p>
  
  <pre><code>AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new BufferedInputStream(new FileInputStream(file)));
  byte[] bytes = new byte[(int) (audioInputStream.getFrameLength()) * (audioInputStream.getFormat().getFrameSize())];
  audioInputStream.read(bytes);
  
  // Get amplitude values for each audio channel in an array.
  graphData = type.getUnscaledAmplitude(bytes, 1);
  
  
  public int[][] getUnscaledAmplitude(byte[] eightBitByteArray, int nbChannels)
  {
      int[][] toReturn = new int[nbChannels][eightBitByteArray.length / (2 * nbChannels)];
      int index = 0;
  
      for (int audioByte = 0; audioByte &lt; eightBitByteArray.length;)
      {
          for (int channel = 0; channel &lt; nbChannels; channel++)
          {
              // Do the byte to sample conversion.
              int low = (int) eightBitByteArray[audioByte];
              audioByte++;
              int high = (int) eightBitByteArray[audioByte];
              audioByte++;
              int sample = (high &lt;&lt; 8) + (low &amp; 0x00ff);
  
              toReturn[channel][index] = sample;
          }
          index++;
      }
  
      return toReturn;
  }
  </code></pre>
  
  <p>But I need to show the audio's pitch, not amplitude. <a href="http://en.wikipedia.org/wiki/Fast_Fourier_transform">Fast Fourier transform</a> appears to get the pitch, but it needs to know more variables than the raw bytes I have, and is very complex and mathematical.</p>
  
  <p>Is there a way I can do this?</p>