how to make a chirping noise every 5 minutes of the hour?

edited March 2016 in Library Questions

I used the minim sound library and I got a bird chirping noise to work. If I open my sketch at, for example, 8:34, and leave it open, at 8:35 the bird will chirp once then stop, which is great. that's what i want it to do. However, if I leave the sketch running, 5 minutes later, at 8:40, the bird will no longer chirp. It only seems to work once and I'm not sure why. Although you can't access my sound file, here is the code I used. if((int)minute == 0) {player.play(); } if((int)minute == 5) {player.play();} if((int)minute == 10) {player.play();} if((int)minute == 15) {player.play();} if((int)minute == 20) {player.play();} if((int)minute == 25) {player.play(); } if((int)minute == 30) {player.play(); } if((int)minute == 35) {player.play();} if((int)minute == 40) {player.play(); } if((int)minute == 45) {player.play(); } if((int)minute == 50) {player.play();} if((int)minute == 55) {player.play(); }

Why does it only work one time the sketch is open but not after that? How can I fix this?

Thanks in advance :)

}

Tagged:

Answers

  • Highlight code, press ctrl-o to format it.

    I think you need to rewind the sample before playing it again. But when you do you'll notice another problem...

    Also ((int)minute % 5 == 0) can replace all your individual tests

Sign In or Register to comment.