# Can't play sound

**URL:** https://discourse.processing.org/t/cant-play-sound/13130
**Category:** Libraries
**Created:** [August 1, 2019, 7:37pm UTC](https://discourse.processing.org/t/cant-play-sound/13130 "2019-08-01T19:37:01Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![SheCurvesMobius](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/shecurvesmobius/32/7054_2.png) [@SheCurvesMobius](https://discourse.processing.org/u/SheCurvesMobius)
#### Post date: [August 1, 2019, 7:37pm UTC](https://discourse.processing.org/t/cant-play-sound/13130/1 "2019-08-01T19:37:01Z")

</div>

Hello,

I’m just learning to work with sound and I can’t get my sketch to work.

Here’s the code:

```auto
let mySound;

function preload() {
  soundFormats('mp3');
  mySound = loadSound('doorbell.mp3');
}

function setup() {
  mySound.setVolume(0.1);
  mySound.play();
}

```

I’m using [openprocessing.org](http://openprocessing.org) as my IDE. I’ve uploaded a file called doorbell.mp3. I get an error that says: “Uncaught ReferenceError: soundFormats is not defined”  
How do I define a function that p5 made, and not me?

---

<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: [August 1, 2019, 7:47pm UTC](https://discourse.processing.org/t/cant-play-sound/13130/2 "2019-08-01T19:47:25Z")

</div>

[http://p5js.org/reference/#/p5/soundFormats](http://p5js.org/reference/#/p5/soundFormats)

---

<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: [August 1, 2019, 7:48pm UTC](https://discourse.processing.org/t/cant-play-sound/13130/3 "2019-08-01T19:48:05Z")

</div>

This function requires you include the p5.sound library. Add the following into the head of your index.html file:

```auto
<script language="javascript"

type="text/javascript" 

src="path/to/p5.sound.js"></script>

```

Hm…

Not sure whether we want to have the sound file in the asset folder

---

<div class="post-metadata">

### Author: ![SheCurvesMobius](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/shecurvesmobius/32/7054_2.png) [@SheCurvesMobius](https://discourse.processing.org/u/SheCurvesMobius)
#### Post date: [August 3, 2019, 11:06am UTC](https://discourse.processing.org/t/cant-play-sound/13130/4 "2019-08-03T11:06:58Z")

</div>

Thanks for this!

For those who might read this thread later: if working in [openprocessing.org](http://openprocessing.org) under ‘settings’ you need to turn on the p5.sound library.

---

<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: [August 4, 2019, 12:08am UTC](https://discourse.processing.org/t/cant-play-sound/13130/5 "2019-08-04T00:08:41Z")

</div>

you mean

- [openprocessing.org](http://openprocessing.org)
- p5.js mode
- check revision ( now 0.9.0 )
- enable sound lib  
( here a photo )  
 ![openprocessing_orp_P5js_p5sound](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/2/2f973a534be34f38f9a97e6a72fd7284fc07e2ed.png)

---

<div class="post-metadata">

### Author: ![SheCurvesMobius](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/shecurvesmobius/32/7054_2.png) [@SheCurvesMobius](https://discourse.processing.org/u/SheCurvesMobius)
#### Post date: [August 4, 2019, 1:45pm UTC](https://discourse.processing.org/t/cant-play-sound/13130/6 "2019-08-04T13:45:05Z")

</div>

Yes, exactly. Thanks for adding more detail to my post 🙂
