view doc/sound.md @ 4:2d46729a022e

sound processing and in-game sounds
author ark
date 2026-10-18 20:58 +0200
parents 7af9dd4e2595
children 910b26feca76
line wrap: on
line source

sound
-----

events with a voice recording play the recording. the others play
placeholder beeps, generated in the browser (web audio oscillator, a few notes
each), until a recording arrives.


events
------

the event name is the name of its recordings and its entry in [sound.event]
in config/game.toml.

| event                | name              | notes |
|----------------------|-------------------|-------|
| t0 attack            | t0_attack         | recorded, 4 variants |
| t1 shot              | t1_shot           | recorded, 6 variants |
| t2 shot              | t2_shot           | recorded, 4 variants |
| t3 shot              | t3_shot           | recorded, 7 variants |
| monster hit          | monster_hit       | frequent; keep short or play only some of them |
| monster enters map   | monster_enter     | recorded, 3 variants. every monster for now; to playtest |
| monster dies         | monster_die       | recorded, 4 variants |
| monster reaches exit | monster_exit      | recorded. a heart is lost |
| boss appears         | boss_enter        | recorded |
| boss reaches exit    | boss_exit         | recorded |
| boss dies            | boss_die          | recorded |
| coins arrive         | coins_arrive      | at most one per short interval |
| wave starts          | wave_start        | |
| early start bonus    | early_bonus       | |
| tower built          | tower_built       | |
| tower upgraded       | tower_upgraded    | not in the game yet |
| tower sold           | tower_sold        | not in the game yet |
| placement refused    | placement_refused | no legal spot within reach |
| button tap           | button_tap        | |
| map won              | map_won           | recorded |
| map lost             | map_lost          | recorded |

several recordings per event are allowed; the game picks one at random.

the map won sound waits until a boss or monster death sound still playing has
ended, and map lost waits for the last exit sound. the boss wave may not stay
the end of a map, so boss_die and map_won are separate sounds.

per event, the config sets a volume, an optional least time between two
plays (plays in between are dropped) and the placeholder beep.


recordings
----------

- recorded on any device, supplied in any common format
- art/sound_sources/ holds the recordings as supplied, named after the event.
  a recording may hold several variants with pauses between them
- tools/cut_sounds.py turns them into game sounds in art/sounds/. it is run
  by hand after a recording changes, not by the build, because it needs
  ffmpeg. it lists the number of variants per recording and splits those
  recordings at their longest pauses, into NAME_1, NAME_2 and so on. it
  trims silence, filters low rumble, fades the ends and brings every sound to
  the same peak level. the output is mono mp3, which desktop browsers and
  tablets (including safari) play
- the build embeds art/sounds/ as base64 in game/data/sounds.js. see
  architecture.md for why

browsers only play sound after the first user interaction. for now that is
the first tap anywhere on the game; later the first tap on the title screen.

sound can be switched off; the setting is stored with the other settings. for
now the switch is the enabled setting in [sound]; the game has no button for
it yet.