We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSound,  Music Libraries › ess. too short playback
Page Index Toggle Pages: 1
ess. too short playback (Read 1029 times)
ess. too short playback
Mar 9th, 2006, 3:41pm
 
hello..
I want that my sample (kuku.wav) could play only while the cursor is over the middle of the stage.
But when the cursor is over the middle, it plays only few miliseconds instead of the full six seconds. Why it can't play the full sample?

import krister.Ess.*;

Channel myChannel;

void setup() {
 size(300,300);  
 Ess.start(this);
 myChannel=new Channel("kuku.wav");

}

void draw() {

if (mouseX > width/2) {
myChannel.play(Ess.FOREVER);
}else{
 myChannel.stop();
} }

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


Re: ess. too short playback
Reply #1 - Mar 9th, 2006, 4:13pm
 
What's happening is you're calling myChannel.play(Ess.FOREVER) every single fame that the mouse is over the specified area.

You can stop this from happening by adding a boolean value and only starting to play if it's not being played already.

Code:
 import krister.Ess.*;  

Channel myChannel;
boolean isPlaying;

void setup() {
size(300,300);
Ess.start(this);
myChannel=new Channel("kuku.wav");
isPlaying=false;
}

void draw() {
if (mouseX > width/2) {
if(!isPlaying) {
myChannel.play(Ess.FOREVER);
isPlaying=true;
}
}else{
myChannel.stop();
isPlaying=false;
}
}

public void stop() {
Ess.stop();
super.stop();
}
Page Index Toggle Pages: 1