# How to add sound effects and music to a browser game

## Use the free built-in sounds or upload your own MP3, WAV, OGG or M4A files, then tell the AI when each one plays; Go Bananas evens out the loudness and handles phones.

Sound is half of how a game feels. A coin that chimes, a jump that whooshes and a hit that thuds tell players what happened without them reading anything. Music sets the mood and makes a short game feel finished. This guide covers the free sounds you can use right away, uploading your own, asking the AI to use them, the audio helper for developers, and how to make it all sound good on phones.

## Why sound matters in games

- **Feedback.** Every important action should make a sound: collecting, getting hit, scoring, losing a life. Players notice a missing sound more than a mediocre one.
- **Feel.** The same jump feels heavier or lighter depending on its sound. Short, punchy effects make controls feel responsive.
- **Information.** Sound can warn of things off screen: an enemy behind you, a timer about to run out.
- **Mood.** Music and background sound tell players whether the game is tense, silly or calm.

## Built-in sounds you can use for free

Go Bananas has a small pack of sound effects anyone can use in their games, released under CC0 (no permission or credit needed). Each one is at `https://gobananas.co/sfx/<name>.mp3`:

| Name | What it is |
| --- | --- |
| `gunshot` | A gunshot |
| `reload` | A weapon reloading |
| `hit` | An impact |
| `footstep` | A footstep |
| `pickup` | Picking something up |
| `menu_click` | A menu click |
| `zombie_moan` | A zombie groaning |
| `zombie_attack` | A zombie attacking |
| `zombie_death` | A zombie dying |
| `ambient_tension` | A tense background loop of about 10 seconds |

The AI doesn't know about this pack unless you tell it, so give it the address in your request:

> When the player picks up a key, play https://gobananas.co/sfx/pickup.mp3.

Always use the full address starting with `https://`. Games run in a sandbox where short addresses like `/sfx/pickup.mp3` don't load.

## Uploading your own sounds

You can upload sound effects, voice lines and music in [MP3](/formats/mp3), [WAV](/formats/wav), [OGG](/formats/ogg) or [M4A](/formats/m4a). Use the **Upload Asset** window, from the Assets tab or the editor. If you drop an audio file on the create panel, it opens that window for you. You need a verified account, and you tick a box to confirm you have the right to use the audio: your own work, licensed, or public domain.

| Limit | Value |
| --- | --- |
| File size | 5 MB per file |
| Length | 120 seconds per file |
| Audio storage | 50 MB per account |
| Embedded cover art and tags | 256 KB at most |

### What the site does to your audio

Every upload is processed the same way, whatever its format:

- **The loudness is evened out** to -16 LUFS, a standard level for games and streaming, so a quiet recording and a loud one end up at the same volume.
- **Silence at the start is trimmed,** so the sound plays the moment it's triggered. Silence at the end is kept.
- **It's converted to MP3** at 44.1 kHz. Clips of 5 seconds or less are treated as sound effects and saved in mono at 96 kbps; longer clips are treated as music and saved in stereo at 128 kbps.
- **Tags and cover art are removed.**
- **The original file isn't kept,** only the MP3.

You'll see a warning if the recording is clipping (distorted at its loudest points) or if its loudness was unusually low or high to start with. Clipping can't be fixed after the fact, so it's worth exporting a cleaner version.

### Trimming and volume

Each sound in your assets has a play button, a waveform and its length. You can trim a sound in the app to keep only part of it; the file isn't cut, and the game plays only the part you kept.

In the editor's Assets tab, **+ Attach to game** adds a sound to the game you're editing. Attached sounds get a volume slider from 0 to 100, starting at 100, so you can make the music quieter or a footstep softer without editing code. Changes are saved automatically.

## Asking the AI to use your sounds

Type **@** in the create or edit box and pick a sound. Its name is inserted in quotes, and you describe when it plays:

> Play "coin" when the player collects a star, and "boing" when they jump. Loop "forest-theme" as background music at low volume.

