Tree-Axis ``` Processing  


Back  
Class   FFT
   
Name  

getSpectrum()

   
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, so we pass 512
  myFFT=new FFT(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   Calculates spectrum data based on the passed AudioChannel, AudioStream, AudioInput, or float array, and copies it into the buffer spectrum
   
Syntax  
fft.getSpectrum(src)
fft.getSpectrum(srcArray, offset) 
   
Parameters  
fft   any instance of FFT

src   the source AudioChannel, AudioStream, or AudioInput instance

srcArray   float[]: the source array containing sample data

offset   int: the sample frame from which to start analysis

   
Returns   nothing
   
Usage   Web & Application
   
 
 






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


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