view doc/sound.md @ 18:5dc69898a091

balancing
author ark
date 2026-10-20 00:14 +0200
parents fe680946164b
children 85d23328a215
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    | |
| tower sold           | tower_sold        | |
| 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 www/data/sounds.js. see
  architecture.md for why

browsers only play sound after the first user interaction. the play button on
the splash screen starts the sound.

the sound button in the top bar switches sound on and off. the choice is
stored in the browser (architecture.md, persistence). until the player first
uses it, the enabled setting in [sound] applies.