あと、サンプルファイルはsetup()メソッドの中に一度だけ書いておくのではなく、毎回鳴らす度にnewしてあげる方がいい。特にone shotもの。ちょっと腑に落ちないけど。
import krister.Ess.*;
AudioChannel myChannel;
Envelope myEnvelope;
void setup() {
size(256,200);
// start up Ess
Ess.start(this);
}
void playSound(){
// load file into a new AudioChannel
myChannel=new AudioChannel("cell.aif");
// apply a 4 point envelope
EPoint[] env1 = new EPoint[4];
env1[0] = new EPoint(0,0);
env1[1] = new EPoint(1,1);
env1[2] = new EPoint(2,0);
env1[3] = new EPoint(3,0);
myEnvelope = new Envelope(env1);
myEnvelope.filter(myChannel);
// play
myChannel.play();
}
void draw() {
}
void mousePressed() {
playSound();
}
// we are done, clean up Ess
public void stop() {
Ess.stop();
super.stop();
}
0 件のコメント:
コメントを投稿