> For the complete documentation index, see [llms.txt](https://learnpython.strivemath.com/p5-python-web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learnpython.strivemath.com/p5-python-web/reference/images-and-audio/loadsound.md).

# loadSound()

### Example

click the link below to play the sound.

{% file src="/files/KS6VwKSQKHZL6oEEM9kO" %}
Sound Effect by [UNIVERSFIELD](https://pixabay.com/users/universfield-28281460/?utm_source=link-attribution\&utm_medium=referral\&utm_campaign=music\&utm_content=121578) from [Pixabay](https://pixabay.com/sound-effects//?utm_source=link-attribution\&utm_medium=referral\&utm_campaign=music\&utm_content=121578)
{% endfile %}

```python
def setup():
    ...
    loadSound("/wow-121578.mp3",'WOW')

def draw():
    ...
    assets['WOW'].play()
```

### Syntax

```python
def setup():
    ...
    loadSound("sourceURL",'NAME')

def draw():
    ...
    assets['NAME'].play()
    ...
    assets['NAME'].stop()
```

| Input     | Description                                |
| --------- | ------------------------------------------ |
| sourceURL | web or local URL of **sound** to be loaded |
| NAME      | name for **variable** of sound in code     |

### Description

Loads a sound into memory from an external source so that it can be used in code. The **sourceURL** can be a web address (for example **"<http://wow-121578.mp3>"**) - this is the usual situation - or the local address if the file is stored with the rest of your code.&#x20;

Once a sound is loaded (in the example below, using the variable **'NAME'** in code), the following functions are available to call on the sound file:

| Function                      | Description                                                                                                                                                                                   |
| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| assets\['NAME'].play()        | starts playing the sound                                                                                                                                                                      |
| assets\['NAME'].stop()        | stops playing the sound and resets it                                                                                                                                                         |
| assets\['NAME'].pause()       | stops playing the sound and pauses it                                                                                                                                                         |
| assets\['NAME'].isPlaying()   | returns `True` or `False` depending on whether the sound is currently already playing                                                                                                         |
| assets\['NAME'].volume(**V**) | <p>adjusts the volume of the sound. <strong>V</strong> is a decimal value <strong>between 0 and 1</strong>. </p><p><strong>0</strong> is no volume, <strong>1</strong> is maximum volume </p> |

{% hint style="info" %}
Find these documents helpful? Let the people who made them help your child learn to code at [**Strivemath**](https://www.strivemath.com/)<mark style="color:blue;">**!**</mark>

We'd love to hear your Feedback/Comments [here](https://docs.google.com/forms/d/e/1FAIpQLSeqorBAGTya-YBRI-VFjJxtgQtCz3ucGDI96K96sNyuaGuvdw/viewform?usp=sf_link).
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://learnpython.strivemath.com/p5-python-web/reference/images-and-audio/loadsound.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
