Tree-Axis ``` Processing  


Back  
Class   FFT
   
Name  

averages()

   
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);
  
  // normalize the spectrum
  myFFT.limits();
  
  // we want 16 averages
  myFFT.averages(16);
  
  // 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<16; i++) {
    float temp=max(0,185-myFFT.averages[i]*512);
    rect(i*16,temp+.5,16,height-temp+.5);
  }
}

// we are done, clean up Ess

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


Description   Sets the number of averages of spectrum bins. Averages are processed by calling getSpectrum(), then accessing the field averages. The number of averages must be less than or equal to half the number of spectrum bins, though it is best if the number of averages divides cleanly into the number of bins. The default is 2
   
Syntax  
fft.averages(averages)
   
Parameters  
fft   any instance of FFT

averages   boolean: true if we want to use an envelope, false if not

   
Returns   nothing
   
Usage   Web & Application
   
 
 






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


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