# Sound playing every hour

**URL:** https://discourse.processing.org/t/sound-playing-every-hour/19497
**Category:** Libraries
**Created:** [April 7, 2020, 10:27am UTC](https://discourse.processing.org/t/sound-playing-every-hour/19497 "2020-04-07T10:27:53Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![F\_War](https://avatars.discourse-cdn.com/v4/letter/f/e480ec/32.png) [@F\_War](https://discourse.processing.org/u/F_War)
#### Post date: [April 7, 2020, 10:27am UTC](https://discourse.processing.org/t/sound-playing-every-hour/19497/1 "2020-04-07T10:27:53Z")

</div>

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 😉)  
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!

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [April 7, 2020, 11:35am UTC](https://discourse.processing.org/t/sound-playing-every-hour/19497/2 "2020-04-07T11:35:47Z")

</div>

for example here [https://www.processing.org/reference/libraries/sound/SoundFile\_play\_.html](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](https://www.processing.org/reference/hour_.html)

---

<div class="post-metadata">

### Author: ![F\_War](https://avatars.discourse-cdn.com/v4/letter/f/e480ec/32.png) [@F\_War](https://discourse.processing.org/u/F_War)
#### Post date: [April 7, 2020, 12:07pm UTC](https://discourse.processing.org/t/sound-playing-every-hour/19497/3 "2020-04-07T12:07:13Z")

</div>

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

---

<div class="post-metadata">

### Author: ![F\_War](https://avatars.discourse-cdn.com/v4/letter/f/e480ec/32.png) [@F\_War](https://discourse.processing.org/u/F_War)
#### Post date: [April 7, 2020, 1:38pm UTC](https://discourse.processing.org/t/sound-playing-every-hour/19497/4 "2020-04-07T13:38:42Z")

</div>

"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?

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [April 7, 2020, 2:32pm UTC](https://discourse.processing.org/t/sound-playing-every-hour/19497/5 "2020-04-07T14:32:41Z")

</div>

```auto

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
}
//

```
