title: How do I plot the spectrum of a wav file using FFT?
body: <p>NOTE: This is not a duplicate, I have specific requirements other than related questions.</p>
  
  <p>To start with, I want to plot the spectrum of an audio file (.wav) just like what audacity does (similar: <a href="https://stackoverflow.com/questions/10664105/how-to-draw-a-frequency-spectrum-from-a-fourier-transform">How to draw a frequency spectrum from a Fourier transform</a>).</p>
  
  <p>So far I am able to read and write wav files. But my problem is I don't know exactly what values I need to pass to the FFT function. By the way I am using Exocortex for FFT in C#. The FFT function requires me to pass an array of complex numbers with the right size (512, 1024, ... I presume), an optional integer parameter for length, and the fourier direction (forward/backward).</p>
  
  <p>Specific Questions:</p>
  
  <ol>
  <li>The Complex (class) from the Exocortex library has two values namely Real and Imaginary. I have the array of samples, so which should be real and which should be Imaginary?</li>
  <li>I have the wav file, so the length should be assumed variable. How do I pass that to the FFT function? Should I select a size (512/1024/etc), divide the the entire samples to the size, then pass all of it to the FFT?</li>
  <li>How do i know what frequencies should be listed down on the x-axis?</li>
  <li>How do I plot the FFT'ed data? (I want the x-axis to be frequency, and y-axis in decibels)</li>
  </ol>
  
  <p>If you don't get what I mean, then try to use Audacity, import an audio file, then click Analyze > Plot Spectrum. Those are the things want to recreate. Please answer my question in details because I really want to learn this. I only have a little background on this. I am just a newbie in digital signal processing. Also as much as possible please don't direct me to other FFT sites because they don't answer my question specifically.</p>
  
  <hr>
  
  <p>EDIT:</p>
  
  <p>I've done some reading and found out how to FFT an audio data but only in powers of 2. So how do I do the same in an audio file with a length that's not of powers of 2? According to some I need to use "window". I've also done some searching about it and found out that it only takes an portion of the waveform to be processed later. Remember above that I want to get the FFT of the audio file not a portion of it. So what should I do now? Please help :(</p>