Tree-Axis ``` Processing  


Back  
Class   FFT
   
Name  

setupFFT()

   
Examples  
// Example by Krister Olsson

import krister.Ess.*;

AudioChannel myChannel;
FFT myFFT;

void setup() {
  size(256,200);

  // start up Ess
  Ess.start(this);

  // load "cell.aif" into a new AudioChannel
  myChannel=new AudioChannel("cell.aif");

  // we want 256 frequency bands
  myFFT=new FFT();
  myFFT.setupFFT(512);
  
  // start the sound looping forever
  myChannel.play(Ess.FOREVER);
  
  noStroke();
  fill(255);
}

void draw() {
  background(0,0,255);

  // get our spectrum
  myFFT.getSpectrum(myChannel);

  // draw our frequency bars
  for (int i=0; i<256; i++) {
    float temp=max(0,185-myFFT.spectrum[i]*512);
    rect(i,temp+.5,1,height-temp+.5);
  }
}

// we are done, clean up Ess

public void stop() {
  Ess.stop();
  super.stop();
}


Description   Sets the resolution of an FFT's spectrum analysis (the more bins, the greater the resolution). Spectrum data is processed by calling getSpectrum(), then accessing the field spectrum
   
Syntax  
fft.setupFFT(bins)
   
Parameters  
fft   any instance of FFT

bins   int: the number of frequency bins (the size of spectrum will always be half this number). Must be a power of 2

   
Returns   nothing
   
Usage   Web & Application
   
 
 






   
 
Updated: Tue May 31 04:52:42 PDT 2006


 
  Questions, comments, corrections: e-mail Krister Olsson.