Tree-Axis ``` Processing  


Back  
Class   AudioStream
   
Name  

fadeTo()

   
Examples  
// Example by Krister Olsson

import krister.Ess.*;

AudioStream myStream;
SineWave myWave;

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

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

  // create a new AudioStream
  myStream=new AudioStream();

  // our wave
  myWave=new SineWave(262,.33);
  
  // start
  myStream.start();
  
  // fade to silence over 5 seconds
  myStream.fadeTo(0,5000);
  print("Starting fade");
  
  // slow the framerate
  framerate(1);
}

void draw() {
  // are we fading?
  if (myStream.fading) print(".");
}

void audioOutputFade(AudioOutput ch) {
  print("done!");
}

void audioStreamWrite(AudioStream theStream) {
  // next wave
  myWave.generate(myStream);

  // adjust our phase
  myWave.phase+=myStream.size;
  myWave.phase%=myStream.sampleRate;
}

// we are done, clean up Ess

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


Description   Adjusts an AudioStream's volume over a period of milliseconds. Runs in its own thread so other code may be executed simultaneously
   
Syntax  
stream.fadeTo(volume, ms)
stream.fadeTo(volume, ms, type)
   
Parameters  
stream   any instance of AudioStream

volume   float: the target volume (between 0 and 1)

ms   int: the number of milliseconds over which to adjust the volume

type   the type of fade: Ess.LINEAR (the default), Ess.SLOW, or Ess.FAST

   
Returns   nothing
   
Usage   Web & Application
   
 
 






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


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