Sound playing every hour

Hello!
I am still very new to this and I am working on a clock.
I would like the clock to play a sound every hour. (Like clocks do :wink:)
I can load the sound into the file but then I am not sure how to tackle it.
Does anyone know any examples that I could look at?
Thank you!

for example here https://www.processing.org/reference/libraries/sound/SoundFile_play_.html

to check the hour use hour() maybe you can store the previousHour throughout and when they are different play sound (to avoid that it gets played multiple times)

see https://www.processing.org/reference/hour_.html

1 Like

Hey!,
Yes I saw these two but I am not sure how I can combine these.

"import processing.sound.*;
int m = minute();
SoundFile bang;

void setup() {
size(640, 360);
background(255);
bang = new SoundFile(this, β€œbang.wav”);

}

void draw() {

if(m == 00){
bang.play(); }
noLoop();
}
"

This is how far I got. The problem is that I would like to run it every time the minute is 0, so every hour. for now it only runs once on the minute I run it. How do I run the program in a loop?


import processing.sound.*;

SoundFile bang;

int mPrev; 

void setup() {
  size(640, 360);
  background(255);
  bang = new SoundFile(this, "bang.wav");
  mPrev=minute();
}

void draw() {
  if (minute() != mPrev) {
    bang.play();
    mPrev=minute();
  }//if
}
//
1 Like