When you create a game, the AI is told about all your uploaded sounds. When you edit a game that has attached files, it's told about the attached sounds, so attach the ones you want it to use.

## For developers: the audio helper

Every Go Bananas game gets `window.__audio`, a small helper that works in the sandbox, unlocks sound on iPhones and follows the site's mute button. Use it instead of `new Audio()` or creating your own `AudioContext`.

```js
// The address of an uploaded sound comes from GAME_ASSETS (name = file name without extension).
const coinUrl = window.GAME_ASSETS.audio['coin'].url;
const musicUrl = window.GAME_ASSETS.audio['forest-theme'].url;
const jumpUrl = 'https://gobananas.co/sfx/pickup.mp3';   // a built-in sound

// Load sounds ahead of time so they play without delay.
Promise.all([__audio.load(coinUrl), __audio.load(jumpUrl)]);

// Start audio on the player's first tap or click (needed on iPhones).
startButton.addEventListener('click', () => {
  __audio.init();
  __audio.playMusic(musicUrl, { volume: 0.4, loop: true, fadeInMs: 1000 });
  startGame();
});

function onCoinCollected() {
  // Slightly different pitch each time keeps repeated sounds from feeling robotic.
  __audio.play(coinUrl, { volume: 0.8, rate: 0.95 + Math.random() * 0.1 });
}
```

The main methods:

- `init()`: call it from a tap or click. It unlocks audio on iPhones.
- `load(url)`: fetches and decodes a sound and returns a promise. Load before playing; a sound that isn't loaded yet plays only after it's decoded.
- `play(url, { volume, pan, rate })`: plays a sound effect. `pan` places it left or right, `rate` changes speed and pitch.
- `play3D(url, x, y, z, camera, { volume, maxDist, rate })`: plays a sound from a point in a 3D scene, quieter with distance.
- `playMusic(url, { volume, loop, fadeInMs })`: plays music. It loops by default, at volume 0.5, with a half-second fade-in.
- `stopAll()`, `setMasterVolume(v)` and `setMuted(true or false)`.

Always pass a full address. A sound's name or ID on its own doesn't work. The volume a sound plays at is your master volume, times the slider in the Assets tab, times the volume you pass in code.

## Sound on phones

- **Nothing plays until the player taps.** Phones, iPhones especially, block audio until the player touches the screen. A "Tap to start" screen that calls `__audio.init()` solves it.
- **The site's mute button works on every game.** Players can mute any game from the site's sound button, and the helper follows it, so don't build a game that depends on sound to be understood.
- **Keep files small.** Short effects and a compact music loop load faster on mobile data.

## Mixing tips

- **Keep music quieter than effects.** Music around 0.3 to 0.5 volume leaves room for the sounds that carry information.
- **Don't stack copies of one sound.** If twenty coins are collected at once, play the sound once or a few times, not twenty.
- **Add variation.** A small random change in `rate` makes repeated footsteps and hits sound natural.
- **Give each important event its own sound.** Players learn sounds quickly; reuse the same sound for different things and they lose that information.
- **Mind the length.** Sound effects work best under a second. Long tails cut into the next sound.
- **Loop cleanly.** Music meant to loop should start and end at the same point in the beat.

## Related

- [How to make a video game](/guides/how-to-make-a-video-game)
- [Game design basics](/guides/game-design-basics)
- [How to describe a game so the AI builds it](/guides/how-to-describe-a-game)
- [How to make a multiplayer browser game](/guides/multiplayer-games)
- [How to make a 3D browser game](/guides/3d-games)
- [Making games work on phones](/guides/games-on-phones)
- [Publishing and sharing your game](/guides/publish-and-share)
- [Using Go Bananas from ChatGPT or Claude](/guides/chatgpt-and-claude)
- File formats: [MP3](/formats/mp3), [WAV](/formats/wav), [OGG](/formats/ogg), [M4A](/formats/m4a), [all formats](/formats)
