title: Determining what frequencies correspond to the x axis in aurioTouch sample application
body: <p>I'm looking at the <a href="https://developer.apple.com/iphone/library/samplecode/aurioTouch/Introduction/Intro.html" rel="nofollow noreferrer">aurioTouch sample application</a> for the iPhone SDK. It has a basic <a href="http://en.wikipedia.org/wiki/Spectrum_analyzer" rel="nofollow noreferrer">spectrum analyzer</a> implemented when you choose the "FFT" option. One of the things the app is lacking is X axis labels (i.e. the frequency labels).</p>
  
  <p>In the <a href="https://developer.apple.com/iphone/library/samplecode/aurioTouch/Listings/Classes_aurioTouchAppDelegate_mm.html#//apple_ref/doc/uid/DTS40007770-Classes_aurioTouchAppDelegate_mm-DontLinkElementID_6" rel="nofollow noreferrer">aurioTouchAppDelegate.mm</a> file, in the function <code>- (void)drawOscilloscope</code> at line 652, it has the following code:</p>
  
  <pre><code>if (displayMode == aurioTouchDisplayModeOscilloscopeFFT)
  {           
      if (fftBufferManager-&gt;HasNewAudioData())
      {
          if (fftBufferManager-&gt;ComputeFFT(l_fftData))
              [self setFFTData:l_fftData length:fftBufferManager-&gt;GetNumberFrames() / 2];
          else
              hasNewFFTData = NO;
      }
  
      if (hasNewFFTData)
      {
  
          int y, maxY;
          maxY = drawBufferLen;
          for (y=0; y&lt;maxY; y++)
          {
              CGFloat yFract = (CGFloat)y / (CGFloat)(maxY - 1);
              CGFloat fftIdx = yFract * ((CGFloat)fftLength);
  
              double fftIdx_i, fftIdx_f;
              fftIdx_f = modf(fftIdx, &amp;fftIdx_i);
  
              SInt8 fft_l, fft_r;
              CGFloat fft_l_fl, fft_r_fl;
              CGFloat interpVal;
  
              fft_l = (fftData[(int)fftIdx_i] &amp; 0xFF000000) &gt;&gt; 24;
              fft_r = (fftData[(int)fftIdx_i + 1] &amp; 0xFF000000) &gt;&gt; 24;
              fft_l_fl = (CGFloat)(fft_l + 80) / 64.;
              fft_r_fl = (CGFloat)(fft_r + 80) / 64.;
              interpVal = fft_l_fl * (1. - fftIdx_f) + fft_r_fl * fftIdx_f;
  
              interpVal = CLAMP(0., interpVal, 1.);
  
              drawBuffers[0][y] = (interpVal * 120);
  
          }
          cycleOscilloscopeLines();
  
      }
  
  }
  </code></pre>
  
  <p>From my understanding, this part of the code is what is used to decide which magnitude to draw for each frequency in the UI. My question is how can I determine what frequency each iteration (or <code>y</code> value) represents inside the <code>for</code> loop.</p>
  
  <p>For example, if I want to know what the magnitude is for 6kHz, I'm thinking of adding a line similar to the following:</p>
  
  <pre><code>if (yValueRepresentskHz(y, 6))
    NSLog(@"The magnitude for 6kHz is %f", (interpVal * 120));
  </code></pre>
  
  <p><em>Please note that although they chose to use the variable name <code>y</code>, from what I understand, it actually represents the x-axis in the visual graph of the spectrum analyzer, and the value of the <code>drawBuffers[0][y]</code> represents the y-axis.</em></p>