comparison doc/sound.md @ 4:2d46729a022e

sound processing and in-game sounds
author ark
date 2026-10-18 20:58 +0200
parents 7af9dd4e2595
children 910b26feca76
comparison
equal deleted inserted replaced
3:cc0c32e71090 4:2d46729a022e
1 sound 1 sound
2 ----- 2 -----
3 3
4 the first version uses placeholder beeps, generated in the browser (web audio 4 events with a voice recording play the recording. the others play
5 oscillator, a few notes each). voice recordings replace them later, one event 5 placeholder beeps, generated in the browser (web audio oscillator, a few notes
6 at a time. 6 each), until a recording arrives.
7 7
8 8
9 events 9 events
10 ------ 10 ------
11 11
12 | event | notes | 12 the event name is the name of its recordings and its entry in [sound.event]
13 |----------------------|-------| 13 in config/game.toml.
14 | t0 attack | | 14
15 | t1 shot | | 15 | event | name | notes |
16 | t2 shot | | 16 |----------------------|-------------------|-------|
17 | t3 shot | | 17 | t0 attack | t0_attack | recorded, 4 variants |
18 | monster hit | frequent; keep short or play only some of them | 18 | t1 shot | t1_shot | recorded, 6 variants |
19 | monster dies | | 19 | t2 shot | t2_shot | recorded, 4 variants |
20 | boss appears | | 20 | t3 shot | t3_shot | recorded, 7 variants |
21 | boss dies | | 21 | monster hit | monster_hit | frequent; keep short or play only some of them |
22 | coins arrive | at most one per short interval | 22 | monster enters map | monster_enter | recorded, 3 variants. every monster for now; to playtest |
23 | monster reaches exit | a heart is lost | 23 | monster dies | monster_die | recorded, 4 variants |
24 | wave starts | | 24 | monster reaches exit | monster_exit | recorded. a heart is lost |
25 | early start bonus | | 25 | boss appears | boss_enter | recorded |
26 | tower built | | 26 | boss reaches exit | boss_exit | recorded |
27 | tower upgraded | | 27 | boss dies | boss_die | recorded |
28 | tower sold | | 28 | coins arrive | coins_arrive | at most one per short interval |
29 | placement refused | no legal spot within reach | 29 | wave starts | wave_start | |
30 | button tap | | 30 | early start bonus | early_bonus | |
31 | map won | | 31 | tower built | tower_built | |
32 | map lost | | 32 | tower upgraded | tower_upgraded | not in the game yet |
33 | tower sold | tower_sold | not in the game yet |
34 | placement refused | placement_refused | no legal spot within reach |
35 | button tap | button_tap | |
36 | map won | map_won | recorded |
37 | map lost | map_lost | recorded |
33 38
34 several recordings per event are allowed; the game picks one at random. 39 several recordings per event are allowed; the game picks one at random.
40
41 the map won sound waits until a boss or monster death sound still playing has
42 ended, and map lost waits for the last exit sound. the boss wave may not stay
43 the end of a map, so boss_die and map_won are separate sounds.
44
45 per event, the config sets a volume, an optional least time between two
46 plays (plays in between are dropped) and the placeholder beep.
35 47
36 48
37 recordings 49 recordings
38 ---------- 50 ----------
39 51
40 - recorded on any device, supplied in any common format 52 - recorded on any device, supplied in any common format
41 - the build trims silence, evens out volume, converts to one format that 53 - art/sound_sources/ holds the recordings as supplied, named after the event.
42 desktop browsers and tablets (including safari) play, and embeds the result 54 a recording may hold several variants with pauses between them
43 as base64 in a javascript file. see architecture.md for why 55 - tools/cut_sounds.py turns them into game sounds in art/sounds/. it is run
44 - named after the event, with a number for variants 56 by hand after a recording changes, not by the build, because it needs
57 ffmpeg. it lists the number of variants per recording and splits those
58 recordings at their longest pauses, into NAME_1, NAME_2 and so on. it
59 trims silence, filters low rumble, fades the ends and brings every sound to
60 the same peak level. the output is mono mp3, which desktop browsers and
61 tablets (including safari) play
62 - the build embeds art/sounds/ as base64 in game/data/sounds.js. see
63 architecture.md for why
45 64
46 browsers only play sound after the first user interaction. the first tap on 65 browsers only play sound after the first user interaction. for now that is
47 the title screen unlocks audio. 66 the first tap anywhere on the game; later the first tap on the title screen.
48 67
49 sound can be switched off; the setting is stored with the other settings. 68 sound can be switched off; the setting is stored with the other settings. for
69 now the switch is the enabled setting in [sound]; the game has no button for
70 it yet.