wobblyhead hg > minor_monsters
view doc/sound.md @ 32:85d23328a215 0.10.0
added intro music, logic for browser audio triggering on splash screen
| author | ark |
|---|---|
| date | 2026-10-20 18:39 +0200 |
| parents | fe680946164b |
| children |
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 | | splash screen music | intro | recorded, loops while the splash screen shows | 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 script can drop the start of a recording up to a set time, and add a pause of silence after a sound that loops. intro loses its first 3 s, which hold a burp before the music, and gets 0.3 s of silence at the end - 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. on the first splash screen after loading, a sound button covers the play button. it pulses with a red glow, like an armed sell button. tapping it starts the sound and the intro music, and uncovers the play button. when sound was switched off in an earlier visit, there is no sound button: the play button shows at once and starts the sound as before, and there is no music. the intro loops until the play button is tapped, then fades out over the music_fade setting in [sound]. the splash screen that follows a won game plays the intro at once, as sound is already running. 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.
