title: Fast Fourier Transform With Microphone Input Data in AS3
body: <p>Is it possible to get the source of adobes <code>flash.media.SoundMixer</code> class ?</p>
  
  <p>If it is, where can i find / get it ?</p>
  
  <p>I waht to "clone" the <code>.computeSpectrum()</code> function to transform a raw sound wave ( byteArray ) from Microphone input into a frequency spectrum.</p>
  
  <p>I've found a couple of examples like this one -> <a href="http://pierrickpluchon.fr/blog/as3-how-to-plug-your-microphone-with-a-soundspectrum-in-flash-player-10-1/" rel="nofollow">http://pierrickpluchon.fr/blog/as3-how-to-plug-your-microphone-with-a-soundspectrum-in-flash-player-10-1/</a></p>
  
  <p>All other methos i've found are pretty much the same.</p>
  
  <p>The problem is that there is always a <code>Sound()</code> playing, what i DON'T want. ( I don't want any loopback )</p>
  
  <p>But if i'm not playing a sound, i can't use the <code>SoundMixer.computeSpectrum()</code> function to transform my ByteArray that comes from the <code>Microphone</code> to a frequency spectrum by turning the FFTMode to true ( <code>computeSpectrum(myByteArray,true)</code> )</p>
  
  <p>Also if you know any other method to get the Frequency Spectrum from the Raw Sound Wave, please let me know.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>my code:</p>
  
  <pre><code>var bytes:ByteArray = new ByteArray();
  
  var mic:Microphone = Microphone.getMicrophone();
  mic.rate = 44;
  // mic.gain = 100; // gain
  mic.addEventListener(SampleDataEvent.SAMPLE_DATA, onSampleData);
  
  function onSampleData( event:SampleDataEvent ):void {
      graphics.clear();
      graphics.lineStyle(1, 0xFF0000);
      for( var i:uint = 0; i &lt; 256; i++ ) {
          var num:Number = event.data.readFloat() * 100 + 100; // -Math.abs( )
          if( i == 0 ) {
              graphics.moveTo( i, num );
          } else {
              graphics.lineTo( i, num );
          }
      }
  }
  </code></pre>