> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rebind.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# rb.audio

> Play sound files and a short tone.

`rb.audio` plays sound files and a short tone. A script reaches for it to
signal that something happened, such as a beep when a toggle turns on, or to
play an alert or a loop of music while it works.

This script halves the master volume and beeps, then plays `music.ogg` from
its folder on a loop for ten seconds and stops it:

```luau theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
-- rebind: min_sdk=3.9.0 name=example version=1.0.0
rb.audio.set_master_volume(0.5)
rb.audio.beep()

rb.run(function()
  rb.audio.play("music.ogg", { volume = 0.8, loop = true })
  rb.sleep(10000)
  rb.audio.stop_all()
end)
```

| Signature | Effect |
| - | - |
| `rb.audio.beep() -> ()` | a short tone on the default output |
| `rb.audio.play(path: string, options: PlayOptions?) -> SoundHandle` | plays a WAV, MP3, Ogg Vorbis or FLAC file without waiting |
| `rb.audio.stop_all() -> ()` | stops every sound of the script |
| `rb.audio.set_master_volume(vol: number) -> ()` | 0 to 1, for sounds started afterward |
| `rb.audio.get_master_volume() -> number` | |

`options` is `{ volume = 0..1 (default 1), loop = false }`. A sound starts at
its `volume` times the master volume. Paths follow the
[`rb.file`](https://docs.rebind.gg/reference/sdk/file) rules. A file that cannot be opened or decoded
raises. Sounds stop when the script stops. The
[SoundHandle](https://docs.rebind.gg/reference/sdk/handles.md) controls one sound.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.