User Tools

Site Tools


cs276:generatesine
// Example by Krister Olsson
// Modifications due to spc
 
import krister.Ess.*;
 
AudioChannel myChannel;
SineWave myWave;
 
void setup() {
  size(256,200);
 
  // start up Ess
  Ess.start(this);
 
  // create a new AudioChannel
  myChannel=new AudioChannel();
 
  // set the channel size to 6 seconds
  myChannel.initChannel(myChannel.frames(6000));
 
  // generate 3 seconds of a soft sine wave
  myWave=new SineWave(480, 0.1);
  myWave.generate(myChannel, 0, myChannel.frames(3000));
 
  // generate 2 more seconds of the sine wave
  // starting at offset 4 seconds into the audio stream
  myWave.generate(myChannel, myChannel.frames(4000), myChannel.frames(2000));
 
  // play
  myChannel.play();
}
 
void draw() {
}
 
// we are done, clean up Ess
 
public void stop() {
  Ess.stop();
  super.stop();
}
cs276/generatesine.txt · Last modified: 2010/11/03 16:12 by scarl