processing-sound-archive icon indicating copy to clipboard operation
processing-sound-archive copied to clipboard

add isPlaying() to sound library

Open wirsing opened this issue 11 years ago • 10 comments

(I'm adding some items that came up in an e-mail discussion re: the Processing sound library.)

Read more about the discussion here: processing/processing#2684

wirsing avatar Nov 12 '14 21:11 wirsing

@shiffman this was also for soundfiles, right?

wirsing avatar Nov 18 '14 01:11 wirsing

Yes, the idea is to be able to determine if a sound is already playing without having to have your own boolean. This comes up a lot when play() is called in, say, a draw() loop.

void draw() {
  if (!sound.isPlaying()) {
    sound.play();
  }
}

I'm not sure it's relevant for generated sound?

shiffman avatar Nov 18 '14 02:11 shiffman

will be added with the next release. .play() is not supposed to be called in the draw loop at any times but it might be a good idea to have it.

wirsing avatar Mar 05 '15 17:03 wirsing

If I may, it definitely a nice feature to have. It would also be worth implementing it in the Env class too.

b2renger avatar Mar 05 '15 23:03 b2renger

Would be nice to have this indeed.

kasperkamperman avatar Sep 04 '15 14:09 kasperkamperman

yes, i'll incorporate it. For now you can just set a variable to flag true or false to work around not having this.

wirsing avatar Sep 08 '15 21:09 wirsing

Would be great to have this

sunwangshu avatar Dec 09 '15 21:12 sunwangshu

indeed, +1 for this

dhowe avatar Apr 19 '16 16:04 dhowe

Has this been implemented as working yet ? I notice the method exists but a simple println on the value while a file plays once just leaves it as 1 and it doesnt change to 0 when the audio has finished

ashleyjamesbrown avatar Jan 25 '17 20:01 ashleyjamesbrown

@wirsing you said above:

.play() is not supposed to be called in the draw loop at any times but it might be a good idea to have it.

So, how would one, say, play a sound that isn't in setup or connected to a key press or mouse press? Like, say I wanted to play a sound when the mouse got to the edge of the sketch and not have it trigger on every cycle of draw?

I tried putting .play() in it's own function, which didn't work.

I've got a bunch of code written to check how long it's been since a file was triggered, if that's longer than the duration of the file, etc. But it just feels clunky.

Also @ashleyjamesbrown just tested with 1.3.2 and got the same results you did.

slambert avatar Mar 29 '17 14:03 slambert