# Sound triggered by buttons

**URL:** <https://discourse.processing.org/t/sound-triggered-by-buttons/16831>\
**Category:** Libraries\
**Created:** [January 3, 2020, 2:08pm UTC](https://discourse.processing.org/t/sound-triggered-by-buttons/16831 "2020-01-03T14:08:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![marianne91](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@marianne91](https://discourse.processing.org/u/marianne91)\
**Post date:** [January 3, 2020, 2:08pm UTC](https://discourse.processing.org/t/sound-triggered-by-buttons/16831/1 "2020-01-03T14:08:16Z")

</div>

Hi there,

Does anyone have an idea of how to trigger sounds with buttons on processing? I have found a tutorial for this for p5.js but can’t make it translate to processing…

Ultimately want to use buttons to trigger video clips but starting with sound first…

Thanks

---

<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:** [January 3, 2020, 2:40pm UTC](https://discourse.processing.org/t/sound-triggered-by-buttons/16831/2 "2020-01-03T14:40:13Z")

</div>

Website examples section, buttons

Then library sound: website libraries section

---

<div class="post-metadata">

**Author:** ![marianne91](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@marianne91](https://discourse.processing.org/u/marianne91)\
**Post date:** [January 3, 2020, 2:50pm UTC](https://discourse.processing.org/t/sound-triggered-by-buttons/16831/3 "2020-01-03T14:50:11Z")

</div>

Thanks @Chrisir.  
I’ve had a look and experiment with buttons and the sound library.  
So know how to make a button and play a sound seperately.  
But unsure how to combine them…  
Unsure which part of the code for playing a sound to put into the button sketch.  
Am getting errors every time I try and replace parts.  
(I am new to coding so still getting used to things…)  
Thanks,  
Marianne

---

<div class="post-metadata">

**Author:** ![marianne91](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@marianne91](https://discourse.processing.org/u/marianne91)\
**Post date:** [January 3, 2020, 3:46pm UTC](https://discourse.processing.org/t/sound-triggered-by-buttons/16831/4 "2020-01-03T15:46:54Z")

</div>

Ahh - I’ve got this now!  
Trying to now make buttons trigger video clips…

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [January 4, 2020, 1:59am UTC](https://discourse.processing.org/t/sound-triggered-by-buttons/16831/5 "2020-01-04T01:59:53Z")

</div>

> [@marianne91](#):
>
> make a button and play a sound

a not that easy example

> **[p5.js Web Editor](https://editor.p5js.org/kll/sketches/NIwFX54Gk)**
>
> A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, educators, and beginners.

as it combines BUTTON as class in a extra myTools.js file  
also contains other things you not need

---

<div class="post-metadata">

**Author:** ![marianne91](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@marianne91](https://discourse.processing.org/u/marianne91)\
**Post date:** [January 4, 2020, 11:26am UTC](https://discourse.processing.org/t/sound-triggered-by-buttons/16831/6 "2020-01-04T11:26:53Z")

</div>

Hi @kll  
Thanks for your reply.  
I’ve come across examples similar to this and have wanted to recreate one using a similar code but have had problems with p5js. When trying to load a sound file to the sketch the online editor comes up with the error that it does not accept sound files (e.g. mp3, .wav.) and then the downloadable version is no longer available. How do you get round this?  
Thanks,  
M

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [January 4, 2020, 11:30am UTC](https://discourse.processing.org/t/sound-triggered-by-buttons/16831/7 "2020-01-04T11:30:13Z")

</div>

ahm…  
p5.js online editor is free web space for learning and sharing

so they had to put in a file size limit, possibly you hit that.

* * *

when you look my example, there is a mp3 file i uploaded from PDE examples.  
after LOGIN you get the option to  
/ file / duplicate /  
my sketch…

---

<div class="post-metadata">

**Author:** ![marianne91](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@marianne91](https://discourse.processing.org/u/marianne91)\
**Post date:** [January 5, 2020, 1:38pm UTC](https://discourse.processing.org/t/sound-triggered-by-buttons/16831/8 "2020-01-05T13:38:14Z")

</div>

Perfect, will try this thank you!
