diff --git a/.gitattributes b/.gitattributes index 8323191..33708b2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -19,6 +19,10 @@ *.hdr filter=lfs diff=lfs merge=lfs -text *.pck filter=lfs diff=lfs merge=lfs -text +# The generated audio is small (every file under 1 MB, held there by +# tools/check_binaries.sh) and the Gitea server has no LFS, so it stays in plain git. +assets/audio/*.wav -filter -diff -merge binary + # Small images stay in plain git, as binary. *.png binary *.jpg binary diff --git a/CLAUDE.md b/CLAUDE.md index 29182c1..df86188 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -45,6 +45,8 @@ continuity. | `make soak` | The 24-client network soak (N8): a real server and 24 headless `SoakPlayer` clients in three processes, each behind a `UdpRelay` adding 60 ms, +/-20 ms jitter and 2% loss each way, for two whole matches in real time (about 30 min, under `nice`). Fails on a world-hash mismatch, errors, unreadable packets, a client that didn't play every match, memory growth between matches, or a p99 tick over budget. `SOAK_MATCHES`, `SOAK_CLIENTS`, `SOAK_PROCS`, `SOAK_LATENCY`, `SOAK_JITTER`, `SOAK_LOSS` scale it. Results in `build/soak/report.txt`. | | `make soak-selfcheck` | About a minute: tampers with one client's world and checks the soak's comparison catches it and only it. | | `make server-package-check` | Builds the server image with `packaging/docker/compose.yaml`, waits for it to be healthy, checks it is non-root and read-only, joins it with a headless client and stops it with SIGTERM (N7, about 1.5 min). Needs Docker. See `packaging/README.md`. | +| `make audio` | Regenerates every sound and the score's layers in `assets/audio/` from `tools/audio/` (about 6 s), with `manifest.json`. Commit the WAVs it changes. | +| `make audio-check` | Checks each file in `assets/audio/` matches its manifest hash and its loudness target, and the mix order (tide loudest). Also run by `test_audio_assets`, which regenerates everything and compares. | | `make capture-test` | Proves the capture harness works and rejects a blank frame. Needs Docker, so it isn't part of `make check`. | Run one group of tests with `tools/run_tests.sh --root=res://test/sim` or diff --git a/Makefile b/Makefile index e3f7f03..884830a 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,15 @@ # Tidewall build entry points. Everything runs headless with the repo-local engine. GODOT := tools/godot.sh -.PHONY: check import parse test test-selfcheck smoke capture-test terrain-capture binaries verify-engine bot-matches match match-captures client-check client-captures hud-captures style-captures menu-captures chart-captures discovery-check fuzz soak soak-selfcheck server-package-check +.PHONY: audio audio-check check import parse test test-selfcheck smoke capture-test terrain-capture binaries verify-engine bot-matches match match-captures client-check client-captures hud-captures style-captures menu-captures chart-captures discovery-check fuzz soak soak-selfcheck server-package-check + +## A8: regenerates every sound in assets/audio/ from tools/audio/ (about 6 s). +audio: import + @$(GODOT) --script res://tools/audio/generate.gd + +## A8: checks the generated audio's hashes and loudness against the rules. +audio-check: import + @$(GODOT) --script res://tools/audio/check.gd ## Everything that must pass before a push. check: verify-engine binaries parse test test-selfcheck smoke diff --git a/assets/PROVENANCE.md b/assets/PROVENANCE.md new file mode 100644 index 0000000..58100f3 --- /dev/null +++ b/assets/PROVENANCE.md @@ -0,0 +1,22 @@ +# Asset provenance + +Every file under `assets/` is made by a script in this repository. Nothing here is +sampled, recorded, downloaded or taken from a third party. Colours, shaders and +meshes built in code are recorded by being in the repository and aren't listed here. + +## Audio (`assets/audio/`, A8) + +| Files | Generator | How | +|---|---|---| +| `step_*`, `land`, `swing_*`, `shot_*`, `keg_blast`, `reload`, `hit_*`, `chop`, `build_*`, `break_*`, `splash`, `swim`, `surge`, `bell`, `foghorn`, `lighthouse`, `hurt`, `pickup`, `chest_open`, `eliminated`, `amb_*`, `ui_*` | `tools/audio/recipes.gd` | Synthesized from seeded noise, wavetable oscillators, filters and decaying modes (`tools/audio/dsp.gd`). | +| `music_drone`, `music_drum`, `music_concertina`, `music_fiddle` | `tools/audio/score.gd` | An original eight-bar tune and chord sequence in D Dorian, written for Tidewall as the note lists in the script, rendered with the same synthesis. It follows no existing song. | +| `manifest.json` | `tools/audio/generate.gd` | Each file's category, length, SHA-256, peak and loudness. | + +Regenerate everything with: + + tools/godot.sh --script res://tools/audio/generate.gd + +and check it with `tools/godot.sh --script res://tools/audio/check.gd` (part of +`make check` through `test/audio/test_audio_assets.gd`, which also regenerates every +file and compares hashes). Files are mono 16-bit PCM at 22,050 Hz. Licence: see +`LICENSE-ASSETS`. diff --git a/assets/audio/amb_rain.wav b/assets/audio/amb_rain.wav new file mode 100644 index 0000000..636925f Binary files /dev/null and b/assets/audio/amb_rain.wav differ diff --git a/assets/audio/amb_rain.wav.import b/assets/audio/amb_rain.wav.import new file mode 100644 index 0000000..a058b0d --- /dev/null +++ b/assets/audio/amb_rain.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://8g3iopq0hhj2" +path="res://.godot/imported/amb_rain.wav-5995007a2efdd9b9ddd6d4f114e56a6d.sample" + +[deps] + +source_file="res://assets/audio/amb_rain.wav" +dest_files=["res://.godot/imported/amb_rain.wav-5995007a2efdd9b9ddd6d4f114e56a6d.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/amb_surf.wav b/assets/audio/amb_surf.wav new file mode 100644 index 0000000..3304f49 Binary files /dev/null and b/assets/audio/amb_surf.wav differ diff --git a/assets/audio/amb_surf.wav.import b/assets/audio/amb_surf.wav.import new file mode 100644 index 0000000..f95d19a --- /dev/null +++ b/assets/audio/amb_surf.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://4v0if64fua5j" +path="res://.godot/imported/amb_surf.wav-312af5e29c01dc927a416ac2a9a10b83.sample" + +[deps] + +source_file="res://assets/audio/amb_surf.wav" +dest_files=["res://.godot/imported/amb_surf.wav-312af5e29c01dc927a416ac2a9a10b83.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/amb_wind.wav b/assets/audio/amb_wind.wav new file mode 100644 index 0000000..2f6134d Binary files /dev/null and b/assets/audio/amb_wind.wav differ diff --git a/assets/audio/amb_wind.wav.import b/assets/audio/amb_wind.wav.import new file mode 100644 index 0000000..1409c97 --- /dev/null +++ b/assets/audio/amb_wind.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://bpl0ug3ivs3t2" +path="res://.godot/imported/amb_wind.wav-cf0d90716ccece9021e2c59418b8beaa.sample" + +[deps] + +source_file="res://assets/audio/amb_wind.wav" +dest_files=["res://.godot/imported/amb_wind.wav-cf0d90716ccece9021e2c59418b8beaa.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/bell.wav b/assets/audio/bell.wav new file mode 100644 index 0000000..52939d9 Binary files /dev/null and b/assets/audio/bell.wav differ diff --git a/assets/audio/bell.wav.import b/assets/audio/bell.wav.import new file mode 100644 index 0000000..17a6e80 --- /dev/null +++ b/assets/audio/bell.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://cmjkjibrfbseu" +path="res://.godot/imported/bell.wav-c9e8b15c72938ff0cc4247d900f73a2f.sample" + +[deps] + +source_file="res://assets/audio/bell.wav" +dest_files=["res://.godot/imported/bell.wav-c9e8b15c72938ff0cc4247d900f73a2f.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/break_driftwood.wav b/assets/audio/break_driftwood.wav new file mode 100644 index 0000000..3ade1f3 Binary files /dev/null and b/assets/audio/break_driftwood.wav differ diff --git a/assets/audio/break_driftwood.wav.import b/assets/audio/break_driftwood.wav.import new file mode 100644 index 0000000..9008b25 --- /dev/null +++ b/assets/audio/break_driftwood.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://bjv77jft4gf3t" +path="res://.godot/imported/break_driftwood.wav-81046fb6f11d6430fe78c79fa17a6ba4.sample" + +[deps] + +source_file="res://assets/audio/break_driftwood.wav" +dest_files=["res://.godot/imported/break_driftwood.wav-81046fb6f11d6430fe78c79fa17a6ba4.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/break_salvage_iron.wav b/assets/audio/break_salvage_iron.wav new file mode 100644 index 0000000..3e5b035 Binary files /dev/null and b/assets/audio/break_salvage_iron.wav differ diff --git a/assets/audio/break_salvage_iron.wav.import b/assets/audio/break_salvage_iron.wav.import new file mode 100644 index 0000000..2e651ba --- /dev/null +++ b/assets/audio/break_salvage_iron.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://bqj711kyaa7ig" +path="res://.godot/imported/break_salvage_iron.wav-f906b13fd2514ff7571596e42829fa8b.sample" + +[deps] + +source_file="res://assets/audio/break_salvage_iron.wav" +dest_files=["res://.godot/imported/break_salvage_iron.wav-f906b13fd2514ff7571596e42829fa8b.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/break_stone.wav b/assets/audio/break_stone.wav new file mode 100644 index 0000000..8d8a179 Binary files /dev/null and b/assets/audio/break_stone.wav differ diff --git a/assets/audio/break_stone.wav.import b/assets/audio/break_stone.wav.import new file mode 100644 index 0000000..e1d0ce3 --- /dev/null +++ b/assets/audio/break_stone.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://d221tjdqnyl35" +path="res://.godot/imported/break_stone.wav-bcecdbd6d5fdb36a9ed60047d80ebe73.sample" + +[deps] + +source_file="res://assets/audio/break_stone.wav" +dest_files=["res://.godot/imported/break_stone.wav-bcecdbd6d5fdb36a9ed60047d80ebe73.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/build_driftwood.wav b/assets/audio/build_driftwood.wav new file mode 100644 index 0000000..c4ba646 Binary files /dev/null and b/assets/audio/build_driftwood.wav differ diff --git a/assets/audio/build_driftwood.wav.import b/assets/audio/build_driftwood.wav.import new file mode 100644 index 0000000..b2247dc --- /dev/null +++ b/assets/audio/build_driftwood.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://4rqpojyk4fym" +path="res://.godot/imported/build_driftwood.wav-e4835c74eb4d3ae3c41a759018620b99.sample" + +[deps] + +source_file="res://assets/audio/build_driftwood.wav" +dest_files=["res://.godot/imported/build_driftwood.wav-e4835c74eb4d3ae3c41a759018620b99.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/build_salvage_iron.wav b/assets/audio/build_salvage_iron.wav new file mode 100644 index 0000000..0884fc9 Binary files /dev/null and b/assets/audio/build_salvage_iron.wav differ diff --git a/assets/audio/build_salvage_iron.wav.import b/assets/audio/build_salvage_iron.wav.import new file mode 100644 index 0000000..c159081 --- /dev/null +++ b/assets/audio/build_salvage_iron.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://c8ys3lrrq85s5" +path="res://.godot/imported/build_salvage_iron.wav-1e76e0e17491fdc0aa4bf23812d51bba.sample" + +[deps] + +source_file="res://assets/audio/build_salvage_iron.wav" +dest_files=["res://.godot/imported/build_salvage_iron.wav-1e76e0e17491fdc0aa4bf23812d51bba.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/build_stone.wav b/assets/audio/build_stone.wav new file mode 100644 index 0000000..cc71630 Binary files /dev/null and b/assets/audio/build_stone.wav differ diff --git a/assets/audio/build_stone.wav.import b/assets/audio/build_stone.wav.import new file mode 100644 index 0000000..568cd4d --- /dev/null +++ b/assets/audio/build_stone.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://7ps7y5hfwk7c" +path="res://.godot/imported/build_stone.wav-3e7b02511cd8e2be25f69dd560ca27e8.sample" + +[deps] + +source_file="res://assets/audio/build_stone.wav" +dest_files=["res://.godot/imported/build_stone.wav-3e7b02511cd8e2be25f69dd560ca27e8.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/chest_open.wav b/assets/audio/chest_open.wav new file mode 100644 index 0000000..0875e20 Binary files /dev/null and b/assets/audio/chest_open.wav differ diff --git a/assets/audio/chest_open.wav.import b/assets/audio/chest_open.wav.import new file mode 100644 index 0000000..657f972 --- /dev/null +++ b/assets/audio/chest_open.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://dax815h7yoaiw" +path="res://.godot/imported/chest_open.wav-bc9a383f1cff61eaa27508e8925b8370.sample" + +[deps] + +source_file="res://assets/audio/chest_open.wav" +dest_files=["res://.godot/imported/chest_open.wav-bc9a383f1cff61eaa27508e8925b8370.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/chop.wav b/assets/audio/chop.wav new file mode 100644 index 0000000..05877d5 Binary files /dev/null and b/assets/audio/chop.wav differ diff --git a/assets/audio/chop.wav.import b/assets/audio/chop.wav.import new file mode 100644 index 0000000..b06dcdf --- /dev/null +++ b/assets/audio/chop.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://dv2bu806b60ub" +path="res://.godot/imported/chop.wav-c1c773baa0a920553448a92ec0ca243d.sample" + +[deps] + +source_file="res://assets/audio/chop.wav" +dest_files=["res://.godot/imported/chop.wav-c1c773baa0a920553448a92ec0ca243d.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/eliminated.wav b/assets/audio/eliminated.wav new file mode 100644 index 0000000..02f8745 Binary files /dev/null and b/assets/audio/eliminated.wav differ diff --git a/assets/audio/eliminated.wav.import b/assets/audio/eliminated.wav.import new file mode 100644 index 0000000..8524642 --- /dev/null +++ b/assets/audio/eliminated.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://dhehl3mx2hhf3" +path="res://.godot/imported/eliminated.wav-f5c77fe3dfcd57be09de9a863c6f645d.sample" + +[deps] + +source_file="res://assets/audio/eliminated.wav" +dest_files=["res://.godot/imported/eliminated.wav-f5c77fe3dfcd57be09de9a863c6f645d.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/foghorn.wav b/assets/audio/foghorn.wav new file mode 100644 index 0000000..06f210a Binary files /dev/null and b/assets/audio/foghorn.wav differ diff --git a/assets/audio/foghorn.wav.import b/assets/audio/foghorn.wav.import new file mode 100644 index 0000000..a679662 --- /dev/null +++ b/assets/audio/foghorn.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://bwo7tywbtqtsg" +path="res://.godot/imported/foghorn.wav-75b17e364e2ead4da591db0219c9d1a5.sample" + +[deps] + +source_file="res://assets/audio/foghorn.wav" +dest_files=["res://.godot/imported/foghorn.wav-75b17e364e2ead4da591db0219c9d1a5.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/hit_ground.wav b/assets/audio/hit_ground.wav new file mode 100644 index 0000000..94addd3 Binary files /dev/null and b/assets/audio/hit_ground.wav differ diff --git a/assets/audio/hit_ground.wav.import b/assets/audio/hit_ground.wav.import new file mode 100644 index 0000000..3518bbc --- /dev/null +++ b/assets/audio/hit_ground.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://bukxpys48lpwv" +path="res://.godot/imported/hit_ground.wav-b874b586a9e529a561bd4b5ca751c5d2.sample" + +[deps] + +source_file="res://assets/audio/hit_ground.wav" +dest_files=["res://.godot/imported/hit_ground.wav-b874b586a9e529a561bd4b5ca751c5d2.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/hit_iron.wav b/assets/audio/hit_iron.wav new file mode 100644 index 0000000..a7ec748 Binary files /dev/null and b/assets/audio/hit_iron.wav differ diff --git a/assets/audio/hit_iron.wav.import b/assets/audio/hit_iron.wav.import new file mode 100644 index 0000000..e7a2a6f --- /dev/null +++ b/assets/audio/hit_iron.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://bkdqms53gm325" +path="res://.godot/imported/hit_iron.wav-40c8deac56deb44b30380c27662168a4.sample" + +[deps] + +source_file="res://assets/audio/hit_iron.wav" +dest_files=["res://.godot/imported/hit_iron.wav-40c8deac56deb44b30380c27662168a4.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/hit_player.wav b/assets/audio/hit_player.wav new file mode 100644 index 0000000..ae69e61 Binary files /dev/null and b/assets/audio/hit_player.wav differ diff --git a/assets/audio/hit_player.wav.import b/assets/audio/hit_player.wav.import new file mode 100644 index 0000000..ef24f51 --- /dev/null +++ b/assets/audio/hit_player.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://bmskvseengqeh" +path="res://.godot/imported/hit_player.wav-b723706a5da0fc8929a4aecb7a48b710.sample" + +[deps] + +source_file="res://assets/audio/hit_player.wav" +dest_files=["res://.godot/imported/hit_player.wav-b723706a5da0fc8929a4aecb7a48b710.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/hit_stone.wav b/assets/audio/hit_stone.wav new file mode 100644 index 0000000..f04e7a4 Binary files /dev/null and b/assets/audio/hit_stone.wav differ diff --git a/assets/audio/hit_stone.wav.import b/assets/audio/hit_stone.wav.import new file mode 100644 index 0000000..4928a54 --- /dev/null +++ b/assets/audio/hit_stone.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://cfgfo65aoum4s" +path="res://.godot/imported/hit_stone.wav-353d8b46d67b3828bd7e66044dd3bbf2.sample" + +[deps] + +source_file="res://assets/audio/hit_stone.wav" +dest_files=["res://.godot/imported/hit_stone.wav-353d8b46d67b3828bd7e66044dd3bbf2.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/hit_wood.wav b/assets/audio/hit_wood.wav new file mode 100644 index 0000000..071ec0d Binary files /dev/null and b/assets/audio/hit_wood.wav differ diff --git a/assets/audio/hit_wood.wav.import b/assets/audio/hit_wood.wav.import new file mode 100644 index 0000000..957b832 --- /dev/null +++ b/assets/audio/hit_wood.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://sh2l7w11lkxf" +path="res://.godot/imported/hit_wood.wav-3750ad9661fb64c8ca9a62d7a96a4aca.sample" + +[deps] + +source_file="res://assets/audio/hit_wood.wav" +dest_files=["res://.godot/imported/hit_wood.wav-3750ad9661fb64c8ca9a62d7a96a4aca.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/hurt.wav b/assets/audio/hurt.wav new file mode 100644 index 0000000..3c0122c Binary files /dev/null and b/assets/audio/hurt.wav differ diff --git a/assets/audio/hurt.wav.import b/assets/audio/hurt.wav.import new file mode 100644 index 0000000..79262dc --- /dev/null +++ b/assets/audio/hurt.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://cvtef0jy5v1cp" +path="res://.godot/imported/hurt.wav-e638edfaf88190ba3ffee0adc26b7375.sample" + +[deps] + +source_file="res://assets/audio/hurt.wav" +dest_files=["res://.godot/imported/hurt.wav-e638edfaf88190ba3ffee0adc26b7375.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/keg_blast.wav b/assets/audio/keg_blast.wav new file mode 100644 index 0000000..619f2c9 Binary files /dev/null and b/assets/audio/keg_blast.wav differ diff --git a/assets/audio/keg_blast.wav.import b/assets/audio/keg_blast.wav.import new file mode 100644 index 0000000..076641f --- /dev/null +++ b/assets/audio/keg_blast.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://6aw1j2tnssda" +path="res://.godot/imported/keg_blast.wav-a4707dcd55a6c7dbbf3a2b429603a348.sample" + +[deps] + +source_file="res://assets/audio/keg_blast.wav" +dest_files=["res://.godot/imported/keg_blast.wav-a4707dcd55a6c7dbbf3a2b429603a348.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/land.wav b/assets/audio/land.wav new file mode 100644 index 0000000..12e738f Binary files /dev/null and b/assets/audio/land.wav differ diff --git a/assets/audio/land.wav.import b/assets/audio/land.wav.import new file mode 100644 index 0000000..009e072 --- /dev/null +++ b/assets/audio/land.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://6gdltf2u1mgf" +path="res://.godot/imported/land.wav-baef3c9f2a47922b496a826b5b8d32ac.sample" + +[deps] + +source_file="res://assets/audio/land.wav" +dest_files=["res://.godot/imported/land.wav-baef3c9f2a47922b496a826b5b8d32ac.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/lighthouse.wav b/assets/audio/lighthouse.wav new file mode 100644 index 0000000..0815179 Binary files /dev/null and b/assets/audio/lighthouse.wav differ diff --git a/assets/audio/lighthouse.wav.import b/assets/audio/lighthouse.wav.import new file mode 100644 index 0000000..6dbb27d --- /dev/null +++ b/assets/audio/lighthouse.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://cweyxigxi4bpv" +path="res://.godot/imported/lighthouse.wav-6cb0ec00717e5c3ca8767dd6c67aef5c.sample" + +[deps] + +source_file="res://assets/audio/lighthouse.wav" +dest_files=["res://.godot/imported/lighthouse.wav-6cb0ec00717e5c3ca8767dd6c67aef5c.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/manifest.json b/assets/audio/manifest.json new file mode 100644 index 0000000..b6eb09c --- /dev/null +++ b/assets/audio/manifest.json @@ -0,0 +1,542 @@ +{ + "amb_rain": { + "category": "ambience", + "loops": true, + "seconds": 6.0, + "sha256": "91e3a48117bc69d0f092a9838bb036aa419079aa0ab9ce1887b9584f3d1a55f1", + "peak_db": -14.46, + "loudness_db": -27.0, + "target_db": -27.0, + "generator": "tools/audio/recipes.gd" + }, + "amb_surf": { + "category": "ambience", + "loops": true, + "seconds": 8.0, + "sha256": "c3388cc9009de894acd9c65783eae02ddd7db14d4f4489f75ef350b19f15624c", + "peak_db": -13.64, + "loudness_db": -27.0, + "target_db": -27.0, + "generator": "tools/audio/recipes.gd" + }, + "amb_wind": { + "category": "ambience", + "loops": true, + "seconds": 7.0, + "sha256": "1336f72dc43e97cc1698301d6cb6c13637907a09676a174506477d45dd3daf98", + "peak_db": -13.27, + "loudness_db": -27.0, + "target_db": -27.0, + "generator": "tools/audio/recipes.gd" + }, + "bell": { + "category": "tide", + "loops": false, + "seconds": 3.8, + "sha256": "4ab94565e4d460337855d19f3707ac6d7fb8d0c9e762f123ced42cb3223bb193", + "peak_db": -2.32, + "loudness_db": -12.0, + "target_db": -12.0, + "generator": "tools/audio/recipes.gd" + }, + "break_driftwood": { + "category": "build", + "loops": false, + "seconds": 1.0, + "sha256": "1e29c274fd5e50c49e1ad9e4cd8ee947816032d692e5ef87db5e4340ce0d7316", + "peak_db": -4.93, + "loudness_db": -19.0, + "target_db": -19.0, + "generator": "tools/audio/recipes.gd" + }, + "break_salvage_iron": { + "category": "build", + "loops": false, + "seconds": 1.4, + "sha256": "f9936e7c8532f077b9a556ff875b4d4407418665d66cf74b356a9a0c6765e1c8", + "peak_db": -3.61, + "loudness_db": -19.0, + "target_db": -19.0, + "generator": "tools/audio/recipes.gd" + }, + "break_stone": { + "category": "build", + "loops": false, + "seconds": 1.2, + "sha256": "c1da53846d65df3a647bfa651599dbfd7244767a7d9c7de8fe9111eb25606957", + "peak_db": -4.4, + "loudness_db": -19.0, + "target_db": -19.0, + "generator": "tools/audio/recipes.gd" + }, + "build_driftwood": { + "category": "build", + "loops": false, + "seconds": 0.62, + "sha256": "f67ee15c0943428c9e093c62ab0a241de51e78ae9c5b913768d678e6396688c8", + "peak_db": -1.98, + "loudness_db": -19.0, + "target_db": -19.0, + "generator": "tools/audio/recipes.gd" + }, + "build_salvage_iron": { + "category": "build", + "loops": false, + "seconds": 0.63, + "sha256": "a68d70fab460578940db55fafbfad8d7d28778bed51c483a70b15124e0af6dc7", + "peak_db": -1.08, + "loudness_db": -19.0, + "target_db": -19.0, + "generator": "tools/audio/recipes.gd" + }, + "build_stone": { + "category": "build", + "loops": false, + "seconds": 0.7, + "sha256": "b8836a9e3c188c06a4d8ec447844d02b376355d2045231d686b7cadb3a26efc6", + "peak_db": -2.12, + "loudness_db": -19.0, + "target_db": -19.0, + "generator": "tools/audio/recipes.gd" + }, + "chest_open": { + "category": "player", + "loops": false, + "seconds": 1.04, + "sha256": "ce3b8b4a09195bce463bc9ff7cb4bfc2f95b71e4b085f83cdff174cbc67e7c7e", + "peak_db": -2.96, + "loudness_db": -22.0, + "target_db": -22.0, + "generator": "tools/audio/recipes.gd" + }, + "chop": { + "category": "impact", + "loops": false, + "seconds": 0.3, + "sha256": "271d6962cee2524cb79cd00204dc156dfd7a6f17beab690a342fd3fe1eb5fb7e", + "peak_db": -1.05, + "loudness_db": -19.62, + "target_db": -19.0, + "generator": "tools/audio/recipes.gd" + }, + "eliminated": { + "category": "player", + "loops": false, + "seconds": 2.0, + "sha256": "1f264784e9c1677a70a87d4a6742c0d11a025c3fb0f5cd6f2ba15f2a4a1a53bf", + "peak_db": -11.5, + "loudness_db": -22.0, + "target_db": -22.0, + "generator": "tools/audio/recipes.gd" + }, + "foghorn": { + "category": "tide", + "loops": false, + "seconds": 3.6, + "sha256": "5126a894d367689c0deaf7513951464cf893a851be0297e147ca2f2ce42569f0", + "peak_db": -5.36, + "loudness_db": -12.0, + "target_db": -12.0, + "generator": "tools/audio/recipes.gd" + }, + "hit_ground": { + "category": "impact", + "loops": false, + "seconds": 0.3, + "sha256": "10856b8ff027df4ee4e8a148275b9bea3c9320bf41292d789a1393c8e15286e6", + "peak_db": -1.05, + "loudness_db": -19.4, + "target_db": -19.0, + "generator": "tools/audio/recipes.gd" + }, + "hit_iron": { + "category": "impact", + "loops": false, + "seconds": 0.8, + "sha256": "6c70d9095869da3364250802a167cabf9094d21fdaaef719302084f34ee580f6", + "peak_db": -1.26, + "loudness_db": -19.0, + "target_db": -19.0, + "generator": "tools/audio/recipes.gd" + }, + "hit_player": { + "category": "impact", + "loops": false, + "seconds": 0.25, + "sha256": "288cf84795ac4ba543a2bb9407795401e614f66be76cd0f6ea28f567f92bbac9", + "peak_db": -2.15, + "loudness_db": -19.0, + "target_db": -19.0, + "generator": "tools/audio/recipes.gd" + }, + "hit_stone": { + "category": "impact", + "loops": false, + "seconds": 0.3, + "sha256": "886fe3795ce2fbb0189abb4102df4d759f815263f52fc3d7f987b871c22b9379", + "peak_db": -1.05, + "loudness_db": -20.17, + "target_db": -19.0, + "generator": "tools/audio/recipes.gd" + }, + "hit_wood": { + "category": "impact", + "loops": false, + "seconds": 0.35, + "sha256": "23bafcedafbe8787fdae9d58087792680c24b9879b9076cf967209287e3948fd", + "peak_db": -1.05, + "loudness_db": -19.36, + "target_db": -19.0, + "generator": "tools/audio/recipes.gd" + }, + "hurt": { + "category": "player", + "loops": false, + "seconds": 0.35, + "sha256": "8e8f6ff74cb1e74fe7f4c7d3752991a3dd5d31c6b0c088ca0a5faec41afe5ee2", + "peak_db": -5.91, + "loudness_db": -22.0, + "target_db": -22.0, + "generator": "tools/audio/recipes.gd" + }, + "keg_blast": { + "category": "weapon", + "loops": false, + "seconds": 2.6, + "sha256": "00d1455ec274c51216ce8cd21d24f04f3ed94670f2ce3ff7d09ad136ecf6e4ed", + "peak_db": -8.75, + "loudness_db": -15.0, + "target_db": -15.0, + "generator": "tools/audio/recipes.gd" + }, + "land": { + "category": "footstep", + "loops": false, + "seconds": 0.4, + "sha256": "47d4d62693eabeaea6fc07be43791ab2341e6661372392f95cae170148a02ca3", + "peak_db": -7.83, + "loudness_db": -24.0, + "target_db": -24.0, + "generator": "tools/audio/recipes.gd" + }, + "lighthouse": { + "category": "tide", + "loops": false, + "seconds": 4.0, + "sha256": "98d7d56c5eff271ffa1a09c4c9277dfb31b33418cea9808d1602f2d23fbf8957", + "peak_db": -5.82, + "loudness_db": -12.0, + "target_db": -12.0, + "generator": "tools/audio/recipes.gd" + }, + "music_concertina": { + "category": "music", + "loops": true, + "seconds": 13.333, + "sha256": "5564ab9f0f1ec2b5a1d9ba2242e93ce7250e5a1370437e74178871e186c4f208", + "peak_db": -16.31, + "loudness_db": -29.0, + "target_db": -29.0, + "generator": "tools/audio/score.gd" + }, + "music_drone": { + "category": "music", + "loops": true, + "seconds": 13.333, + "sha256": "f631a5541a888f62d339b24dff54f072211994ffb20188867f4d3a782b932aa8", + "peak_db": -21.1, + "loudness_db": -29.0, + "target_db": -29.0, + "generator": "tools/audio/score.gd" + }, + "music_drum": { + "category": "music", + "loops": true, + "seconds": 13.333, + "sha256": "2d0bd51e5eff39e6674bc8991c14660388830b6bd0cac534bb96a5cc528d656b", + "peak_db": -6.51, + "loudness_db": -28.0, + "target_db": -28.0, + "generator": "tools/audio/score.gd" + }, + "music_fiddle": { + "category": "music", + "loops": true, + "seconds": 13.333, + "sha256": "4189c1d4d97098e6d7a5428c4b1b6a0e6edfb41129dfbaa2fd7be43a227971b0", + "peak_db": -19.19, + "loudness_db": -26.0, + "target_db": -26.0, + "generator": "tools/audio/score.gd" + }, + "pickup": { + "category": "player", + "loops": false, + "seconds": 0.3, + "sha256": "ba4f7ce11340d1d1e8d224114ec48568b8f4fb12d6711d9a86ff48e177a9842f", + "peak_db": -8.12, + "loudness_db": -22.0, + "target_db": -22.0, + "generator": "tools/audio/recipes.gd" + }, + "reload": { + "category": "player", + "loops": false, + "seconds": 0.42, + "sha256": "a13af1213a2fc2542c5b2c74bfa80022b46d7bd61e1036d9e87bfe52ccdd0318", + "peak_db": -1.59, + "loudness_db": -22.0, + "target_db": -22.0, + "generator": "tools/audio/recipes.gd" + }, + "shot_dock_carbine": { + "category": "weapon", + "loops": false, + "seconds": 0.92, + "sha256": "f3ce6a703c342e5fc503e9a530851a4943d7e20691af8f5a4bbc1174dd1c5df9", + "peak_db": -1.59, + "loudness_db": -15.0, + "target_db": -15.0, + "generator": "tools/audio/recipes.gd" + }, + "shot_fowling_piece": { + "category": "weapon", + "loops": false, + "seconds": 1.28, + "sha256": "5e7e35d65b92bac72efa7c7b2a70ecf818e65fa45b3410df9bb6bc3130640039", + "peak_db": -4.56, + "loudness_db": -15.0, + "target_db": -15.0, + "generator": "tools/audio/recipes.gd" + }, + "shot_harpoon_gun": { + "category": "weapon", + "loops": false, + "seconds": 0.7, + "sha256": "cfcc4639c77a520803dadfa6dd071dea19257c034f23326e381a03901fc79aa1", + "peak_db": -1.05, + "loudness_db": -16.17, + "target_db": -15.0, + "generator": "tools/audio/recipes.gd" + }, + "shot_line_thrower": { + "category": "weapon", + "loops": false, + "seconds": 0.7, + "sha256": "fa9f8e166c7b1929cd997163b987e355fadec7a6717f8d6ced686cd3ff388216", + "peak_db": -1.05, + "loudness_db": -16.3, + "target_db": -15.0, + "generator": "tools/audio/recipes.gd" + }, + "shot_rivet_repeater": { + "category": "weapon", + "loops": false, + "seconds": 0.4, + "sha256": "f6a9547ee7767b013d46ece53345d58dfa078625b4ecac7dff4ce45793e1f07b", + "peak_db": -1.05, + "loudness_db": -16.21, + "target_db": -15.0, + "generator": "tools/audio/recipes.gd" + }, + "shot_signal_revolver": { + "category": "weapon", + "loops": false, + "seconds": 0.5, + "sha256": "081ccf38cbc7b079967f552a760efc89c823e04e9955141579d2e8c845fb8cae", + "peak_db": -1.05, + "loudness_db": -15.34, + "target_db": -15.0, + "generator": "tools/audio/recipes.gd" + }, + "shot_whalers_longgun": { + "category": "weapon", + "loops": false, + "seconds": 2.19, + "sha256": "3ba89892d3688a2e0966127ad5c5fd12b9eef8ea9bad094a1da9b475fac626f4", + "peak_db": -6.86, + "loudness_db": -15.0, + "target_db": -15.0, + "generator": "tools/audio/recipes.gd" + }, + "splash": { + "category": "water", + "loops": false, + "seconds": 0.9, + "sha256": "1a21d14c506c92cf0f4b005c103c2863ff40732324c965e8706b8bb0a7fe88a3", + "peak_db": -4.04, + "loudness_db": -18.0, + "target_db": -18.0, + "generator": "tools/audio/recipes.gd" + }, + "step_grass_1": { + "category": "footstep", + "loops": false, + "seconds": 0.22, + "sha256": "22a2bd90f3b588c8ccfa22efab837fc6c616f169e1669e2cf226cc2da5fa1300", + "peak_db": -9.76, + "loudness_db": -24.0, + "target_db": -24.0, + "generator": "tools/audio/recipes.gd" + }, + "step_grass_2": { + "category": "footstep", + "loops": false, + "seconds": 0.22, + "sha256": "324f1f657487dd6aca6f306e6ed0e1dcb0811eab85747bcbdc2d84dfb12604aa", + "peak_db": -7.17, + "loudness_db": -24.0, + "target_db": -24.0, + "generator": "tools/audio/recipes.gd" + }, + "step_rock_1": { + "category": "footstep", + "loops": false, + "seconds": 0.18, + "sha256": "e3a807d9dd4af50b5df046892fbdadb1bb0bdccc5c269d5593b53386939a577e", + "peak_db": -3.95, + "loudness_db": -24.0, + "target_db": -24.0, + "generator": "tools/audio/recipes.gd" + }, + "step_rock_2": { + "category": "footstep", + "loops": false, + "seconds": 0.18, + "sha256": "d0e5428402084e215827b27e2970349a300c70aed7713dbb8a7e4bf89dd9f1e6", + "peak_db": -3.05, + "loudness_db": -24.0, + "target_db": -24.0, + "generator": "tools/audio/recipes.gd" + }, + "step_sand_1": { + "category": "footstep", + "loops": false, + "seconds": 0.26, + "sha256": "a64ddb1b12ebd81519c341a88ceefee684e3f29d1c9c55da03766d304d196b71", + "peak_db": -6.09, + "loudness_db": -24.0, + "target_db": -24.0, + "generator": "tools/audio/recipes.gd" + }, + "step_sand_2": { + "category": "footstep", + "loops": false, + "seconds": 0.26, + "sha256": "9b69077d25cc225f805cf39ad8c1ef59270e9576451d825fae74b9b104f8bca2", + "peak_db": -5.39, + "loudness_db": -24.0, + "target_db": -24.0, + "generator": "tools/audio/recipes.gd" + }, + "step_shallows_1": { + "category": "footstep", + "loops": false, + "seconds": 0.4, + "sha256": "bb50596d7df3f35d34627ec99ad15845cff887b3414db1a83773eb67720d68f5", + "peak_db": -9.68, + "loudness_db": -24.0, + "target_db": -24.0, + "generator": "tools/audio/recipes.gd" + }, + "step_shallows_2": { + "category": "footstep", + "loops": false, + "seconds": 0.4, + "sha256": "71d194685dc0a4691e38aea75da99aab57a9a45a8c97a9c72bf9149c6647c842", + "peak_db": -9.66, + "loudness_db": -24.0, + "target_db": -24.0, + "generator": "tools/audio/recipes.gd" + }, + "step_wood_1": { + "category": "footstep", + "loops": false, + "seconds": 0.3, + "sha256": "2e090e4083221d26767b4cc6a0b19581a9b5c8802fc9aa1c9a367bceee44d946", + "peak_db": -5.18, + "loudness_db": -24.0, + "target_db": -24.0, + "generator": "tools/audio/recipes.gd" + }, + "step_wood_2": { + "category": "footstep", + "loops": false, + "seconds": 0.3, + "sha256": "13db663efad3f31e7fc6622ab387c2f5d406c6cebb3cb1c6a56043d4ead617f0", + "peak_db": -4.98, + "loudness_db": -24.0, + "target_db": -24.0, + "generator": "tools/audio/recipes.gd" + }, + "surge": { + "category": "tide", + "loops": false, + "seconds": 3.5, + "sha256": "f4256bc08a72b21398db80872de4f8d37a5aac30fa43e7e73ca2aa083bac34eb", + "peak_db": -5.98, + "loudness_db": -12.0, + "target_db": -12.0, + "generator": "tools/audio/recipes.gd" + }, + "swim": { + "category": "water", + "loops": false, + "seconds": 0.6, + "sha256": "089ea4461b4023fdfba8007a1a26e4b6033a04a058a45cdbb3cc62a1853da679", + "peak_db": -5.54, + "loudness_db": -18.0, + "target_db": -18.0, + "generator": "tools/audio/recipes.gd" + }, + "swing_boathook": { + "category": "weapon", + "loops": false, + "seconds": 0.35, + "sha256": "b79c188f3e30e725eb8c169eee02031e45b44ff82b05750b31d9f4195073308d", + "peak_db": -2.18, + "loudness_db": -15.0, + "target_db": -15.0, + "generator": "tools/audio/recipes.gd" + }, + "ui_back": { + "category": "ui", + "loops": false, + "seconds": 0.27, + "sha256": "b071fdd776579afd65aa04deebec85a96ef3c42c5618685a60889cfa70b9be45", + "peak_db": -6.35, + "loudness_db": -26.0, + "target_db": -26.0, + "generator": "tools/audio/recipes.gd" + }, + "ui_click": { + "category": "ui", + "loops": false, + "seconds": 0.14, + "sha256": "25e825b7975be91744cbe68942aeba141538a09961fd862d131446dc92440e63", + "peak_db": -5.57, + "loudness_db": -26.0, + "target_db": -26.0, + "generator": "tools/audio/recipes.gd" + }, + "ui_confirm": { + "category": "ui", + "loops": false, + "seconds": 0.9, + "sha256": "fb91d5ef05cfab1d9ee1f4141b71050a2156a12db92f203009a7ce48564206b2", + "peak_db": -11.36, + "loudness_db": -26.0, + "target_db": -26.0, + "generator": "tools/audio/recipes.gd" + }, + "ui_hover": { + "category": "ui", + "loops": false, + "seconds": 0.08, + "sha256": "53db564707f8a01f27af3ba94513df6bc37431462cd1f9c1939625beacc3cc08", + "peak_db": -7.92, + "loudness_db": -26.0, + "target_db": -26.0, + "generator": "tools/audio/recipes.gd" + } +} diff --git a/assets/audio/music_concertina.wav b/assets/audio/music_concertina.wav new file mode 100644 index 0000000..9b8d5f3 Binary files /dev/null and b/assets/audio/music_concertina.wav differ diff --git a/assets/audio/music_concertina.wav.import b/assets/audio/music_concertina.wav.import new file mode 100644 index 0000000..3549e99 --- /dev/null +++ b/assets/audio/music_concertina.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://nmdpxdxhv1ka" +path="res://.godot/imported/music_concertina.wav-3bb9781733c5c8362f9331ac49caaab1.sample" + +[deps] + +source_file="res://assets/audio/music_concertina.wav" +dest_files=["res://.godot/imported/music_concertina.wav-3bb9781733c5c8362f9331ac49caaab1.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/music_drone.wav b/assets/audio/music_drone.wav new file mode 100644 index 0000000..3650c78 Binary files /dev/null and b/assets/audio/music_drone.wav differ diff --git a/assets/audio/music_drone.wav.import b/assets/audio/music_drone.wav.import new file mode 100644 index 0000000..922ae49 --- /dev/null +++ b/assets/audio/music_drone.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://c43ly2q0yrgk3" +path="res://.godot/imported/music_drone.wav-2e64ce1d2ddc7c6bc17bea9a64a84bd0.sample" + +[deps] + +source_file="res://assets/audio/music_drone.wav" +dest_files=["res://.godot/imported/music_drone.wav-2e64ce1d2ddc7c6bc17bea9a64a84bd0.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/music_drum.wav b/assets/audio/music_drum.wav new file mode 100644 index 0000000..e3ebd71 Binary files /dev/null and b/assets/audio/music_drum.wav differ diff --git a/assets/audio/music_drum.wav.import b/assets/audio/music_drum.wav.import new file mode 100644 index 0000000..fd1b30e --- /dev/null +++ b/assets/audio/music_drum.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://cbu7x42a44nac" +path="res://.godot/imported/music_drum.wav-b36e212a2c7e061253b14387e37994ee.sample" + +[deps] + +source_file="res://assets/audio/music_drum.wav" +dest_files=["res://.godot/imported/music_drum.wav-b36e212a2c7e061253b14387e37994ee.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/music_fiddle.wav b/assets/audio/music_fiddle.wav new file mode 100644 index 0000000..c4d20b8 Binary files /dev/null and b/assets/audio/music_fiddle.wav differ diff --git a/assets/audio/music_fiddle.wav.import b/assets/audio/music_fiddle.wav.import new file mode 100644 index 0000000..4244a02 --- /dev/null +++ b/assets/audio/music_fiddle.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://d82tt4mvjfus" +path="res://.godot/imported/music_fiddle.wav-86298f62e872b481d34658b5d587375c.sample" + +[deps] + +source_file="res://assets/audio/music_fiddle.wav" +dest_files=["res://.godot/imported/music_fiddle.wav-86298f62e872b481d34658b5d587375c.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/pickup.wav b/assets/audio/pickup.wav new file mode 100644 index 0000000..04b44f8 Binary files /dev/null and b/assets/audio/pickup.wav differ diff --git a/assets/audio/pickup.wav.import b/assets/audio/pickup.wav.import new file mode 100644 index 0000000..c7ce71a --- /dev/null +++ b/assets/audio/pickup.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://dcl7vft12i52u" +path="res://.godot/imported/pickup.wav-005c0482069dd16ebcd4cedd7f327134.sample" + +[deps] + +source_file="res://assets/audio/pickup.wav" +dest_files=["res://.godot/imported/pickup.wav-005c0482069dd16ebcd4cedd7f327134.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/reload.wav b/assets/audio/reload.wav new file mode 100644 index 0000000..79bc913 Binary files /dev/null and b/assets/audio/reload.wav differ diff --git a/assets/audio/reload.wav.import b/assets/audio/reload.wav.import new file mode 100644 index 0000000..63a1d68 --- /dev/null +++ b/assets/audio/reload.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://em8m7gfufhet" +path="res://.godot/imported/reload.wav-50f2d65be979b5afe34a1e31b08f63e8.sample" + +[deps] + +source_file="res://assets/audio/reload.wav" +dest_files=["res://.godot/imported/reload.wav-50f2d65be979b5afe34a1e31b08f63e8.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/shot_dock_carbine.wav b/assets/audio/shot_dock_carbine.wav new file mode 100644 index 0000000..c946337 Binary files /dev/null and b/assets/audio/shot_dock_carbine.wav differ diff --git a/assets/audio/shot_dock_carbine.wav.import b/assets/audio/shot_dock_carbine.wav.import new file mode 100644 index 0000000..e6a150f --- /dev/null +++ b/assets/audio/shot_dock_carbine.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://bm0g5jrvvckqp" +path="res://.godot/imported/shot_dock_carbine.wav-d1a81c2a5de363a10e6051824a5df68b.sample" + +[deps] + +source_file="res://assets/audio/shot_dock_carbine.wav" +dest_files=["res://.godot/imported/shot_dock_carbine.wav-d1a81c2a5de363a10e6051824a5df68b.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/shot_fowling_piece.wav b/assets/audio/shot_fowling_piece.wav new file mode 100644 index 0000000..7363721 Binary files /dev/null and b/assets/audio/shot_fowling_piece.wav differ diff --git a/assets/audio/shot_fowling_piece.wav.import b/assets/audio/shot_fowling_piece.wav.import new file mode 100644 index 0000000..672bf53 --- /dev/null +++ b/assets/audio/shot_fowling_piece.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://dlxyd33frasjq" +path="res://.godot/imported/shot_fowling_piece.wav-32ffa2e75368314d16bcb9703c5730ad.sample" + +[deps] + +source_file="res://assets/audio/shot_fowling_piece.wav" +dest_files=["res://.godot/imported/shot_fowling_piece.wav-32ffa2e75368314d16bcb9703c5730ad.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/shot_harpoon_gun.wav b/assets/audio/shot_harpoon_gun.wav new file mode 100644 index 0000000..0c20a3b Binary files /dev/null and b/assets/audio/shot_harpoon_gun.wav differ diff --git a/assets/audio/shot_harpoon_gun.wav.import b/assets/audio/shot_harpoon_gun.wav.import new file mode 100644 index 0000000..fcb36ae --- /dev/null +++ b/assets/audio/shot_harpoon_gun.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://di8ovfnvljl5x" +path="res://.godot/imported/shot_harpoon_gun.wav-00d1e808fed227b7292292c66478873a.sample" + +[deps] + +source_file="res://assets/audio/shot_harpoon_gun.wav" +dest_files=["res://.godot/imported/shot_harpoon_gun.wav-00d1e808fed227b7292292c66478873a.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/shot_line_thrower.wav b/assets/audio/shot_line_thrower.wav new file mode 100644 index 0000000..22afac9 Binary files /dev/null and b/assets/audio/shot_line_thrower.wav differ diff --git a/assets/audio/shot_line_thrower.wav.import b/assets/audio/shot_line_thrower.wav.import new file mode 100644 index 0000000..68b849c --- /dev/null +++ b/assets/audio/shot_line_thrower.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://dbpui6x27mpio" +path="res://.godot/imported/shot_line_thrower.wav-46573384a97aa73092687f748bf8125a.sample" + +[deps] + +source_file="res://assets/audio/shot_line_thrower.wav" +dest_files=["res://.godot/imported/shot_line_thrower.wav-46573384a97aa73092687f748bf8125a.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/shot_rivet_repeater.wav b/assets/audio/shot_rivet_repeater.wav new file mode 100644 index 0000000..9bc7664 Binary files /dev/null and b/assets/audio/shot_rivet_repeater.wav differ diff --git a/assets/audio/shot_rivet_repeater.wav.import b/assets/audio/shot_rivet_repeater.wav.import new file mode 100644 index 0000000..cce4237 --- /dev/null +++ b/assets/audio/shot_rivet_repeater.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://dvbejcfi6ucwm" +path="res://.godot/imported/shot_rivet_repeater.wav-c1c8de0dc4f48ffbf874772bd09d249a.sample" + +[deps] + +source_file="res://assets/audio/shot_rivet_repeater.wav" +dest_files=["res://.godot/imported/shot_rivet_repeater.wav-c1c8de0dc4f48ffbf874772bd09d249a.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/shot_signal_revolver.wav b/assets/audio/shot_signal_revolver.wav new file mode 100644 index 0000000..5bb50a4 Binary files /dev/null and b/assets/audio/shot_signal_revolver.wav differ diff --git a/assets/audio/shot_signal_revolver.wav.import b/assets/audio/shot_signal_revolver.wav.import new file mode 100644 index 0000000..8fc9001 --- /dev/null +++ b/assets/audio/shot_signal_revolver.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://b6gcl53gy0in5" +path="res://.godot/imported/shot_signal_revolver.wav-755563ebd35211b7fb09e23860f0b1d0.sample" + +[deps] + +source_file="res://assets/audio/shot_signal_revolver.wav" +dest_files=["res://.godot/imported/shot_signal_revolver.wav-755563ebd35211b7fb09e23860f0b1d0.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/shot_whalers_longgun.wav b/assets/audio/shot_whalers_longgun.wav new file mode 100644 index 0000000..f4994d0 Binary files /dev/null and b/assets/audio/shot_whalers_longgun.wav differ diff --git a/assets/audio/shot_whalers_longgun.wav.import b/assets/audio/shot_whalers_longgun.wav.import new file mode 100644 index 0000000..f1e7d88 --- /dev/null +++ b/assets/audio/shot_whalers_longgun.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://ck680n1lcwrwe" +path="res://.godot/imported/shot_whalers_longgun.wav-318cf59da07f59b8d5faf3dca6bff540.sample" + +[deps] + +source_file="res://assets/audio/shot_whalers_longgun.wav" +dest_files=["res://.godot/imported/shot_whalers_longgun.wav-318cf59da07f59b8d5faf3dca6bff540.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/splash.wav b/assets/audio/splash.wav new file mode 100644 index 0000000..c3e4dfa Binary files /dev/null and b/assets/audio/splash.wav differ diff --git a/assets/audio/splash.wav.import b/assets/audio/splash.wav.import new file mode 100644 index 0000000..252d9b7 --- /dev/null +++ b/assets/audio/splash.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://c3baxuiy3d1nq" +path="res://.godot/imported/splash.wav-5ec4fd8293fbd42c27becff16a2e488f.sample" + +[deps] + +source_file="res://assets/audio/splash.wav" +dest_files=["res://.godot/imported/splash.wav-5ec4fd8293fbd42c27becff16a2e488f.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/step_grass_1.wav b/assets/audio/step_grass_1.wav new file mode 100644 index 0000000..f395b83 Binary files /dev/null and b/assets/audio/step_grass_1.wav differ diff --git a/assets/audio/step_grass_1.wav.import b/assets/audio/step_grass_1.wav.import new file mode 100644 index 0000000..643cc60 --- /dev/null +++ b/assets/audio/step_grass_1.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://c2wapmq03n0ep" +path="res://.godot/imported/step_grass_1.wav-1a07d4eb9214e8dd566a17c49274b30f.sample" + +[deps] + +source_file="res://assets/audio/step_grass_1.wav" +dest_files=["res://.godot/imported/step_grass_1.wav-1a07d4eb9214e8dd566a17c49274b30f.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/step_grass_2.wav b/assets/audio/step_grass_2.wav new file mode 100644 index 0000000..318d867 Binary files /dev/null and b/assets/audio/step_grass_2.wav differ diff --git a/assets/audio/step_grass_2.wav.import b/assets/audio/step_grass_2.wav.import new file mode 100644 index 0000000..21481cc --- /dev/null +++ b/assets/audio/step_grass_2.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://ce11j87velk1g" +path="res://.godot/imported/step_grass_2.wav-d2639d368a5dd9b930d4f15911462d9f.sample" + +[deps] + +source_file="res://assets/audio/step_grass_2.wav" +dest_files=["res://.godot/imported/step_grass_2.wav-d2639d368a5dd9b930d4f15911462d9f.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/step_rock_1.wav b/assets/audio/step_rock_1.wav new file mode 100644 index 0000000..da011b2 Binary files /dev/null and b/assets/audio/step_rock_1.wav differ diff --git a/assets/audio/step_rock_1.wav.import b/assets/audio/step_rock_1.wav.import new file mode 100644 index 0000000..947b8ff --- /dev/null +++ b/assets/audio/step_rock_1.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://ubjxh6qr0q3x" +path="res://.godot/imported/step_rock_1.wav-f48c4a64f02d969c8e4a9e714e92be96.sample" + +[deps] + +source_file="res://assets/audio/step_rock_1.wav" +dest_files=["res://.godot/imported/step_rock_1.wav-f48c4a64f02d969c8e4a9e714e92be96.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/step_rock_2.wav b/assets/audio/step_rock_2.wav new file mode 100644 index 0000000..866abbe Binary files /dev/null and b/assets/audio/step_rock_2.wav differ diff --git a/assets/audio/step_rock_2.wav.import b/assets/audio/step_rock_2.wav.import new file mode 100644 index 0000000..03c9e14 --- /dev/null +++ b/assets/audio/step_rock_2.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://dav7rpsct3o53" +path="res://.godot/imported/step_rock_2.wav-4253a3ac218c4c2a42e351dea286d00c.sample" + +[deps] + +source_file="res://assets/audio/step_rock_2.wav" +dest_files=["res://.godot/imported/step_rock_2.wav-4253a3ac218c4c2a42e351dea286d00c.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/step_sand_1.wav b/assets/audio/step_sand_1.wav new file mode 100644 index 0000000..6ddb233 Binary files /dev/null and b/assets/audio/step_sand_1.wav differ diff --git a/assets/audio/step_sand_1.wav.import b/assets/audio/step_sand_1.wav.import new file mode 100644 index 0000000..bd1d686 --- /dev/null +++ b/assets/audio/step_sand_1.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://ccuyqn1sxlp7v" +path="res://.godot/imported/step_sand_1.wav-4ed16d746f05831b818cc83a2864b671.sample" + +[deps] + +source_file="res://assets/audio/step_sand_1.wav" +dest_files=["res://.godot/imported/step_sand_1.wav-4ed16d746f05831b818cc83a2864b671.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/step_sand_2.wav b/assets/audio/step_sand_2.wav new file mode 100644 index 0000000..5b16762 Binary files /dev/null and b/assets/audio/step_sand_2.wav differ diff --git a/assets/audio/step_sand_2.wav.import b/assets/audio/step_sand_2.wav.import new file mode 100644 index 0000000..62a08cf --- /dev/null +++ b/assets/audio/step_sand_2.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://fojpx8qjvrhe" +path="res://.godot/imported/step_sand_2.wav-13a96aeb5bec8a049cac3f0d35f2bcb8.sample" + +[deps] + +source_file="res://assets/audio/step_sand_2.wav" +dest_files=["res://.godot/imported/step_sand_2.wav-13a96aeb5bec8a049cac3f0d35f2bcb8.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/step_shallows_1.wav b/assets/audio/step_shallows_1.wav new file mode 100644 index 0000000..ce495e1 Binary files /dev/null and b/assets/audio/step_shallows_1.wav differ diff --git a/assets/audio/step_shallows_1.wav.import b/assets/audio/step_shallows_1.wav.import new file mode 100644 index 0000000..f0a4f93 --- /dev/null +++ b/assets/audio/step_shallows_1.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://bsaq2jg2q8u02" +path="res://.godot/imported/step_shallows_1.wav-267c9794e6bab4534162b07ce963244f.sample" + +[deps] + +source_file="res://assets/audio/step_shallows_1.wav" +dest_files=["res://.godot/imported/step_shallows_1.wav-267c9794e6bab4534162b07ce963244f.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/step_shallows_2.wav b/assets/audio/step_shallows_2.wav new file mode 100644 index 0000000..dfb4929 Binary files /dev/null and b/assets/audio/step_shallows_2.wav differ diff --git a/assets/audio/step_shallows_2.wav.import b/assets/audio/step_shallows_2.wav.import new file mode 100644 index 0000000..a0ee285 --- /dev/null +++ b/assets/audio/step_shallows_2.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://bfea4gxevep8i" +path="res://.godot/imported/step_shallows_2.wav-dc33455f5fd685ffa99250fd13925e87.sample" + +[deps] + +source_file="res://assets/audio/step_shallows_2.wav" +dest_files=["res://.godot/imported/step_shallows_2.wav-dc33455f5fd685ffa99250fd13925e87.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/step_wood_1.wav b/assets/audio/step_wood_1.wav new file mode 100644 index 0000000..2538008 Binary files /dev/null and b/assets/audio/step_wood_1.wav differ diff --git a/assets/audio/step_wood_1.wav.import b/assets/audio/step_wood_1.wav.import new file mode 100644 index 0000000..8a49fc3 --- /dev/null +++ b/assets/audio/step_wood_1.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://dgypqge01ex7y" +path="res://.godot/imported/step_wood_1.wav-dc93baaf326355245944c55b38184551.sample" + +[deps] + +source_file="res://assets/audio/step_wood_1.wav" +dest_files=["res://.godot/imported/step_wood_1.wav-dc93baaf326355245944c55b38184551.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/step_wood_2.wav b/assets/audio/step_wood_2.wav new file mode 100644 index 0000000..9a394fc Binary files /dev/null and b/assets/audio/step_wood_2.wav differ diff --git a/assets/audio/step_wood_2.wav.import b/assets/audio/step_wood_2.wav.import new file mode 100644 index 0000000..66edf61 --- /dev/null +++ b/assets/audio/step_wood_2.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://baacujwfs0778" +path="res://.godot/imported/step_wood_2.wav-aea818a08fb9e45ea0476ca6031a372c.sample" + +[deps] + +source_file="res://assets/audio/step_wood_2.wav" +dest_files=["res://.godot/imported/step_wood_2.wav-aea818a08fb9e45ea0476ca6031a372c.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/surge.wav b/assets/audio/surge.wav new file mode 100644 index 0000000..a99d93d Binary files /dev/null and b/assets/audio/surge.wav differ diff --git a/assets/audio/surge.wav.import b/assets/audio/surge.wav.import new file mode 100644 index 0000000..771e853 --- /dev/null +++ b/assets/audio/surge.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://bc74cr2hdlwgq" +path="res://.godot/imported/surge.wav-32074e26d26fc0d8f21ee64de5d20971.sample" + +[deps] + +source_file="res://assets/audio/surge.wav" +dest_files=["res://.godot/imported/surge.wav-32074e26d26fc0d8f21ee64de5d20971.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/swim.wav b/assets/audio/swim.wav new file mode 100644 index 0000000..e66cb03 Binary files /dev/null and b/assets/audio/swim.wav differ diff --git a/assets/audio/swim.wav.import b/assets/audio/swim.wav.import new file mode 100644 index 0000000..74f1a64 --- /dev/null +++ b/assets/audio/swim.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://bw6035mfofsd" +path="res://.godot/imported/swim.wav-f60c63fc9f4fc811b5b2e0ed8a963264.sample" + +[deps] + +source_file="res://assets/audio/swim.wav" +dest_files=["res://.godot/imported/swim.wav-f60c63fc9f4fc811b5b2e0ed8a963264.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/swing_boathook.wav b/assets/audio/swing_boathook.wav new file mode 100644 index 0000000..fd7f1d0 Binary files /dev/null and b/assets/audio/swing_boathook.wav differ diff --git a/assets/audio/swing_boathook.wav.import b/assets/audio/swing_boathook.wav.import new file mode 100644 index 0000000..b393bb4 --- /dev/null +++ b/assets/audio/swing_boathook.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://cgpj0mle7bip7" +path="res://.godot/imported/swing_boathook.wav-6227dc9735b2d08af46944a9a1e7dcc1.sample" + +[deps] + +source_file="res://assets/audio/swing_boathook.wav" +dest_files=["res://.godot/imported/swing_boathook.wav-6227dc9735b2d08af46944a9a1e7dcc1.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/ui_back.wav b/assets/audio/ui_back.wav new file mode 100644 index 0000000..cfb940e Binary files /dev/null and b/assets/audio/ui_back.wav differ diff --git a/assets/audio/ui_back.wav.import b/assets/audio/ui_back.wav.import new file mode 100644 index 0000000..6e9ce3a --- /dev/null +++ b/assets/audio/ui_back.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://c5frbn1w7d6tm" +path="res://.godot/imported/ui_back.wav-56fe1fa7ac8a8ca13054a184bdd849d2.sample" + +[deps] + +source_file="res://assets/audio/ui_back.wav" +dest_files=["res://.godot/imported/ui_back.wav-56fe1fa7ac8a8ca13054a184bdd849d2.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/ui_click.wav b/assets/audio/ui_click.wav new file mode 100644 index 0000000..1c2c6d1 Binary files /dev/null and b/assets/audio/ui_click.wav differ diff --git a/assets/audio/ui_click.wav.import b/assets/audio/ui_click.wav.import new file mode 100644 index 0000000..3858988 --- /dev/null +++ b/assets/audio/ui_click.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://b2peil8v2nca2" +path="res://.godot/imported/ui_click.wav-27a1a14815f4272c438d6dd4385cee0b.sample" + +[deps] + +source_file="res://assets/audio/ui_click.wav" +dest_files=["res://.godot/imported/ui_click.wav-27a1a14815f4272c438d6dd4385cee0b.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/ui_confirm.wav b/assets/audio/ui_confirm.wav new file mode 100644 index 0000000..725bbfe Binary files /dev/null and b/assets/audio/ui_confirm.wav differ diff --git a/assets/audio/ui_confirm.wav.import b/assets/audio/ui_confirm.wav.import new file mode 100644 index 0000000..eb22e85 --- /dev/null +++ b/assets/audio/ui_confirm.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://dxn1me6xnxfek" +path="res://.godot/imported/ui_confirm.wav-bc2ae5b59e18c09c9fb35c83bd897209.sample" + +[deps] + +source_file="res://assets/audio/ui_confirm.wav" +dest_files=["res://.godot/imported/ui_confirm.wav-bc2ae5b59e18c09c9fb35c83bd897209.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/audio/ui_hover.wav b/assets/audio/ui_hover.wav new file mode 100644 index 0000000..db28cd9 Binary files /dev/null and b/assets/audio/ui_hover.wav differ diff --git a/assets/audio/ui_hover.wav.import b/assets/audio/ui_hover.wav.import new file mode 100644 index 0000000..0697321 --- /dev/null +++ b/assets/audio/ui_hover.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://mf7l7lcu48k" +path="res://.godot/imported/ui_hover.wav-e8532001b0f3258b9ba03aefba32a561.sample" + +[deps] + +source_file="res://assets/audio/ui_hover.wav" +dest_files=["res://.godot/imported/ui_hover.wav-e8532001b0f3258b9ba03aefba32a561.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 796d02d..905100b 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -410,7 +410,7 @@ the hand, which needs a real playtest. | `src/server/` | Headless and listening servers, joining the network to the match | `src/sim/`, `src/bots/`, `src/net/` | | `src/client/` | World rendering, camera, input, effects | `src/sim/`, `src/net/` | | `src/ui/` | HUD, menus, map | `src/sim/` (read only), `src/client/` | -| `src/audio/` | Sound playback, music | `src/sim/` (read only) | +| `src/audio/` | Sound playback, music (A8) | `src/sim/` and `src/net/` (read only) | | `src/app/` | Startup and mode selection | Everything | ## Bots @@ -541,3 +541,32 @@ client played every match, the p99 tick, and memory from one match to the next. A client process holds back a new match's notice until it has made that client's island, at most one a frame: a dozen clients making islands in one frame starved their connections of service for long enough that ENet dropped them. + +## Audio (A8) + +Every sound is synthesized offline by `tools/audio/` and committed as a WAV in +`assets/audio/`, with `manifest.json` recording each file's hash and levels and +`assets/PROVENANCE.md` naming the generators. `make audio` regenerates them; the same +engine build gives the same bytes, and `test_audio_assets` regenerates every file and +compares hashes. `make audio-check` (and that test) holds each sound to its category's +loudness (`tools/audio/loudness.gd`) and the mix order: the tide loudest, ambience, +music and menus under the effects. + +In the client: + +- `SoundDirector` (a child of `ClientSession`) reads the client's world each frame and + turns what changed into sounds: FX records (shots, impacts, harvesting), footsteps by + surface for every walking player near the camera, landings and splashes, pieces built + and broken, the tide's bell, foghorn, surge and lighthouse, the own player's hurts and + the feed. Placed sounds play on `AudioStreamPlayer3D` voices at the event's position, + so the camera's listener pans and attenuates them. It never changes the world, and the + server plays no sound. +- `MusicDirector` (a child of `AppShell`) plays the score's four layers in step on an + `AudioStreamSynchronized` and fades them by intensity: full in menus and results, + the drone alone while the first tide holds, building to the whole tune for the last + land. +- `MenuSounds` hooks every menu button for a hover tick and a press knock. + +Effects play on the `Effects` bus and music on `Music`; the settings' volume sliders +set those buses. + diff --git a/docs/STYLE.md b/docs/STYLE.md index d7cad76..3b0a578 100644 --- a/docs/STYLE.md +++ b/docs/STYLE.md @@ -151,6 +151,10 @@ All synthesized by scripts in the repository. fuller in menus and results. - Mix: the sea is always present underneath. Loudness is calm; the tide is the loudest thing when it rises. +- Levels (loudest 400 ms window, dBFS, `tools/audio/recipes.gd`): tide -12, weapons + -15, water -18, impacts and building -19, player -22, footsteps -24, menus -26, + ambience -27 (whole loop). The score's layers sit at -26 to -29 and play 6 dB lower + again under a match. Peaks never pass -1 dBFS. `make audio-check` enforces all of it. ## Never diff --git a/src/app/app_shell.gd b/src/app/app_shell.gd index 5a39943..c725866 100644 --- a/src/app/app_shell.gd +++ b/src/app/app_shell.gd @@ -14,6 +14,9 @@ signal quit_requested var settings: GameSettings var settings_path: String var menus: Menus +## The score (A8), fuller in the menus and quieter under a match, and the menus' knocks. +var music: MusicDirector +var menu_sounds: MenuSounds var session: ClientSession = null ## Keeps the mouse free and skips the window when false (tests, headless). var grab_mouse: bool = true @@ -44,6 +47,13 @@ func _init(with: GameSettings = null, path: String = GameSettings.DEFAULT_PATH) menus.leave_requested.connect(leave) menus.quit_requested.connect(func() -> void: quit_requested.emit()) menus.settings_changed.connect(_settings_changed) + music = MusicDirector.new() + music.name = "Music" + add_child(music) + menu_sounds = MenuSounds.new() + menu_sounds.name = "MenuSounds" + add_child(menu_sounds) + menu_sounds.attach(menus) func _ready() -> void: diff --git a/src/app/client_session.gd b/src/app/client_session.gd index b2053e4..d211304 100644 --- a/src/app/client_session.gd +++ b/src/app/client_session.gd @@ -30,6 +30,8 @@ var hud: Hud = null ## the map key opens it. Children of the HUD. var minimap: ChartMap = null var chart: ChartMap = null +## The match's sound (A8), once the session is in a scene tree. +var sound: SoundDirector = null ## The player's settings (see use_settings()). var settings: GameSettings = GameSettings.new() ## Escape asks for the pause menu: whoever runs the session shows it (AppShell). With @@ -124,6 +126,9 @@ func _ready() -> void: _status.add_theme_color_override("font_outline_color", Palette.OUTLINE) _status.add_theme_constant_override("outline_size", 6) add_child(_status) + sound = SoundDirector.new() + sound.name = "Sound" + add_child(sound) hud = Hud.new() add_child(hud) minimap = ChartMap.new(ChartMap.Mode.MINI) @@ -143,6 +148,8 @@ func _ready() -> void: func _process(delta: float) -> void: pump(delta) + if sound != null: + sound.update(game, mirror.own_id, view.camera.global_position if view != null else Vector3.ZERO, delta) if _status != null: _status.text = status_text() if hud != null: diff --git a/src/audio/menu_sounds.gd b/src/audio/menu_sounds.gd new file mode 100644 index 0000000..c70dc2c --- /dev/null +++ b/src/audio/menu_sounds.gd @@ -0,0 +1,61 @@ +## Wooden knocks for the menus: a soft tick when a button is pointed at or focused, a +## peg knocked home when it's pressed, a two-step knock for going back. Attached to a +## Control, it hooks every button under it, including ones made later (the server list). +class_name MenuSounds +extends Node + +const BACK_WORDS: Array[String] = ["Back", "Resume", "Leave", "Cancel"] + +## Sounds played since attached, newest last: for tests. +var heard: Array[String] = [] +var audible: bool = true + +var _root: Control +var _voice: AudioStreamPlayer + + +func attach(root: Control) -> void: + _root = root + SoundBank.ensure_bus(SoundBank.EFFECTS_BUS) + _voice = AudioStreamPlayer.new() + _voice.bus = SoundBank.EFFECTS_BUS + _voice.max_polyphony = 4 + add_child(_voice) + _hook_all(root) + + +func _ready() -> void: + get_tree().node_added.connect(_hook_later) + + +func _hook_later(node: Node) -> void: + if _root != null and (node == _root or _root.is_ancestor_of(node)): + _hook(node) + + +func _hook_all(node: Node) -> void: + _hook(node) + for child: Node in node.get_children(): + _hook_all(child) + + +func _hook(node: Node) -> void: + var button: BaseButton = node as BaseButton + if button == null or button.has_meta("menu_sounds"): + return + button.set_meta("menu_sounds", true) + var text: String = (button as Button).text if button is Button else "" + var press: String = "ui_back" if BACK_WORDS.has(text) else "ui_click" + button.pressed.connect(play.bind(press)) + button.mouse_entered.connect(play.bind("ui_hover")) + button.focus_entered.connect(play.bind("ui_hover")) + + +func play(sound: String) -> void: + heard.append(sound) + if heard.size() > 64: + heard.pop_front() + if not audible or _voice == null: + return + _voice.stream = SoundBank.stream(sound) + _voice.play() diff --git a/src/audio/menu_sounds.gd.uid b/src/audio/menu_sounds.gd.uid new file mode 100644 index 0000000..13eff33 --- /dev/null +++ b/src/audio/menu_sounds.gd.uid @@ -0,0 +1 @@ +uid://ducdhhaku6pd diff --git a/src/audio/music_director.gd b/src/audio/music_director.gd new file mode 100644 index 0000000..761e8d5 --- /dev/null +++ b/src/audio/music_director.gd @@ -0,0 +1,89 @@ +## The adaptive score (tools/audio/score.gd): four layers of one tune that loop in step +## on an AudioStreamSynchronized, each faded in or out by how much the moment calls for. +## +## intensity 0 drone holding tide, early in a match +## intensity 1 drone, drum lobby, drop, the sea rising +## intensity 2 drone, drum, concertina the middle phases +## intensity 3 drone, drum, concertina, fiddle menus, results, the last land +## +## Quiet in play and fuller in menus and results, as docs/STYLE.md asks. Plays on +## the Music bus, so the music volume setting covers it. +class_name MusicDirector +extends Node + +const LAYERS: Array[String] = ["music_drone", "music_drum", "music_concertina", "music_fiddle"] +## Seconds for a layer to fade fully in or out. +const FADE_SECONDS: float = 3.0 +## Gain of the whole score in a match, under the effects, and in menus. +const MATCH_GAIN_DB: float = -6.0 +const MENU_GAIN_DB: float = 0.0 + +## How full the music is now, 0 to 3, and each layer's current gain, 0 to 1. +var intensity: int = 3 +var gains: PackedFloat32Array = PackedFloat32Array([0.0, 0.0, 0.0, 0.0]) +var in_match: bool = false +var player: AudioStreamPlayer +var audible: bool = true + +var _sync: AudioStreamSynchronized + + +func _ready() -> void: + SoundBank.ensure_bus(SoundBank.MUSIC_BUS) + _sync = AudioStreamSynchronized.new() + _sync.stream_count = LAYERS.size() + for index: int in LAYERS.size(): + _sync.set_sync_stream(index, SoundBank.stream(LAYERS[index])) + _sync.set_sync_stream_volume(index, -80.0) + player = AudioStreamPlayer.new() + player.bus = SoundBank.MUSIC_BUS + player.stream = _sync + add_child(player) + if audible: + player.play() + + +## The intensity for a moment: no game (menus) is 3; otherwise by match phase and tide. +static func intensity_for(game: ClientGame) -> int: + if game == null or game.world == null: + return 3 + match game.match_phase: + Match.LOBBY, Match.COUNTDOWN, Match.DROP: + return 1 + Match.RESULTS: + return 3 + var world: Simulation = game.world + if world.tide == null: + return 0 + var stage: int = world.tide.stage_at(world.tick) + if stage == Tide.SUDDEN_DEATH or stage == Tide.OVER: + return 3 + var phase: int = world.tide.phase_at(world.tick) + var last: int = Tide.phase_count() - 1 + if phase >= last: + return 3 + if phase >= 2: + return 2 + if phase == 1 or stage == Tide.RISE: + return 1 + return 0 + + +## One frame: aims the layers at `game`'s intensity (null for the menus) and fades. +func update(game: ClientGame, delta: float) -> void: + intensity = intensity_for(game) + in_match = game != null and game.world != null and game.match_phase != Match.RESULTS + var step: float = delta / FADE_SECONDS + for index: int in LAYERS.size(): + var aim: float = 1.0 if index <= intensity else 0.0 + gains[index] = move_toward(gains[index], aim, step) + if _sync == null: + return + var overall: float = MATCH_GAIN_DB if in_match else MENU_GAIN_DB + for index: int in LAYERS.size(): + _sync.set_sync_stream_volume(index, linear_to_db(maxf(gains[index], 0.0001)) + overall) + + +func _process(delta: float) -> void: + var shell: AppShell = get_parent() as AppShell + update(shell.session.game if shell != null and shell.session != null else null, delta) diff --git a/src/audio/music_director.gd.uid b/src/audio/music_director.gd.uid new file mode 100644 index 0000000..921e460 --- /dev/null +++ b/src/audio/music_director.gd.uid @@ -0,0 +1 @@ +uid://dli4je20nwxp4 diff --git a/src/audio/sound_bank.gd b/src/audio/sound_bank.gd new file mode 100644 index 0000000..6423798 --- /dev/null +++ b/src/audio/sound_bank.gd @@ -0,0 +1,56 @@ +## The game's sounds, as the generator in tools/audio/ wrote them to assets/audio/ +## (see assets/PROVENANCE.md). Streams are loaded once and kept; the looped ones +## (ambience and the score's layers) are set to loop whole. +class_name SoundBank +extends RefCounted + +const DIR: String = "res://assets/audio" +const MUSIC_BUS: String = "Music" +const EFFECTS_BUS: String = "Effects" +## Sounds that loop: ambience and the score's layers. +const LOOPED_PREFIXES: Array[String] = ["amb_", "music_"] + +static var _cache: Dictionary = {} + + +## The stream for a sound by name, or null if there's no such file. +static func stream(sound: String) -> AudioStream: + if _cache.has(sound): + return _cache[sound] + var path: String = "%s/%s.wav" % [DIR, sound] + var loaded: AudioStreamWAV = null + if ResourceLoader.exists(path): + loaded = load(path) as AudioStreamWAV + if loaded != null and loops(sound): + loaded.loop_mode = AudioStreamWAV.LOOP_FORWARD + loaded.loop_begin = 0 + loaded.loop_end = int(round(loaded.get_length() * loaded.mix_rate)) + _cache[sound] = loaded + return loaded + + +## Lets go of every loaded stream (tests, and leaving the game). +static func clear() -> void: + _cache.clear() + + +static func has(sound: String) -> bool: + return stream(sound) != null + + +static func loops(sound: String) -> bool: + for prefix: String in LOOPED_PREFIXES: + if sound.begins_with(prefix): + return true + return false + + +## Makes the Music and Effects buses if they aren't there yet, sending to Master. +static func ensure_bus(bus: String) -> int: + var index: int = AudioServer.get_bus_index(bus) + if index < 0: + AudioServer.add_bus() + index = AudioServer.bus_count - 1 + AudioServer.set_bus_name(index, bus) + AudioServer.set_bus_send(index, "Master") + return index diff --git a/src/audio/sound_bank.gd.uid b/src/audio/sound_bank.gd.uid new file mode 100644 index 0000000..52b9481 --- /dev/null +++ b/src/audio/sound_bank.gd.uid @@ -0,0 +1 @@ +uid://2tji48nqpqc4 diff --git a/src/audio/sound_director.gd b/src/audio/sound_director.gd new file mode 100644 index 0000000..839621a --- /dev/null +++ b/src/audio/sound_director.gd @@ -0,0 +1,386 @@ +## The sound of a match, heard from the camera: everything the client's world and the +## server's FX messages say happened, turned into sounds placed where they happened. +## +## - Shots, swings, where shots land and harvesting, from ClientGame.fx (NetFx). +## - Footsteps for every player walking near the listener, by what they walk on: grass, +## sand, rock, built pieces or the shallows. Landings and splashes. +## - Pieces built and broken, by material, from the world's structures. +## - The tide: a ship's bell when a phase turns, the foghorn when the sea starts to +## rise, the surge's crash, and the lighthouse tone for the last land. +## - The client's own player: hurt, and the feed's eliminations. +## - Ambience under it all: surf that grows near the water, and wind that grows with +## height and in the glide. +## +## Positional sounds play on AudioStreamPlayer3D voices at the event's position, so +## the engine pans and attenuates them against the camera's listener: gunfire and +## footsteps are heard from their direction. The rest play flat. update() fills `cues` +## with what it decided this frame, which is what the tests look at; it reads the +## world and never changes it. +class_name SoundDirector +extends Node3D + +## How many sounds can play at once, placed and flat. The oldest is cut off past it. +const VOICES_3D: int = 24 +const VOICES_2D: int = 8 +## Metres a player walks between footfalls, and the slowest speed that counts as +## walking, in metres a second. +const STRIDE_METRES: float = 1.6 +const WALK_SPEED: float = 0.8 +## A player who moves further than this in a frame was placed, not walking. +const TELEPORT_METRES: float = 6.0 +## Footsteps further than this from the listener aren't played at all. +const STEP_HEARING_METRES: float = 45.0 +## Falling faster than this (m/s) before touching ground plays a landing. +const LANDING_SPEED: float = 6.0 +## How far each kind of sound carries, in metres: where it's at half volume +## (unit_size) and where it stops (max_distance). +const CARRY: Dictionary = { + "footstep": [3.0, 45.0], + "weapon": [18.0, 600.0], + "impact": [6.0, 120.0], + "build": [6.0, 120.0], + "water": [5.0, 80.0], + "player": [4.0, 60.0], +} +## Height above the sea where the surf has faded to its quietest, in metres. +const SURF_FADE_METRES: float = 70.0 + +## What update() decided this frame: {sound, category, spatial, at, volume_db, pitch}. +var cues: Array[Dictionary] = [] +## Sounds started since the director was made. +var played: int = 0 +## Whether to actually start voices. Off, update() only fills `cues`. +var audible: bool = true +## Rain under the ambience, for weather (A6) to turn on: 0 to 1. +var rain: float = 0.0 + +var _world: Simulation = null +var _fx_seen: int = 0 +var _feed_seen: int = 0 +var _pieces: Dictionary = {} +var _players: Dictionary = {} +var _tide_phase: int = -1 +var _tide_stage: int = -1 +var _tide_tick: int = -1 +var _match_phase: int = -1 +var _own_health: int = -1 +var _voices_3d: Array[AudioStreamPlayer3D] = [] +var _voices_2d: Array[AudioStreamPlayer] = [] +var _next_3d: int = 0 +var _next_2d: int = 0 +var _ambience: Dictionary = {} + + +func _ready() -> void: + SoundBank.ensure_bus(SoundBank.EFFECTS_BUS) + for index: int in VOICES_3D: + var voice: AudioStreamPlayer3D = AudioStreamPlayer3D.new() + voice.bus = SoundBank.EFFECTS_BUS + voice.attenuation_model = AudioStreamPlayer3D.ATTENUATION_INVERSE_DISTANCE + voice.panning_strength = 1.0 + add_child(voice) + _voices_3d.append(voice) + for index: int in VOICES_2D: + var flat: AudioStreamPlayer = AudioStreamPlayer.new() + flat.bus = SoundBank.EFFECTS_BUS + add_child(flat) + _voices_2d.append(flat) + for loop: String in ["amb_surf", "amb_wind", "amb_rain"]: + var bed: AudioStreamPlayer = AudioStreamPlayer.new() + bed.bus = SoundBank.EFFECTS_BUS + bed.stream = SoundBank.stream(loop) + bed.volume_db = -80.0 + add_child(bed) + _ambience[loop] = bed + + +## One frame. `own_id` is the client's own player or 0; `listener` is where the camera is. +func update(game: ClientGame, own_id: int, listener: Vector3, delta: float) -> void: + cues.clear() + var world: Simulation = game.world + if world != _world: + _begin(world, game) + if world == null: + _set_ambience(0.0, 0.0, 0.0) + return + _hear_fx(game, world) + _hear_players(world, own_id, listener, delta) + _hear_building(world) + _hear_tide(world) + _hear_match(game, own_id, world) + _hear_ambience(world, own_id, listener, delta) + if audible: + for cue: Dictionary in cues: + _play(cue) + played += cues.size() + + +## The surface a player at `feet` is walking on: "shallows", "wood", "sand", "rock" or +## "grass". +static func surface_at(world: Simulation, feet: Vector3) -> String: + if world.water_level_at(feet) > feet.y + 0.05: + return "shallows" + var terrain: float = world.ground.terrain_height(feet.x, feet.z) + if feet.y > terrain + 0.3: + return "wood" + if world.island == null: + return "grass" + match world.island.band_at(feet.x, feet.z): + Island.Band.SEA, Island.Band.BEACH: + return "sand" + Island.Band.HIGHLAND, Island.Band.SUMMIT: + return "rock" + return "grass" + + +## The report for a shot by item code: each weapon has its own. The boathook has no +## code (it is always carried), so a negative one is its swing. +static func shot_sound(item: int) -> String: + if item < 0: + return "swing_boathook" + var def: ItemDef = ItemCatalog.get_def(item) + if def == null: + return "shot_dock_carbine" + if def.id == "powder_keg": + return "swing_boathook" + var sound: String = "shot_" + def.id + return sound if SoundBank.has(sound) else "shot_dock_carbine" + + +func _begin(world: Simulation, game: ClientGame) -> void: + _world = world + _fx_seen = game.fx_received + _feed_seen = game.feed.size() + _players.clear() + _pieces.clear() + _own_health = -1 + _tide_phase = -1 + _tide_stage = -1 + _tide_tick = -1 + _match_phase = game.match_phase + if world != null: + for piece_id: int in world.structures.pieces: + _pieces[piece_id] = _piece_record(world.structures.pieces[piece_id]) + + +func _cue(sound: String, category: String, at: Variant = null, volume_db: float = 0.0, pitch: float = 1.0) -> void: + cues.append({ + "sound": sound, "category": category, "spatial": at != null, + "at": at if at != null else Vector3.ZERO, "volume_db": volume_db, "pitch": pitch, + }) + + +func _hear_fx(game: ClientGame, world: Simulation) -> void: + var fresh: int = mini(game.fx_received - _fx_seen, game.fx.size()) + _fx_seen = game.fx_received + for index: int in range(game.fx.size() - fresh, game.fx.size()): + var record: Dictionary = game.fx[index] + var at: Vector3 = record["position"] + match int(record["kind"]): + NetFx.SHOT: + _cue(shot_sound(int(record["item"])), "weapon", at, 0.0, _wobble(record, 0.04)) + NetFx.IMPACT: + _cue(_impact_sound(record, world), "impact", at, -2.0, _wobble(record, 0.08)) + NetFx.HARVEST: + _cue("chop", "impact", at + Vector3(0.0, 1.0, 0.0), -3.0, _wobble(record, 0.08)) + + +func _impact_sound(record: Dictionary, world: Simulation) -> String: + var item: ItemDef = ItemCatalog.get_def(int(record["item"])) + if item != null and item.id == "powder_keg": + return "keg_blast" + match int(record.get("hit", Weapons.HIT_NONE)): + Weapons.HIT_PLAYER: + return "hit_player" + Weapons.HIT_PIECE: + var piece: StructureSet.Piece = world.structures.find(int(record.get("target", 0))) + if piece != null and piece.material == Materials.STONE: + return "hit_stone" + if piece != null and piece.material == Materials.SALVAGE_IRON: + return "hit_iron" + return "hit_wood" + Weapons.HIT_PROP: + return "hit_wood" + return "hit_ground" + + +## A small, repeatable pitch change per event, so a burst of the same sound doesn't +## sound like one sample. +static func _wobble(record: Dictionary, spread: float) -> float: + var h: int = hash([record.get("tick", 0), record.get("player", 0), record.get("kind", 0)]) + return 1.0 + spread * (float(h % 1000) / 500.0 - 1.0) + + +func _hear_players(world: Simulation, own_id: int, listener: Vector3, delta: float) -> void: + var seen: Dictionary = {} + for entity: SimEntity in world.entities.entities(): + if entity.archetype != SimEntity.ARCHETYPE_PLAYER: + continue + seen[entity.id] = true + var was: Dictionary = _players.get(entity.id, {}) + _players[entity.id] = { + "at": entity.position, "on_ground": entity.on_ground, "swimming": entity.swimming, + "fall": was.get("fall", 0.0), "walked": was.get("walked", 0.0), "foot": was.get("foot", 1), + } + var now: Dictionary = _players[entity.id] + if was.is_empty() or entity.eliminated or entity.drop_state == Drop.ABOARD: + continue + var moved: Vector3 = entity.position - Vector3(was["at"]) + if moved.length() > TELEPORT_METRES: + continue + var near: bool = entity.position.distance_to(listener) <= STEP_HEARING_METRES or entity.id == own_id + var dt: float = maxf(delta, 0.0001) + # How fast they were falling, kept while in the air, for the landing. + if not entity.on_ground: + now["fall"] = maxf(float(was.get("fall", 0.0)), -moved.y / dt) + if entity.swimming and not bool(was["swimming"]): + if near: + _cue("splash", "water", entity.position, 0.0) + now["walked"] = 0.0 + continue + if entity.on_ground and not bool(was["on_ground"]) and not entity.swimming: + if near and float(was.get("fall", 0.0)) >= LANDING_SPEED: + _cue("land", "footstep", entity.position, 0.0) + now["fall"] = 0.0 + now["walked"] = 0.0 + continue + var horizontal: float = Vector2(moved.x, moved.z).length() + if horizontal / dt < WALK_SPEED or not (entity.on_ground or entity.swimming): + continue + now["walked"] = float(was["walked"]) + horizontal + var stride: float = STRIDE_METRES * (1.6 if entity.swimming else 1.0) * (0.75 if entity.crouching else 1.0) + if float(now["walked"]) < stride: + continue + now["walked"] = float(now["walked"]) - stride + now["foot"] = 3 - int(was["foot"]) + if not near: + continue + if entity.swimming: + _cue("swim", "water", entity.position, -4.0) + else: + var sound: String = "step_%s_%d" % [surface_at(world, entity.position), now["foot"]] + _cue(sound, "footstep", entity.position, -4.0 if entity.crouching else 0.0) + for entity_id: int in _players.keys(): + if not seen.has(entity_id): + _players.erase(entity_id) + + +func _piece_record(piece: StructureSet.Piece) -> Array: + var centre: Vector3 = piece.boxes[0].get_center() if not piece.boxes.is_empty() else Vector3.ZERO + return [piece.material, centre] + + +func _hear_building(world: Simulation) -> void: + var pieces: Dictionary = world.structures.pieces + for piece_id: int in pieces: + if not _pieces.has(piece_id): + var record: Array = _piece_record(pieces[piece_id]) + _pieces[piece_id] = record + _cue("build_" + Materials.NAMES[clampi(int(record[0]), 0, 2)], "build", record[1]) + for piece_id: int in _pieces.keys(): + if not pieces.has(piece_id): + var gone: Array = _pieces[piece_id] + _pieces.erase(piece_id) + _cue("break_" + Materials.NAMES[clampi(int(gone[0]), 0, 2)], "build", gone[1]) + + +func _hear_tide(world: Simulation) -> void: + if world.tide == null: + return + var tick: int = world.tick + var phase: int = world.tide.phase_at(tick) + var stage: int = world.tide.stage_at(tick) + if _tide_tick >= 0 and tick > _tide_tick: + if stage == Tide.SUDDEN_DEATH and _tide_stage != Tide.SUDDEN_DEATH: + _cue("lighthouse", "tide") + elif stage == Tide.RISE and _tide_stage == Tide.HOLD: + _cue("foghorn", "tide") + elif phase != _tide_phase and stage == Tide.HOLD: + _cue("bell", "tide") + # A surge can start on any tick since the last frame. + for t: int in range(maxi(_tide_tick + 1, tick - 64), tick + 1): + if world.tide.surge_starts(t): + _cue("surge", "tide") + break + _tide_tick = tick + _tide_phase = phase + _tide_stage = stage + + +func _hear_match(game: ClientGame, own_id: int, world: Simulation) -> void: + if game.match_phase != _match_phase: + if game.match_phase == Match.DROP or game.match_phase == Match.RESULTS: + _cue("bell", "tide", null, -4.0) + _match_phase = game.match_phase + if game.feed.size() > _feed_seen: + _cue("eliminated", "player", null, -2.0) + _feed_seen = game.feed.size() + var me: SimEntity = world.entities.find(own_id) if own_id != 0 else null + if me == null: + _own_health = -1 + return + if _own_health >= 0 and me.health < _own_health and not me.eliminated: + _cue("hurt", "player", null, 0.0) + _own_health = me.health + + +func _hear_ambience(world: Simulation, own_id: int, listener: Vector3, _delta: float) -> void: + var above_sea: float = maxf(listener.y - world.sea_level, 0.0) + var surf: float = clampf(1.0 - above_sea / SURF_FADE_METRES, 0.15, 1.0) + var wind: float = clampf(0.25 + above_sea / 120.0, 0.25, 1.0) + var me: SimEntity = world.entities.find(own_id) if own_id != 0 else null + if me != null and (me.drop_state == Drop.FREEFALL or me.drop_state == Drop.GLIDING): + wind = 1.0 + _set_ambience(surf, wind, rain) + + +func _set_ambience(surf: float, wind: float, wet: float) -> void: + var levels: Dictionary = {"amb_surf": surf, "amb_wind": wind, "amb_rain": wet} + for loop: String in _ambience: + var bed: AudioStreamPlayer = _ambience[loop] + var level: float = float(levels[loop]) + bed.volume_db = linear_to_db(maxf(level, 0.0001)) + if not audible or bed.stream == null: + continue + if level > 0.001 and not bed.playing: + bed.play() + elif level <= 0.001 and bed.playing: + bed.stop() + + +## The ambience's volume per loop, 0 to 1, as last set. +func ambience_level(loop: String) -> float: + var bed: AudioStreamPlayer = _ambience.get(loop) + return db_to_linear(bed.volume_db) if bed != null else 0.0 + + +func _play(cue: Dictionary) -> void: + var stream: AudioStream = SoundBank.stream(String(cue["sound"])) + if stream == null: + return + if bool(cue["spatial"]): + var voice: AudioStreamPlayer3D = _voices_3d[_next_3d] + _next_3d = (_next_3d + 1) % _voices_3d.size() + var carry: Array = CARRY.get(String(cue["category"]), [6.0, 120.0]) + voice.unit_size = float(carry[0]) + voice.max_distance = float(carry[1]) + voice.global_position = cue["at"] + voice.stream = stream + voice.volume_db = float(cue["volume_db"]) + voice.pitch_scale = float(cue["pitch"]) + voice.play() + else: + var flat: AudioStreamPlayer = _voices_2d[_next_2d] + _next_2d = (_next_2d + 1) % _voices_2d.size() + flat.stream = stream + flat.volume_db = float(cue["volume_db"]) + flat.pitch_scale = float(cue["pitch"]) + flat.play() + + +## The placed voice that last played `sound`, or null: for tests. +func voice_playing(sound: String) -> AudioStreamPlayer3D: + for voice: AudioStreamPlayer3D in _voices_3d: + if voice.stream != null and voice.stream == SoundBank.stream(sound): + return voice + return null diff --git a/src/audio/sound_director.gd.uid b/src/audio/sound_director.gd.uid new file mode 100644 index 0000000..9e63a5d --- /dev/null +++ b/src/audio/sound_director.gd.uid @@ -0,0 +1 @@ +uid://dryqmjgtmtbud diff --git a/src/client/game_settings.gd b/src/client/game_settings.gd index ac014ba..d20fc4c 100644 --- a/src/client/game_settings.gd +++ b/src/client/game_settings.gd @@ -141,12 +141,7 @@ func apply_to_program(tree: SceneTree) -> void: ## there yet (A8's sounds play on them). func _apply_audio() -> void: for bus: Array in [["Master", master_volume], ["Music", music_volume], ["Effects", effects_volume]]: - var index: int = AudioServer.get_bus_index(bus[0]) - if index < 0: - AudioServer.add_bus() - index = AudioServer.bus_count - 1 - AudioServer.set_bus_name(index, bus[0]) - AudioServer.set_bus_send(index, "Master") + var index: int = AudioServer.get_bus_index(bus[0]) if bus[0] == "Master" else SoundBank.ensure_bus(bus[0]) var volume: float = float(bus[1]) AudioServer.set_bus_mute(index, volume <= 0.0) AudioServer.set_bus_volume_db(index, linear_to_db(maxf(volume, 0.0001))) diff --git a/test/audio/test_audio_assets.gd b/test/audio/test_audio_assets.gd new file mode 100644 index 0000000..2addde9 --- /dev/null +++ b/test/audio/test_audio_assets.gd @@ -0,0 +1,86 @@ +extends TestCase + +## A8: every sound is generated by the scripts in tools/audio/, the files in +## assets/audio/ are exactly what those scripts make, and they pass the loudness rules. + +const Bake = preload("res://tools/audio/bake.gd") +const Check = preload("res://tools/audio/check.gd") +const Loudness = preload("res://tools/audio/loudness.gd") +const Wav = preload("res://tools/audio/wav.gd") + + +func test_the_files_pass_the_loudness_check() -> void: + var found: Array[String] = Check.problems() + assert_eq(found, [] as Array[String], "\n".join(found)) + + +func test_every_file_regenerates_byte_for_byte() -> void: + var manifest: Dictionary = Bake.read_manifest() + for sound: String in Bake.names(): + var baked: Dictionary = Bake.bake(sound) + assert_eq(baked["entry"]["sha256"], manifest.get(sound, {}).get("sha256", ""), "%s regenerates to the committed file" % sound) + + +func test_nothing_in_the_folder_comes_from_elsewhere() -> void: + var names: Array[String] = Bake.names() + for file: String in DirAccess.get_files_at(Bake.OUT_DIR): + if file.ends_with(".import") or file == "manifest.json": + continue + assert_true(file.ends_with(".wav"), "%s is a generated WAV" % file) + assert_true(names.has(file.get_basename()), "%s is made by a recipe" % file) + + +func test_provenance_names_the_generators() -> void: + var provenance: String = FileAccess.get_file_as_string("res://assets/PROVENANCE.md") + for script: String in ["tools/audio/recipes.gd", "tools/audio/score.gd", "tools/audio/generate.gd"]: + assert_true(provenance.contains(script), "PROVENANCE.md names %s" % script) + + +func test_every_sound_loads_and_loops_only_where_it_should() -> void: + for sound: String in Bake.names(): + var stream: AudioStreamWAV = SoundBank.stream(sound) as AudioStreamWAV + assert_not_null(stream, "%s loads" % sound) + if stream == null: + continue + assert_eq(stream.loop_mode != AudioStreamWAV.LOOP_DISABLED, Bake.loops(sound), "%s loops only if it should" % sound) + assert_near(stream.get_length(), float(Bake.read_manifest()[sound]["seconds"]), 0.01, "%s's length" % sound) + SoundBank.clear() + + +func test_the_mix_puts_the_tide_on_top() -> void: + var manifest: Dictionary = Bake.read_manifest() + var loudest_other: float = -180.0 + var quietest_tide: float = 0.0 + for sound: String in manifest: + var level: float = float(manifest[sound]["loudness_db"]) + if manifest[sound]["category"] == "tide": + quietest_tide = minf(quietest_tide, level) + else: + loudest_other = maxf(loudest_other, level) + assert_true(quietest_tide > loudest_other, "the foghorn, bell, surge and lighthouse are the loudest sounds") + + +func test_the_loudness_rules_catch_bad_levels() -> void: + assert_eq(Loudness.problems("x", -0.2, -12.0, -12.0).size(), 1, "a peak over the ceiling") + assert_eq(Loudness.problems("x", -6.0, -9.0, -12.0).size(), 1, "too loud") + assert_eq(Loudness.problems("x", -6.0, -16.0, -12.0).size(), 1, "too quiet without being held by the peak") + assert_eq(Loudness.problems("x", -1.05, -14.0, -12.0).size(), 0, "held down a little by the peak ceiling") + assert_eq(Loudness.problems("x", -3.0, -12.4, -12.0).size(), 0, "on target") + var mix: Array[String] = Loudness.mix_problems({ + "horn": {"category": "tide", "loudness": -14.0}, + "gun": {"category": "weapon", "loudness": -13.0}, + "wind": {"category": "ambience", "loudness": -20.0}, + }) + assert_eq(mix.size(), 1, "a gun as loud as the tide is caught: %s" % [mix]) + + +func test_wav_round_trip() -> void: + var samples: PackedFloat32Array = PackedFloat32Array([0.0, 0.5, -0.5, 1.0, -1.0]) + var bytes: PackedByteArray = Wav.encode(samples) + assert_eq(bytes.size(), 44 + 10) + assert_eq(Wav.rate_of(bytes), 22050) + var back: PackedFloat32Array = Wav.decode(bytes) + assert_eq(back.size(), 5) + for i: int in 5: + assert_near(back[i], samples[i], 0.0001) + assert_eq(Wav.decode(PackedByteArray([1, 2, 3])).size(), 0, "not a WAV") diff --git a/test/audio/test_audio_assets.gd.uid b/test/audio/test_audio_assets.gd.uid new file mode 100644 index 0000000..c55c9f6 --- /dev/null +++ b/test/audio/test_audio_assets.gd.uid @@ -0,0 +1 @@ +uid://cugkr67rsrrtd diff --git a/test/audio/test_music_director.gd b/test/audio/test_music_director.gd new file mode 100644 index 0000000..3914e98 --- /dev/null +++ b/test/audio/test_music_director.gd @@ -0,0 +1,60 @@ +extends TestCase + +## A8: the score builds with the tide, quiet in play and full in menus and results. + +var tree: SceneTree + + +func before_each() -> void: + super.before_each() + tree = Engine.get_main_loop() as SceneTree + + +func _game(phase: int, tide_tick: int = -1) -> ClientGame: + var game: ClientGame = ClientGame.new() + game.world = Simulation.new(3, SimGround.flat(0.0)) + game.match_phase = phase + if tide_tick >= 0: + game.world.tide = Tide.new(0) + game.world.tick = tide_tick + return game + + +func test_intensity_by_moment() -> void: + assert_eq(MusicDirector.intensity_for(null), 3, "menus are fullest") + assert_eq(MusicDirector.intensity_for(_game(Match.LOBBY)), 1) + assert_eq(MusicDirector.intensity_for(_game(Match.RESULTS)), 3) + var tide: Tide = Tide.new(0) + assert_eq(MusicDirector.intensity_for(_game(Match.PLAY, 10)), 0, "a holding tide: the drone alone") + var rising: int = tide.ticks_until_rise(0) + 5 + assert_eq(MusicDirector.intensity_for(_game(Match.PLAY, rising)), 1, "the drum comes in as the sea rises") + var levels: Array[int] = [] + var tick: int = 0 + while tide.stage_at(tick) != Tide.SUDDEN_DEATH: + levels.append(MusicDirector.intensity_for(_game(Match.PLAY, tick))) + tick += Tuning.TICK_RATE_HZ * 5 + levels.append(MusicDirector.intensity_for(_game(Match.PLAY, tick))) + for index: int in range(1, levels.size()): + assert_true(levels[index] >= levels[index - 1], "never falls back as the tide goes on: %s" % [levels]) + assert_eq(levels[levels.size() - 1], 3, "the whole tune for the last land") + assert_true(levels.has(2), "the concertina in the middle phases") + + +func test_layers_fade_toward_the_intensity_and_play_on_the_music_bus() -> void: + var music: MusicDirector = MusicDirector.new() + tree.root.add_child(music) + assert_eq(String(music.player.bus), SoundBank.MUSIC_BUS) + assert_true(music.player.stream is AudioStreamSynchronized) + var game: ClientGame = _game(Match.PLAY, 10) + music.update(game, 1.0) + assert_near(music.gains[0], 1.0 / MusicDirector.FADE_SECONDS, 0.001, "fading, not switching") + for frame: int in 10: + music.update(game, 1.0) + assert_eq(Array(music.gains), [1.0, 0.0, 0.0, 0.0]) + assert_true(music.in_match) + for frame: int in 10: + music.update(null, 1.0) + assert_eq(Array(music.gains), [1.0, 1.0, 1.0, 1.0], "menus have everything") + assert_false(music.in_match) + music.free() + SoundBank.clear() diff --git a/test/audio/test_music_director.gd.uid b/test/audio/test_music_director.gd.uid new file mode 100644 index 0000000..b85f995 --- /dev/null +++ b/test/audio/test_music_director.gd.uid @@ -0,0 +1 @@ +uid://cpmcgkhsonldp diff --git a/test/audio/test_sound_director.gd b/test/audio/test_sound_director.gd new file mode 100644 index 0000000..b70aba4 --- /dev/null +++ b/test/audio/test_sound_director.gd @@ -0,0 +1,231 @@ +extends TestCase + +## A8: what the match sounds like, from the client's world. Sounds are placed where they +## happen (so they are heard from that direction), and each event picks its own sound. + +const FRAME: float = 1.0 / 60.0 + +var tree: SceneTree +var director: SoundDirector +var game: ClientGame +var world: Simulation + + +func before_each() -> void: + super.before_each() + tree = Engine.get_main_loop() as SceneTree + director = SoundDirector.new() + tree.root.add_child(director) + game = ClientGame.new() + world = Simulation.new(5, SimGround.flat(0.0)) + world.sea_level = -5.0 + game.world = world + game.match_phase = Match.PLAY + director.update(game, 0, Vector3.ZERO, FRAME) + + +func after_each() -> void: + director.free() + SoundBank.clear() + super.after_each() + + +func _sounds() -> Array[String]: + var out: Array[String] = [] + for cue: Dictionary in director.cues: + out.append(String(cue["sound"])) + return out + + +func _player(at: Vector3) -> SimEntity: + var player: SimEntity = world.entities.find(world.add_player()) + player.position = at + player.on_ground = true + player.drop_state = Drop.NONE + player.health = 100 + return player + + +func _fx(record: Dictionary) -> void: + game.fx.append(record) + game.fx_received += 1 + + +func test_a_shot_is_placed_where_it_was_fired_with_that_weapons_report() -> void: + var at: Vector3 = Vector3(30.0, 2.0, -12.0) + _fx({"kind": NetFx.SHOT, "tick": 1, "player": 1, "item": ItemCatalog.code_of("whalers_longgun"), "position": at}) + director.update(game, 0, Vector3.ZERO, FRAME) + assert_eq(_sounds(), ["shot_whalers_longgun"] as Array[String]) + assert_true(bool(director.cues[0]["spatial"]), "positional") + var voice: AudioStreamPlayer3D = director.voice_playing("shot_whalers_longgun") + assert_not_null(voice, "played on a 3D voice") + assert_eq(voice.global_position, at, "at the muzzle, so the engine pans it from there") + assert_true(voice.max_distance >= 400.0, "gunfire carries") + director.update(game, 0, Vector3.ZERO, FRAME) + assert_eq(director.cues.size(), 0, "each FX record is heard once") + + +func test_each_weapon_has_its_own_report() -> void: + var seen: Dictionary = {} + for id: String in ["fowling_piece", "dock_carbine", "signal_revolver", "rivet_repeater", "whalers_longgun", "line_thrower", "harpoon_gun"]: + var sound: String = SoundDirector.shot_sound(ItemCatalog.code_of(id)) + assert_eq(sound, "shot_" + id) + assert_true(SoundBank.has(sound), "%s exists" % sound) + seen[sound] = true + assert_eq(SoundDirector.shot_sound(-1), "swing_boathook", "the boathook, which has no item code") + assert_eq(SoundDirector.shot_sound(250), "shot_dock_carbine", "an unknown code still makes a sound") + + +func test_impacts_sound_like_what_was_hit() -> void: + var stone: StructureSet.Piece = world.structures.add(StructureSet.WALL, Materials.STONE, Vector4i(10, 0, 10, StructureSet.SLOT_WALL_X), 0, 0, 0, world.ground) + director.update(game, 0, Vector3.ZERO, FRAME) + var cases: Array = [ + [Weapons.HIT_PIECE, stone.id, "hit_stone"], [Weapons.HIT_PLAYER, 3, "hit_player"], + [Weapons.HIT_PROP, 4, "hit_wood"], [Weapons.HIT_TERRAIN, 0, "hit_ground"], + ] + for entry: Array in cases: + _fx({"kind": NetFx.IMPACT, "tick": 2, "player": 1, "item": ItemCatalog.code_of("dock_carbine"), "position": Vector3(1, 1, 1), "hit": entry[0], "target": entry[1]}) + director.update(game, 0, Vector3.ZERO, FRAME) + assert_eq(_sounds(), [entry[2]] as Array[String]) + _fx({"kind": NetFx.HARVEST, "tick": 3, "player": 1, "item": -1, "position": Vector3.ZERO}) + director.update(game, 0, Vector3.ZERO, FRAME) + assert_eq(_sounds(), ["chop"] as Array[String]) + + +func _walk(player: SimEntity, velocity: Vector3, seconds: float, listener: Vector3 = Vector3.ZERO) -> Array[String]: + var heard: Array[String] = [] + for frame: int in int(seconds / FRAME): + player.position += velocity * FRAME + director.update(game, player.id, listener, FRAME) + heard.append_array(_sounds()) + return heard + + +func test_footsteps_follow_the_stride_and_alternate_feet() -> void: + var player: SimEntity = _player(Vector3(5.0, 0.0, 5.0)) + director.update(game, player.id, Vector3.ZERO, FRAME) + var heard: Array[String] = _walk(player, Vector3(5.0, 0.0, 0.0), 2.0) + # 10 m at a 1.6 m stride. + assert_eq(heard.size(), 6, "%s" % [heard]) + assert_eq(heard[0], "step_grass_2") + assert_eq(heard[1], "step_grass_1") + for cue: Dictionary in director.cues: + assert_true(bool(cue["spatial"])) + var standing: Array[String] = _walk(player, Vector3.ZERO, 1.0) + assert_eq(standing.size(), 0, "standing still is silent") + + +func test_footsteps_know_the_surface() -> void: + var player: SimEntity = _player(Vector3(5.0, 2.0, 5.0)) + director.update(game, player.id, Vector3.ZERO, FRAME) + var on_planks: Array[String] = _walk(player, Vector3(4.0, 0.0, 0.0), 1.0) + assert_true(on_planks.size() > 0 and on_planks[0].begins_with("step_wood"), "above the ground means on a built piece: %s" % [on_planks]) + player.position.y = 0.0 + world.sea_level = 0.4 + director.update(game, player.id, Vector3.ZERO, FRAME) + var wading: Array[String] = _walk(player, Vector3(4.0, 0.0, 0.0), 1.0) + assert_true(wading.size() > 0 and wading[0].begins_with("step_shallows"), "%s" % [wading]) + + +func test_footsteps_on_a_real_island_by_band() -> void: + var island_world: Simulation = Simulation.new(2) + var found: Dictionary = {} + var size: float = Tuning.WORLD_SIZE_METRES + for gz: int in 60: + for gx: int in 60: + var x: float = size * (gx + 0.5) / 60.0 + var z: float = size * (gz + 0.5) / 60.0 + var feet: Vector3 = Vector3(x, island_world.ground.terrain_height(x, z), z) + if feet.y <= island_world.sea_level + 0.1: + continue + found[SoundDirector.surface_at(island_world, feet)] = true + for surface: String in ["sand", "grass", "rock"]: + assert_true(found.has(surface), "the island has %s to walk on: %s" % [surface, found.keys()]) + + +func test_far_footsteps_are_not_heard_but_near_ones_are() -> void: + var far: SimEntity = _player(Vector3(200.0, 0.0, 200.0)) + var near: SimEntity = _player(Vector3(10.0, 0.0, 0.0)) + director.update(game, 0, Vector3.ZERO, FRAME) + var heard: int = 0 + for frame: int in 120: + far.position.x += 5.0 * FRAME + near.position.z += 5.0 * FRAME + director.update(game, 0, Vector3.ZERO, FRAME) + for cue: Dictionary in director.cues: + heard += 1 + assert_true(Vector3(cue["at"]).distance_to(near.position) < 1.0, "only the near player's steps") + assert_eq(heard, 6) + + +func test_landing_and_splashing() -> void: + var player: SimEntity = _player(Vector3(0.0, 10.0, 0.0)) + player.on_ground = false + director.update(game, player.id, Vector3.ZERO, FRAME) + _walk(player, Vector3(0.0, -12.0, 0.0), 0.5) + player.on_ground = true + assert_eq(_walk(player, Vector3.ZERO, FRAME), ["land"] as Array[String]) + player.swimming = true + assert_eq(_walk(player, Vector3.ZERO, FRAME), ["splash"] as Array[String]) + + +func test_building_and_breaking_by_material() -> void: + var piece: StructureSet.Piece = world.structures.add(StructureSet.FLOOR, Materials.SALVAGE_IRON, Vector4i(20, 0, 20, StructureSet.SLOT_FLOOR), 0, 0, 0, world.ground) + director.update(game, 0, Vector3.ZERO, FRAME) + assert_eq(_sounds(), ["build_salvage_iron"] as Array[String]) + assert_true(Vector3(director.cues[0]["at"]).distance_to(piece.boxes[0].get_center()) < 0.01, "at the piece") + world.structures.remove(piece.id, world.ground) + director.update(game, 0, Vector3.ZERO, FRAME) + assert_eq(_sounds(), ["break_salvage_iron"] as Array[String]) + + +func test_the_tide_rings_and_sounds_its_horn() -> void: + world.tide = Tide.new(0) + world.tick = 1 + director.update(game, 0, Vector3.ZERO, FRAME) + assert_eq(_sounds(), [] as Array[String], "nothing on the first look") + world.tick = world.tide.ticks_until_rise(1) + 2 + director.update(game, 0, Vector3.ZERO, FRAME) + assert_true(_sounds().has("foghorn"), "the sea starts to rise: %s" % [_sounds()]) + var heard: Dictionary = {} + while world.tide.stage_at(world.tick) != Tide.SUDDEN_DEATH: + world.tick += 20 + director.update(game, 0, Vector3.ZERO, FRAME) + for sound: String in _sounds(): + heard[sound] = int(heard.get(sound, 0)) + 1 + assert_eq(int(heard.get("foghorn", 0)), Tide.phase_count() - 1, "a horn for each later rise: %s" % [heard]) + assert_eq(int(heard.get("bell", 0)), Tide.phase_count() - 1, "a bell as each new phase holds") + assert_eq(int(heard.get("lighthouse", 0)), 1, "the lighthouse for the last land") + for cue: Dictionary in director.cues: + assert_false(bool(cue["spatial"]), "the tide is everywhere") + + +func test_own_hurt_and_the_feed() -> void: + var me: SimEntity = _player(Vector3.ZERO) + director.update(game, me.id, Vector3.ZERO, FRAME) + me.health = 70 + director.update(game, me.id, Vector3.ZERO, FRAME) + assert_eq(_sounds(), ["hurt"] as Array[String]) + game.feed.append({"victim": 9, "by": 3, "place": 12}) + director.update(game, me.id, Vector3.ZERO, FRAME) + assert_eq(_sounds(), ["eliminated"] as Array[String]) + + +func test_a_new_world_starts_quietly() -> void: + world.structures.add(StructureSet.FLOOR, Materials.STONE, Vector4i(20, 0, 20, StructureSet.SLOT_FLOOR), 0, 0, 0, world.ground) + _fx({"kind": NetFx.SHOT, "tick": 1, "player": 1, "item": 0, "position": Vector3.ZERO}) + var next: Simulation = Simulation.new(6, SimGround.flat(0.0)) + next.structures.add(StructureSet.FLOOR, Materials.STONE, Vector4i(20, 0, 20, StructureSet.SLOT_FLOOR), 0, 0, 0, next.ground) + game.world = next + director.update(game, 0, Vector3.ZERO, FRAME) + assert_eq(_sounds(), [] as Array[String], "what was there before the client looked isn't news") + + +func test_ambience_surf_near_the_water_and_wind_up_high() -> void: + director.update(game, 0, Vector3(0.0, world.sea_level + 2.0, 0.0), FRAME) + var low_surf: float = director.ambience_level("amb_surf") + var low_wind: float = director.ambience_level("amb_wind") + director.update(game, 0, Vector3(0.0, world.sea_level + 90.0, 0.0), FRAME) + assert_true(low_surf > director.ambience_level("amb_surf") * 2.0, "the surf fades with height") + assert_true(director.ambience_level("amb_wind") > low_wind * 2.0, "the wind grows with height") + assert_near(director.ambience_level("amb_rain"), 0.0, 0.001, "no rain until weather asks for it") diff --git a/test/audio/test_sound_director.gd.uid b/test/audio/test_sound_director.gd.uid new file mode 100644 index 0000000..ffb31fd --- /dev/null +++ b/test/audio/test_sound_director.gd.uid @@ -0,0 +1 @@ +uid://cekbfmiu1xq3s diff --git a/test/ui/test_menus.gd b/test/ui/test_menus.gd index a458136..2b5eeb6 100644 --- a/test/ui/test_menus.gd +++ b/test/ui/test_menus.gd @@ -263,3 +263,21 @@ func _press_in(on: Menus, screen: String, text: String) -> void: assert_true(buttons.has(text), "%s has a '%s' button (has %s)" % [screen, text, buttons.keys()]) if buttons.has(text): (buttons[text] as Button).pressed.emit() + + +func test_menu_buttons_knock_when_pointed_at_and_pressed() -> void: + var sounds: MenuSounds = MenuSounds.new() + tree.root.add_child(sounds) + sounds.attach(menus) + var main: Dictionary = menus.buttons_of("main") + var first: Button = main.values()[0] + first.mouse_entered.emit() + assert_eq(sounds.heard.back(), "ui_hover") + var later: Button = Button.new() + later.text = "Back" + menus.add_child(later) + later.pressed.emit() + assert_eq(sounds.heard.back(), "ui_back", "a button made later is hooked too") + sounds.free() + later.free() + SoundBank.clear() diff --git a/tools/audio/bake.gd b/tools/audio/bake.gd new file mode 100644 index 0000000..b3fb0d0 --- /dev/null +++ b/tools/audio/bake.gd @@ -0,0 +1,91 @@ +## Renders, levels and encodes every generated sound: the effects in recipes.gd and the +## score's layers in score.gd. Used by generate.gd to write assets/audio/, and by +## check.gd and the tests to prove the files there are what the source makes. +extends RefCounted + +const Dsp = preload("res://tools/audio/dsp.gd") +const Recipes = preload("res://tools/audio/recipes.gd") +const Score = preload("res://tools/audio/score.gd") +const Wav = preload("res://tools/audio/wav.gd") +const Loudness = preload("res://tools/audio/loudness.gd") + +const OUT_DIR: String = "res://assets/audio" +const MANIFEST: String = "res://assets/audio/manifest.json" + + +static func names() -> Array[String]: + var out: Array[String] = [] + for sound: String in Recipes.SOUNDS: + out.append(sound) + out.append_array(Score.LAYERS) + return out + + +static func category(sound: String) -> String: + return "music" if Score.LAYERS.has(sound) else String(Recipes.SOUNDS[sound][0]) + + +static func loops(sound: String) -> bool: + return Score.LAYERS.has(sound) or bool(Recipes.SOUNDS[sound][1]) + + +static func target(sound: String) -> float: + if Score.TARGETS.has(sound): + return float(Score.TARGETS[sound]) + return float(Recipes.TARGETS[category(sound)]) + + +static func generator(sound: String) -> String: + return "tools/audio/score.gd" if Score.LAYERS.has(sound) else "tools/audio/recipes.gd" + + +static func path(sound: String) -> String: + return "%s/%s.wav" % [OUT_DIR, sound] + + +## The levelled samples for a sound. +static func render(sound: String) -> PackedFloat32Array: + var raw: PackedFloat32Array = Score.render(sound) if Score.LAYERS.has(sound) else Recipes.render(sound) + var gain_db: float = target(sound) - Loudness.loudness_db(raw, loops(sound)) + var leveled: PackedFloat32Array = Dsp.scaled(raw, pow(10.0, gain_db / 20.0)) + # Sharp transients would hold a sound under its target at the peak ceiling, so + # round their peaks off with a soft limiter first, as a mastering limiter would. + var ceiling: float = pow(10.0, Loudness.PEAK_CEILING_DB / 20.0) + if Loudness.peak_db(leveled) > Loudness.PEAK_CEILING_DB: + for i: int in leveled.size(): + leveled[i] = ceiling * tanh(leveled[i] / ceiling) + return Dsp.scaled(leveled, Loudness.levelling_gain(leveled, loops(sound), target(sound))) + + +## The file's bytes and its manifest entry. +static func bake(sound: String) -> Dictionary: + var samples: PackedFloat32Array = render(sound) + var bytes: PackedByteArray = Wav.encode(samples) + # Measure what the file holds, after 16-bit rounding. + var stored: PackedFloat32Array = Wav.decode(bytes) + return { + "bytes": bytes, + "entry": { + "category": category(sound), + "loops": loops(sound), + "seconds": snappedf(float(stored.size()) / Dsp.RATE, 0.001), + "sha256": sha256(bytes), + "peak_db": snappedf(Loudness.peak_db(stored), 0.01), + "loudness_db": snappedf(Loudness.loudness_db(stored, loops(sound)), 0.01), + "target_db": target(sound), + "generator": generator(sound), + }, + } + + +static func sha256(bytes: PackedByteArray) -> String: + var hasher: HashingContext = HashingContext.new() + hasher.start(HashingContext.HASH_SHA256) + hasher.update(bytes) + return hasher.finish().hex_encode() + + +static func read_manifest() -> Dictionary: + var text: String = FileAccess.get_file_as_string(MANIFEST) + var parsed: Variant = JSON.parse_string(text) + return parsed if parsed is Dictionary else {} diff --git a/tools/audio/bake.gd.uid b/tools/audio/bake.gd.uid new file mode 100644 index 0000000..6ee6bc5 --- /dev/null +++ b/tools/audio/bake.gd.uid @@ -0,0 +1 @@ +uid://rbirp8dh2jcc diff --git a/tools/audio/check.gd b/tools/audio/check.gd new file mode 100644 index 0000000..febe7fb --- /dev/null +++ b/tools/audio/check.gd @@ -0,0 +1,44 @@ +## Checks the generated audio: every sound the source defines has a file and a manifest +## entry, every file's hash matches its entry, and every file passes the loudness rules +## in loudness.gd, measured from the file itself. Exits 1 on any problem. +## +## tools/godot.sh --script res://tools/audio/check.gd +extends SceneTree + +const Bake = preload("res://tools/audio/bake.gd") +const Wav = preload("res://tools/audio/wav.gd") +const Loudness = preload("res://tools/audio/loudness.gd") + + +static func problems() -> Array[String]: + var found: Array[String] = [] + var manifest: Dictionary = Bake.read_manifest() + var measured: Dictionary = {} + for sound: String in Bake.names(): + if not manifest.has(sound): + found.append("%s has no manifest entry" % sound) + continue + var bytes: PackedByteArray = FileAccess.get_file_as_bytes(Bake.path(sound)) + if bytes.is_empty(): + found.append("%s has no file at %s" % [sound, Bake.path(sound)]) + continue + if Bake.sha256(bytes) != String(manifest[sound]["sha256"]): + found.append("%s's file doesn't match its manifest hash" % sound) + var samples: PackedFloat32Array = Wav.decode(bytes) + var peak: float = Loudness.peak_db(samples) + var loudness: float = Loudness.loudness_db(samples, Bake.loops(sound)) + found.append_array(Loudness.problems(sound, peak, loudness, Bake.target(sound))) + measured[sound] = {"category": Bake.category(sound), "loudness": loudness} + for sound: String in manifest: + if not Bake.names().has(sound): + found.append("%s is in the manifest but no recipe makes it" % sound) + found.append_array(Loudness.mix_problems(measured)) + return found + + +func _init() -> void: + var found: Array[String] = problems() + for line: String in found: + printerr(line) + print("audio check: %d sounds, %d problems" % [Bake.names().size(), found.size()]) + quit(1 if not found.is_empty() else 0) diff --git a/tools/audio/check.gd.uid b/tools/audio/check.gd.uid new file mode 100644 index 0000000..5b9f0a9 --- /dev/null +++ b/tools/audio/check.gd.uid @@ -0,0 +1 @@ +uid://co7rw4guwnsvp diff --git a/tools/audio/dsp.gd b/tools/audio/dsp.gd new file mode 100644 index 0000000..f4c251a --- /dev/null +++ b/tools/audio/dsp.gd @@ -0,0 +1,279 @@ +## The building blocks every Tidewall sound is made from: seeded noise, wavetable +## oscillators, filters, envelopes, decaying modes and a mixer. Buffers are mono +## PackedFloat32Array at RATE samples a second. Everything here is a pure function of +## its arguments and the seed it is given, so the same engine build renders the same +## bytes every time (see tools/audio/generate.gd and test_audio_assets). +## +## No samples, recordings or third-party audio go in: every sound starts from these +## functions. +extends RefCounted + +const RATE: int = 22050 +const TABLE_SIZE: int = 2048 + +static var _tables: Dictionary = {} + + +## Seconds to samples. +static func n(seconds: float) -> int: + return maxi(1, int(round(seconds * RATE))) + + +static func silence(seconds: float) -> PackedFloat32Array: + var out: PackedFloat32Array = PackedFloat32Array() + out.resize(n(seconds)) + out.fill(0.0) + return out + + +## White noise from a seeded generator. +static func noise(seconds: float, seed_value: int) -> PackedFloat32Array: + var rng: RandomNumberGenerator = RandomNumberGenerator.new() + rng.seed = seed_value + var out: PackedFloat32Array = PackedFloat32Array() + out.resize(n(seconds)) + for i: int in out.size(): + out[i] = rng.randf() * 2.0 - 1.0 + return out + + +## Brown-ish noise: white noise through a leaky integrator, for surf and rumble. +static func brown(seconds: float, seed_value: int) -> PackedFloat32Array: + var white: PackedFloat32Array = noise(seconds, seed_value) + var level: float = 0.0 + for i: int in white.size(): + level = level * 0.985 + white[i] * 0.12 + white[i] = level + return white + + +## One cycle of a band-limited waveform: "sine", "saw", "square", "reed" (a narrow +## pulse, like a free reed) or "bow" (a saw with softened upper partials). +static func table(shape: String) -> PackedFloat32Array: + if _tables.has(shape): + return _tables[shape] + var out: PackedFloat32Array = PackedFloat32Array() + out.resize(TABLE_SIZE) + out.fill(0.0) + var partials: int = 24 + for k: int in range(1, partials + 1): + var amp: float = 0.0 + match shape: + "sine": + amp = 1.0 if k == 1 else 0.0 + "saw": + amp = 1.0 / k + "square": + amp = (1.0 / k) if k % 2 == 1 else 0.0 + "reed": + # A pulse of width 1/5: strong odd and even partials with gaps. + amp = absf(sin(PI * k * 0.2)) / k + "bow": + amp = 1.0 / pow(k, 1.35) + if amp == 0.0: + continue + for i: int in TABLE_SIZE: + out[i] += amp * sin(TAU * k * float(i) / TABLE_SIZE) + var peak: float = 0.0 + for value: float in out: + peak = maxf(peak, absf(value)) + for i: int in TABLE_SIZE: + out[i] /= peak + _tables[shape] = out + return out + + +## A wavetable oscillator. `pitch` is Hz, either a constant or a curve given as +## [start, end] gliding exponentially; `vibrato` is [rate Hz, depth in semitones]. +static func osc(shape: String, seconds: float, pitch: Array, vibrato: Array = [0.0, 0.0], phase: float = 0.0) -> PackedFloat32Array: + var wave: PackedFloat32Array = table(shape) + var count: int = n(seconds) + var out: PackedFloat32Array = PackedFloat32Array() + out.resize(count) + var start: float = float(pitch[0]) + var finish: float = float(pitch[pitch.size() - 1]) + var position: float = phase * TABLE_SIZE + for i: int in count: + var t: float = float(i) / count + var hz: float = start * pow(finish / start, t) + if vibrato[0] > 0.0: + hz *= pow(2.0, vibrato[1] * sin(TAU * vibrato[0] * float(i) / RATE) / 12.0) + var index: int = int(position) + var frac: float = position - index + var a: float = wave[index % TABLE_SIZE] + var b: float = wave[(index + 1) % TABLE_SIZE] + out[i] = a + (b - a) * frac + position = fmod(position + hz * TABLE_SIZE / RATE, float(TABLE_SIZE)) + return out + + +## One-pole low-pass, cutoff in Hz, either fixed or gliding [start, end]. +static func lowpass(input: PackedFloat32Array, cutoff: Array, passes: int = 1) -> PackedFloat32Array: + var out: PackedFloat32Array = input.duplicate() + var start: float = float(cutoff[0]) + var finish: float = float(cutoff[cutoff.size() - 1]) + for _pass: int in passes: + var state: float = 0.0 + for i: int in out.size(): + var hz: float = start * pow(finish / start, float(i) / out.size()) + var a: float = 1.0 - exp(-TAU * hz / RATE) + state += a * (out[i] - state) + out[i] = state + return out + + +static func highpass(input: PackedFloat32Array, cutoff: float) -> PackedFloat32Array: + var low: PackedFloat32Array = lowpass(input, [cutoff]) + var out: PackedFloat32Array = input.duplicate() + for i: int in out.size(): + out[i] -= low[i] + return out + + +## A resonant band-pass (RBJ biquad), centre in Hz, either fixed or gliding. +static func bandpass(input: PackedFloat32Array, centre: Array, q: float) -> PackedFloat32Array: + var out: PackedFloat32Array = PackedFloat32Array() + out.resize(input.size()) + var x1: float = 0.0 + var x2: float = 0.0 + var y1: float = 0.0 + var y2: float = 0.0 + var start: float = float(centre[0]) + var finish: float = float(centre[centre.size() - 1]) + for i: int in input.size(): + var hz: float = start * pow(finish / start, float(i) / input.size()) + var w: float = TAU * minf(hz, RATE * 0.45) / RATE + var alpha: float = sin(w) / (2.0 * q) + var a0: float = 1.0 + alpha + var b0: float = alpha / a0 + var b2: float = -alpha / a0 + var a1: float = -2.0 * cos(w) / a0 + var a2: float = (1.0 - alpha) / a0 + var x: float = input[i] + var y: float = b0 * x + b2 * x2 - a1 * y1 - a2 * y2 + x2 = x1 + x1 = x + y2 = y1 + y1 = y + out[i] = y + return out + + +## Multiplies by an exponential decay that falls 60 dB over `decay` seconds, after +## a linear attack of `attack` seconds. +static func decay(input: PackedFloat32Array, attack: float, decay_seconds: float) -> PackedFloat32Array: + var out: PackedFloat32Array = input.duplicate() + var attack_n: int = n(attack) if attack > 0.0 else 0 + var k: float = log(1000.0) / maxf(decay_seconds * RATE, 1.0) + for i: int in out.size(): + var gain: float = 1.0 + if i < attack_n: + gain = float(i) / attack_n + else: + gain = exp(-k * (i - attack_n)) + out[i] *= gain + return out + + +## Multiplies by a piecewise-linear envelope: points are [seconds, gain] in order. +static func shape(input: PackedFloat32Array, points: Array) -> PackedFloat32Array: + var out: PackedFloat32Array = input.duplicate() + var p: int = 0 + for i: int in out.size(): + var t: float = float(i) / RATE + while p < points.size() - 2 and t > float(points[p + 1][0]): + p += 1 + var t0: float = float(points[p][0]) + var t1: float = float(points[p + 1][0]) + var g0: float = float(points[p][1]) + var g1: float = float(points[p + 1][1]) + var u: float = clampf((t - t0) / maxf(t1 - t0, 0.00001), 0.0, 1.0) + out[i] *= lerpf(g0, g1, u) + return out + + +## Struck modes: a sum of decaying sines at `base` times each ratio, with gains and +## decays (seconds to -60 dB) per mode. Wood, bells, iron and drums. +static func modes(seconds: float, base: float, ratios: Array, gains: Array, decays: Array, glide: float = 1.0) -> PackedFloat32Array: + var out: PackedFloat32Array = silence(seconds) + for m: int in ratios.size(): + var hz: float = base * float(ratios[m]) + if hz >= RATE * 0.45: + continue + var tone: PackedFloat32Array = decay(osc("sine", seconds, [hz, hz * glide]), 0.0008, float(decays[m])) + mix_into(out, tone, 0, float(gains[m])) + return out + + +## Adds `source` times `gain` into `target` from sample `at`. With `wrap`, what runs +## past the end comes round to the start, for seamless loops. +static func mix_into(target: PackedFloat32Array, source: PackedFloat32Array, at: int, gain: float = 1.0, wrap: bool = false) -> void: + var size: int = target.size() + for i: int in source.size(): + var j: int = at + i + if j >= size: + if not wrap: + return + j %= size + if j < 0: + continue + target[j] += source[i] * gain + + +static func scaled(input: PackedFloat32Array, gain: float) -> PackedFloat32Array: + var out: PackedFloat32Array = input.duplicate() + for i: int in out.size(): + out[i] *= gain + return out + + +## Gentle saturation, for powder bangs and heavy hits. +static func saturate(input: PackedFloat32Array, drive: float) -> PackedFloat32Array: + var out: PackedFloat32Array = input.duplicate() + var norm: float = tanh(drive) + for i: int in out.size(): + out[i] = tanh(out[i] * drive) / norm + return out + + +## Crossfades the last `seconds` of a buffer into its start and trims them, so it loops +## without a click. +static func make_loop(input: PackedFloat32Array, seconds: float) -> PackedFloat32Array: + var fade: int = n(seconds) + var length: int = input.size() - fade + var out: PackedFloat32Array = input.slice(0, length) + for i: int in fade: + var u: float = float(i) / fade + out[i] = input[i] * sqrt(u) + input[length + i] * sqrt(1.0 - u) + return out + + +## Echoes: copies of the buffer at `delay` seconds, each `feedback` times the last, +## low-passed a little more each time. Black-powder reports off cliffs and water. +static func echo(input: PackedFloat32Array, delay_seconds: float, feedback: float, repeats: int) -> PackedFloat32Array: + var step: int = n(delay_seconds) + var out: PackedFloat32Array = input.duplicate() + out.resize(input.size() + step * repeats) + for i: int in range(input.size(), out.size()): + out[i] = 0.0 + var tap: PackedFloat32Array = input + var gain: float = 1.0 + for r: int in range(1, repeats + 1): + gain *= feedback + tap = lowpass(tap, [2400.0 / r]) + mix_into(out, tap, step * r, gain) + return out + + +## Concatenates buffers with `gap` seconds of silence between them. +static func sequence(parts: Array, gap: float) -> PackedFloat32Array: + var out: PackedFloat32Array = PackedFloat32Array() + for index: int in parts.size(): + out.append_array(parts[index]) + if index < parts.size() - 1: + out.append_array(silence(gap)) + return out + + +static func midi_hz(note: float) -> float: + return 440.0 * pow(2.0, (note - 69.0) / 12.0) diff --git a/tools/audio/dsp.gd.uid b/tools/audio/dsp.gd.uid new file mode 100644 index 0000000..2e9d39b --- /dev/null +++ b/tools/audio/dsp.gd.uid @@ -0,0 +1 @@ +uid://dchkfpfsycsy5 diff --git a/tools/audio/generate.gd b/tools/audio/generate.gd new file mode 100644 index 0000000..6761558 --- /dev/null +++ b/tools/audio/generate.gd @@ -0,0 +1,40 @@ +## Writes every generated sound to assets/audio/ and the manifest beside it. +## +## tools/godot.sh --script res://tools/audio/generate.gd [-- --only=name,name] +## +## Same engine, same bytes: test_audio_assets regenerates the files and compares. +extends SceneTree + +const Bake = preload("res://tools/audio/bake.gd") + + +func _init() -> void: + var only: PackedStringArray = PackedStringArray() + for arg: String in OS.get_cmdline_user_args(): + if arg.begins_with("--only="): + only = arg.get_slice("=", 1).split(",", false) + DirAccess.make_dir_recursive_absolute(ProjectSettings.globalize_path(Bake.OUT_DIR)) + var manifest: Dictionary = Bake.read_manifest() if not only.is_empty() else {} + var started: int = Time.get_ticks_msec() + for sound: String in Bake.names(): + if not only.is_empty() and not only.has(sound): + continue + var began: int = Time.get_ticks_msec() + var baked: Dictionary = Bake.bake(sound) + var file: FileAccess = FileAccess.open(Bake.path(sound), FileAccess.WRITE) + file.store_buffer(baked["bytes"]) + file.close() + manifest[sound] = baked["entry"] + print("%-24s %6.2f s peak %6.2f loudness %6.2f (target %6.1f) %d ms" % [ + sound, baked["entry"]["seconds"], baked["entry"]["peak_db"], baked["entry"]["loudness_db"], + baked["entry"]["target_db"], Time.get_ticks_msec() - began]) + var sorted: Dictionary = {} + var keys: Array = manifest.keys() + keys.sort() + for key: Variant in keys: + sorted[key] = manifest[key] + var out: FileAccess = FileAccess.open(Bake.MANIFEST, FileAccess.WRITE) + out.store_string(JSON.stringify(sorted, "\t", false) + "\n") + out.close() + print("generated in %d ms" % (Time.get_ticks_msec() - started)) + quit(0) diff --git a/tools/audio/generate.gd.uid b/tools/audio/generate.gd.uid new file mode 100644 index 0000000..5f7a349 --- /dev/null +++ b/tools/audio/generate.gd.uid @@ -0,0 +1 @@ +uid://cxbv0gxh0s2ur diff --git a/tools/audio/loudness.gd b/tools/audio/loudness.gd new file mode 100644 index 0000000..0db9128 --- /dev/null +++ b/tools/audio/loudness.gd @@ -0,0 +1,89 @@ +## Loudness and peak measurements for the generated audio, and the checks every asset +## must pass (tools/audio/check.gd, test_audio_assets): +## +## - the peak stays at or under PEAK_CEILING_DB, so nothing clips; +## - each sound is within TOLERANCE_DB of its target loudness, or under it only because +## the peak ceiling held it down (by no more than LIMITED_SLACK_DB); +## - the mix order from docs/STYLE.md holds: the tide's sounds are the loudest in a +## match, ambience and music sit under the effects, menus are quietest. +## +## Loudness is the RMS of the loudest WINDOW_SECONDS window for one-shots, and of the +## whole file for loops, in dBFS. That is close enough to a momentary loudness meter for +## levelling sounds against each other without a K-weighting filter. +extends RefCounted + +const Dsp = preload("res://tools/audio/dsp.gd") + +const WINDOW_SECONDS: float = 0.4 +const PEAK_CEILING_DB: float = -1.0 +const TOLERANCE_DB: float = 1.0 +const LIMITED_SLACK_DB: float = 4.0 + + +static func db(linear: float) -> float: + return 20.0 * log(maxf(linear, 1e-9)) / log(10.0) + + +static func peak_db(samples: PackedFloat32Array) -> float: + var peak: float = 0.0 + for value: float in samples: + peak = maxf(peak, absf(value)) + return db(peak) + + +static func loudness_db(samples: PackedFloat32Array, loops: bool) -> float: + if samples.is_empty(): + return -180.0 + if loops: + var total: float = 0.0 + for value: float in samples: + total += value * value + return db(sqrt(total / samples.size())) + var window: int = mini(Dsp.n(WINDOW_SECONDS), samples.size()) + var running: float = 0.0 + for i: int in window: + running += samples[i] * samples[i] + var best: float = running + for i: int in range(window, samples.size()): + running += samples[i] * samples[i] - samples[i - window] * samples[i - window] + best = maxf(best, running) + return db(sqrt(maxf(best, 0.0) / window)) + + +## The gain that brings `samples` to `target` dBFS without the peak passing the ceiling. +static func levelling_gain(samples: PackedFloat32Array, loops: bool, target: float) -> float: + var gain_db: float = target - loudness_db(samples, loops) + var headroom_db: float = PEAK_CEILING_DB - 0.05 - peak_db(samples) + return pow(10.0, minf(gain_db, headroom_db) / 20.0) + + +## Problems with one measured sound, as sentences; empty when it passes. +static func problems(sound: String, peak: float, loudness: float, target: float) -> Array[String]: + var found: Array[String] = [] + if peak > PEAK_CEILING_DB + 0.01: + found.append("%s peaks at %.2f dBFS, over the %.1f ceiling" % [sound, peak, PEAK_CEILING_DB]) + if loudness > target + TOLERANCE_DB: + found.append("%s is %.1f dBFS, louder than its %.1f target" % [sound, loudness, target]) + elif loudness < target - TOLERANCE_DB: + var limited: bool = peak >= PEAK_CEILING_DB - 0.3 + if not limited or loudness < target - LIMITED_SLACK_DB: + found.append("%s is %.1f dBFS, quieter than its %.1f target" % [sound, loudness, target]) + return found + + +## Problems with the mix as a whole, from {sound: {category, loudness}}. +static func mix_problems(measured: Dictionary) -> Array[String]: + var loudest: Dictionary = {} + for sound: String in measured: + var category: String = measured[sound]["category"] + loudest[category] = maxf(float(loudest.get(category, -180.0)), float(measured[sound]["loudness"])) + var found: Array[String] = [] + var tide: float = float(loudest.get("tide", -180.0)) + for category: String in loudest: + if category != "tide" and float(loudest[category]) >= tide: + found.append("%s (%.1f dBFS) is as loud as the tide (%.1f)" % [category, loudest[category], tide]) + for under: String in ["ambience", "music", "ui"]: + for over: String in ["weapon", "impact", "build"]: + if loudest.has(under) and loudest.has(over) and float(loudest[under]) >= float(loudest[over]): + found.append("%s should sit under %s" % [under, over]) + return found diff --git a/tools/audio/loudness.gd.uid b/tools/audio/loudness.gd.uid new file mode 100644 index 0000000..450c943 --- /dev/null +++ b/tools/audio/loudness.gd.uid @@ -0,0 +1 @@ +uid://cj5nhe3ftmwu5 diff --git a/tools/audio/recipes.gd b/tools/audio/recipes.gd new file mode 100644 index 0000000..2814cf5 --- /dev/null +++ b/tools/audio/recipes.gd @@ -0,0 +1,481 @@ +## Every Tidewall sound effect, as a recipe over tools/audio/dsp.gd. Each entry names +## its category, whether it loops, and the loudness it is levelled to. The categories +## and their targets are the mix in docs/STYLE.md: the sea always underneath, the +## tide's bell and foghorn the loudest things in a match, weapons dull thumps rather +## than sharp cracks, carpentry for building. +## +## Loudness is the loudest 400 ms window's RMS in dBFS for one-shots, and the whole +## file's RMS for loops (see tools/audio/loudness.gd). +extends RefCounted + +const Dsp = preload("res://tools/audio/dsp.gd") + +## Category -> target loudness in dBFS. +const TARGETS: Dictionary = { + "ui": -26.0, + "footstep": -24.0, + "player": -22.0, + "build": -19.0, + "impact": -19.0, + "weapon": -15.0, + "water": -18.0, + "tide": -12.0, + "ambience": -27.0, + "music": -25.0, +} + +## Sound name -> [category, loops, recipe method]. +const SOUNDS: Dictionary = { + # Footsteps, two of each so steps alternate. + "step_grass_1": ["footstep", false, "_step_grass"], + "step_grass_2": ["footstep", false, "_step_grass"], + "step_sand_1": ["footstep", false, "_step_sand"], + "step_sand_2": ["footstep", false, "_step_sand"], + "step_rock_1": ["footstep", false, "_step_rock"], + "step_rock_2": ["footstep", false, "_step_rock"], + "step_wood_1": ["footstep", false, "_step_wood"], + "step_wood_2": ["footstep", false, "_step_wood"], + "step_shallows_1": ["footstep", false, "_step_shallows"], + "step_shallows_2": ["footstep", false, "_step_shallows"], + "land": ["footstep", false, "_land"], + # Weapons: one report per weapon. + "swing_boathook": ["weapon", false, "_swing"], + "shot_fowling_piece": ["weapon", false, "_shot_fowling"], + "shot_dock_carbine": ["weapon", false, "_shot_carbine"], + "shot_signal_revolver": ["weapon", false, "_shot_revolver"], + "shot_rivet_repeater": ["weapon", false, "_shot_repeater"], + "shot_whalers_longgun": ["weapon", false, "_shot_longgun"], + "shot_line_thrower": ["weapon", false, "_shot_line"], + "shot_harpoon_gun": ["weapon", false, "_shot_harpoon"], + "keg_blast": ["weapon", false, "_keg_blast"], + "reload": ["player", false, "_reload"], + # Where shots and swings land. + "hit_wood": ["impact", false, "_hit_wood"], + "hit_stone": ["impact", false, "_hit_stone"], + "hit_iron": ["impact", false, "_hit_iron"], + "hit_player": ["impact", false, "_hit_player"], + "hit_ground": ["impact", false, "_hit_ground"], + "chop": ["impact", false, "_chop"], + # Building. + "build_driftwood": ["build", false, "_build_wood"], + "build_stone": ["build", false, "_build_stone"], + "build_salvage_iron": ["build", false, "_build_iron"], + "break_driftwood": ["build", false, "_break_wood"], + "break_stone": ["build", false, "_break_stone"], + "break_salvage_iron": ["build", false, "_break_iron"], + # Water and the tide. + "splash": ["water", false, "_splash"], + "swim": ["water", false, "_swim"], + "surge": ["tide", false, "_surge"], + "bell": ["tide", false, "_bell"], + "foghorn": ["tide", false, "_foghorn"], + "lighthouse": ["tide", false, "_lighthouse"], + # The player. + "hurt": ["player", false, "_hurt"], + "pickup": ["player", false, "_pickup"], + "chest_open": ["player", false, "_chest_open"], + "eliminated": ["player", false, "_eliminated"], + # Ambience, looped. + "amb_surf": ["ambience", true, "_amb_surf"], + "amb_wind": ["ambience", true, "_amb_wind"], + "amb_rain": ["ambience", true, "_amb_rain"], + # Menus. + "ui_hover": ["ui", false, "_ui_hover"], + "ui_click": ["ui", false, "_ui_click"], + "ui_back": ["ui", false, "_ui_back"], + "ui_confirm": ["ui", false, "_ui_confirm"], +} + + +## A stable seed per sound name, so each recipe's noise is its own. +static func seed_of(sound: String) -> int: + return hash(sound) & 0x7fffffff + + +static func render(sound: String) -> PackedFloat32Array: + var entry: Array = SOUNDS[sound] + var variant: int = 2 if sound.ends_with("_2") else 1 + var recipes: Object = load("res://tools/audio/recipes.gd").new() + return recipes.call(String(entry[2]), seed_of(sound), variant) + + +# --- Footsteps ------------------------------------------------------------------- + +func _step_grass(seed_value: int, variant: int) -> PackedFloat32Array: + var swish: PackedFloat32Array = Dsp.bandpass(Dsp.noise(0.22, seed_value), [2600.0 + 400.0 * variant, 1500.0], 1.2) + swish = Dsp.shape(swish, [[0.0, 0.0], [0.015, 1.0], [0.08, 0.5], [0.22, 0.0]]) + var thud: PackedFloat32Array = Dsp.decay(Dsp.osc("sine", 0.22, [95.0 + 8.0 * variant, 60.0]), 0.004, 0.09) + Dsp.mix_into(swish, thud, 0, 0.7) + return swish + + +func _step_sand(seed_value: int, variant: int) -> PackedFloat32Array: + var crunch: PackedFloat32Array = Dsp.noise(0.26, seed_value) + # Grains: sparse, uneven clicks under a soft hiss. + var rng: RandomNumberGenerator = RandomNumberGenerator.new() + rng.seed = seed_value + 7 + for i: int in crunch.size(): + crunch[i] *= 0.25 + (1.6 if rng.randf() < 0.06 else 0.0) + crunch = Dsp.bandpass(crunch, [1700.0 + 300.0 * variant], 0.9) + return Dsp.shape(crunch, [[0.0, 0.0], [0.02, 1.0], [0.1, 0.6], [0.26, 0.0]]) + + +func _step_rock(seed_value: int, variant: int) -> PackedFloat32Array: + var click: PackedFloat32Array = Dsp.decay(Dsp.highpass(Dsp.noise(0.18, seed_value), 1800.0), 0.001, 0.03) + var knock: PackedFloat32Array = Dsp.modes(0.18, 210.0 + 25.0 * variant, [1.0, 2.7, 5.1], [0.8, 0.4, 0.2], [0.06, 0.04, 0.02]) + Dsp.mix_into(knock, click, 0, 0.8) + var grit: PackedFloat32Array = Dsp.decay(Dsp.bandpass(Dsp.noise(0.18, seed_value + 3), [3200.0], 1.5), 0.01, 0.1) + Dsp.mix_into(knock, grit, Dsp.n(0.02), 0.3) + return knock + + +func _step_wood(_seed_value: int, variant: int) -> PackedFloat32Array: + var board: PackedFloat32Array = Dsp.modes(0.3, 150.0 + 18.0 * variant, [1.0, 2.31, 3.9, 6.2], [1.0, 0.55, 0.3, 0.15], [0.16, 0.09, 0.05, 0.03]) + var heel: PackedFloat32Array = Dsp.modes(0.2, 190.0 + 18.0 * variant, [1.0, 2.31, 3.9], [0.6, 0.3, 0.15], [0.1, 0.06, 0.04]) + Dsp.mix_into(board, heel, Dsp.n(0.05), 0.7) + return board + + +func _step_shallows(seed_value: int, variant: int) -> PackedFloat32Array: + var slosh: PackedFloat32Array = Dsp.bandpass(Dsp.noise(0.4, seed_value), [900.0 + 150.0 * variant, 2600.0], 0.8) + slosh = Dsp.shape(slosh, [[0.0, 0.0], [0.03, 1.0], [0.12, 0.5], [0.4, 0.0]]) + var bubble: PackedFloat32Array = Dsp.decay(Dsp.osc("sine", 0.12, [500.0 + 60.0 * variant, 1100.0]), 0.002, 0.08) + Dsp.mix_into(slosh, bubble, Dsp.n(0.06), 0.25) + return slosh + + +func _land(seed_value: int, _variant: int) -> PackedFloat32Array: + var thump: PackedFloat32Array = Dsp.decay(Dsp.osc("sine", 0.4, [110.0, 45.0]), 0.003, 0.25) + var dust: PackedFloat32Array = Dsp.shape(Dsp.lowpass(Dsp.noise(0.4, seed_value), [1800.0]), [[0.0, 0.0], [0.01, 1.0], [0.35, 0.0]]) + Dsp.mix_into(thump, dust, 0, 0.6) + return thump + + +# --- Weapons ---------------------------------------------------------------------- + +## A black-powder report: a low thump, a short burst of filtered noise and a tail. +## `body` is the thump's pitch, `bright` the noise's cutoff, `tail` its decay. +func _powder(seed_value: int, length: float, body: float, bright: float, tail: float, drive: float) -> PackedFloat32Array: + var out: PackedFloat32Array = Dsp.decay(Dsp.osc("sine", length, [body * 1.8, body * 0.7]), 0.001, tail * 0.6) + var blast: PackedFloat32Array = Dsp.decay(Dsp.lowpass(Dsp.noise(length, seed_value), [bright, bright * 0.25], 2), 0.0005, tail) + Dsp.mix_into(out, blast, 0, 1.4) + var crack: PackedFloat32Array = Dsp.decay(Dsp.highpass(Dsp.noise(0.03, seed_value + 1), 1200.0), 0.0, 0.02) + Dsp.mix_into(out, crack, 0, 0.35) + return Dsp.saturate(out, drive) + + +func _shot_fowling(seed_value: int, _variant: int) -> PackedFloat32Array: + # The scattergun: wide and boomy. + return Dsp.echo(_powder(seed_value, 0.9, 70.0, 2200.0, 0.55, 2.2), 0.19, 0.3, 2) + + +func _shot_carbine(seed_value: int, _variant: int) -> PackedFloat32Array: + return Dsp.echo(_powder(seed_value, 0.6, 95.0, 3400.0, 0.32, 1.8), 0.16, 0.25, 2) + + +func _shot_revolver(seed_value: int, _variant: int) -> PackedFloat32Array: + # A flare pistol's pop, and the hiss of the charge. + var out: PackedFloat32Array = _powder(seed_value, 0.5, 130.0, 2800.0, 0.2, 1.5) + var hiss: PackedFloat32Array = Dsp.shape(Dsp.bandpass(Dsp.noise(0.5, seed_value + 9), [4000.0, 2200.0], 1.0), [[0.0, 0.0], [0.04, 0.4], [0.5, 0.0]]) + Dsp.mix_into(out, hiss, Dsp.n(0.02), 0.5) + return out + + +func _shot_repeater(seed_value: int, _variant: int) -> PackedFloat32Array: + # Short pop, then the rivet feed's clack. + var out: PackedFloat32Array = _powder(seed_value, 0.4, 120.0, 3000.0, 0.16, 1.6) + var clack: PackedFloat32Array = Dsp.modes(0.1, 1300.0, [1.0, 2.4, 3.7], [0.6, 0.4, 0.2], [0.03, 0.02, 0.015]) + Dsp.mix_into(out, clack, Dsp.n(0.07), 0.5) + return out + + +func _shot_longgun(seed_value: int, _variant: int) -> PackedFloat32Array: + # The heaviest report, rolling back off the cliffs. + return Dsp.echo(_powder(seed_value, 1.2, 55.0, 2600.0, 0.8, 2.4), 0.33, 0.4, 3) + + +func _shot_line(seed_value: int, _variant: int) -> PackedFloat32Array: + # A compressed-air whump and the line paying out. + var whump: PackedFloat32Array = Dsp.decay(Dsp.lowpass(Dsp.noise(0.7, seed_value), [900.0, 300.0]), 0.004, 0.2) + var body: PackedFloat32Array = Dsp.decay(Dsp.osc("sine", 0.7, [150.0, 70.0]), 0.002, 0.18) + Dsp.mix_into(whump, body, 0, 0.8) + var rope: PackedFloat32Array = Dsp.shape(Dsp.bandpass(Dsp.noise(0.7, seed_value + 2), [2400.0, 1200.0], 2.5), [[0.0, 0.0], [0.08, 0.0], [0.15, 0.5], [0.7, 0.0]]) + Dsp.mix_into(whump, rope, 0, 0.6) + return whump + + +func _shot_harpoon(seed_value: int, _variant: int) -> PackedFloat32Array: + # A spring's twang and the harpoon's flight. + var twang: PackedFloat32Array = Dsp.decay(Dsp.osc("saw", 0.7, [180.0, 140.0], [9.0, 0.3]), 0.002, 0.35) + twang = Dsp.lowpass(twang, [2500.0, 600.0]) + var thunk: PackedFloat32Array = Dsp.modes(0.3, 120.0, [1.0, 2.2], [1.0, 0.4], [0.12, 0.08]) + Dsp.mix_into(twang, thunk, 0, 0.9) + var flight: PackedFloat32Array = Dsp.shape(Dsp.bandpass(Dsp.noise(0.7, seed_value), [1800.0, 700.0], 3.0), [[0.0, 0.0], [0.05, 0.6], [0.7, 0.0]]) + Dsp.mix_into(twang, flight, 0, 0.5) + return twang + + +func _keg_blast(seed_value: int, _variant: int) -> PackedFloat32Array: + var out: PackedFloat32Array = _powder(seed_value, 1.8, 40.0, 1600.0, 1.3, 2.8) + var debris: PackedFloat32Array = Dsp.shape(Dsp.bandpass(Dsp.noise(1.8, seed_value + 5), [2500.0, 900.0], 0.7), [[0.0, 0.0], [0.15, 0.0], [0.3, 0.35], [1.8, 0.0]]) + Dsp.mix_into(out, debris, 0, 0.6) + return Dsp.echo(out, 0.4, 0.3, 2) + + +func _swing(seed_value: int, _variant: int) -> PackedFloat32Array: + # A boathook through the air. + var whoosh: PackedFloat32Array = Dsp.bandpass(Dsp.noise(0.35, seed_value), [500.0, 1600.0], 2.0) + return Dsp.shape(whoosh, [[0.0, 0.0], [0.12, 1.0], [0.2, 0.8], [0.35, 0.0]]) + + +func _reload(_seed_value: int, _variant: int) -> PackedFloat32Array: + # Ramrod and lock: two dull metal clicks. + var first: PackedFloat32Array = Dsp.modes(0.12, 900.0, [1.0, 2.7, 4.4], [0.7, 0.4, 0.2], [0.04, 0.03, 0.02]) + var second: PackedFloat32Array = Dsp.modes(0.18, 640.0, [1.0, 2.7, 4.4], [0.9, 0.4, 0.2], [0.07, 0.04, 0.03]) + return Dsp.sequence([first, second], 0.12) + + +# --- Impacts ---------------------------------------------------------------------- + +func _hit_wood(seed_value: int, _variant: int) -> PackedFloat32Array: + var knock: PackedFloat32Array = Dsp.modes(0.35, 240.0, [1.0, 2.31, 3.9, 6.2], [1.0, 0.6, 0.35, 0.2], [0.18, 0.1, 0.06, 0.04]) + var splinter: PackedFloat32Array = Dsp.decay(Dsp.bandpass(Dsp.noise(0.35, seed_value), [3000.0], 1.0), 0.001, 0.12) + Dsp.mix_into(knock, splinter, 0, 0.5) + return knock + + +func _hit_stone(seed_value: int, _variant: int) -> PackedFloat32Array: + var chip: PackedFloat32Array = Dsp.decay(Dsp.highpass(Dsp.noise(0.3, seed_value), 2000.0), 0.0005, 0.08) + var body: PackedFloat32Array = Dsp.modes(0.3, 420.0, [1.0, 2.9, 5.3], [0.6, 0.35, 0.2], [0.07, 0.05, 0.03]) + Dsp.mix_into(chip, body, 0, 0.8) + var rubble: PackedFloat32Array = Dsp.decay(Dsp.lowpass(Dsp.noise(0.3, seed_value + 4), [1200.0]), 0.02, 0.2) + Dsp.mix_into(chip, rubble, Dsp.n(0.03), 0.4) + return chip + + +func _hit_iron(_seed_value: int, _variant: int) -> PackedFloat32Array: + # A dull clang: salvage plate, not a bell. + return Dsp.lowpass(Dsp.modes(0.8, 310.0, [1.0, 2.76, 4.07, 5.4, 6.9], [1.0, 0.6, 0.45, 0.3, 0.2], [0.6, 0.4, 0.3, 0.2, 0.15]), [3500.0]) + + +func _hit_player(seed_value: int, _variant: int) -> PackedFloat32Array: + # Oilskin taking a hit: a padded thump. + var thump: PackedFloat32Array = Dsp.decay(Dsp.osc("sine", 0.25, [130.0, 70.0]), 0.002, 0.12) + var cloth: PackedFloat32Array = Dsp.decay(Dsp.bandpass(Dsp.noise(0.25, seed_value), [1100.0], 1.0), 0.002, 0.08) + Dsp.mix_into(thump, cloth, 0, 0.7) + return thump + + +func _hit_ground(seed_value: int, _variant: int) -> PackedFloat32Array: + var puff: PackedFloat32Array = Dsp.decay(Dsp.lowpass(Dsp.noise(0.3, seed_value), [2400.0, 600.0]), 0.002, 0.15) + var body: PackedFloat32Array = Dsp.decay(Dsp.osc("sine", 0.3, [90.0, 50.0]), 0.002, 0.1) + Dsp.mix_into(puff, body, 0, 0.6) + return puff + + +func _chop(seed_value: int, _variant: int) -> PackedFloat32Array: + # A hook biting timber. + var bite: PackedFloat32Array = Dsp.modes(0.3, 330.0, [1.0, 2.31, 3.9], [1.0, 0.5, 0.3], [0.12, 0.08, 0.05]) + var crack: PackedFloat32Array = Dsp.decay(Dsp.highpass(Dsp.noise(0.3, seed_value), 1500.0), 0.0005, 0.05) + Dsp.mix_into(bite, crack, 0, 0.7) + return bite + + +# --- Building --------------------------------------------------------------------- + +func _build_wood(_seed_value: int, _variant: int) -> PackedFloat32Array: + # Three mallet knocks, the last settling a board. + var parts: Array = [] + for k: int in 3: + parts.append(Dsp.modes(0.16, 200.0 + 15.0 * k, [1.0, 2.31, 3.9, 6.2], [1.0, 0.5, 0.3, 0.15], [0.12, 0.08, 0.05, 0.03])) + return Dsp.sequence(parts, 0.07) + + +func _build_stone(seed_value: int, _variant: int) -> PackedFloat32Array: + # A block set down, and the scrape of it squared. + var set_down: PackedFloat32Array = Dsp.decay(Dsp.osc("sine", 0.7, [85.0, 60.0]), 0.004, 0.25) + var clunk: PackedFloat32Array = Dsp.modes(0.7, 380.0, [1.0, 2.9], [0.4, 0.2], [0.08, 0.05]) + Dsp.mix_into(set_down, clunk, 0, 1.0) + var scrape: PackedFloat32Array = Dsp.shape(Dsp.bandpass(Dsp.noise(0.7, seed_value), [1400.0, 900.0], 1.5), [[0.0, 0.0], [0.2, 0.0], [0.3, 0.6], [0.65, 0.0]]) + Dsp.mix_into(set_down, scrape, 0, 0.7) + return set_down + + +func _build_iron(_seed_value: int, _variant: int) -> PackedFloat32Array: + # Rivets driven: four clanks, quick. + var parts: Array = [] + for k: int in 4: + parts.append(Dsp.lowpass(Dsp.modes(0.12, 520.0 - 20.0 * k, [1.0, 2.76, 4.07], [1.0, 0.5, 0.3], [0.1, 0.07, 0.05]), [3000.0])) + return Dsp.sequence(parts, 0.05) + + +func _break_wood(seed_value: int, _variant: int) -> PackedFloat32Array: + var crack: PackedFloat32Array = Dsp.decay(Dsp.bandpass(Dsp.noise(1.0, seed_value), [2200.0, 800.0], 0.8), 0.001, 0.5) + for k: int in 4: + var plank: PackedFloat32Array = Dsp.modes(0.4, 160.0 + 30.0 * k, [1.0, 2.31, 3.9], [0.8, 0.4, 0.2], [0.2, 0.1, 0.06]) + Dsp.mix_into(crack, plank, Dsp.n(0.12 + 0.13 * k), 0.6) + return crack + + +func _break_stone(seed_value: int, _variant: int) -> PackedFloat32Array: + var rumble: PackedFloat32Array = Dsp.decay(Dsp.lowpass(Dsp.brown(1.2, seed_value), [900.0, 300.0]), 0.01, 0.9) + var rng: RandomNumberGenerator = RandomNumberGenerator.new() + rng.seed = seed_value + 11 + for k: int in 7: + var chunk: PackedFloat32Array = Dsp.modes(0.25, rng.randf_range(250.0, 600.0), [1.0, 2.9], [0.6, 0.3], [0.06, 0.04]) + Dsp.mix_into(rumble, chunk, Dsp.n(rng.randf_range(0.0, 0.8)), 0.5) + return rumble + + +func _break_iron(seed_value: int, _variant: int) -> PackedFloat32Array: + var out: PackedFloat32Array = Dsp.lowpass(Dsp.modes(1.4, 180.0, [1.0, 2.76, 4.07, 5.4], [1.0, 0.7, 0.5, 0.3], [1.0, 0.7, 0.5, 0.3], 0.97), [2500.0]) + var groan: PackedFloat32Array = Dsp.shape(Dsp.bandpass(Dsp.noise(1.4, seed_value), [600.0, 350.0], 6.0), [[0.0, 0.0], [0.2, 0.8], [1.4, 0.0]]) + Dsp.mix_into(out, groan, 0, 0.8) + return out + + +# --- Water and the tide ----------------------------------------------------------- + +func _splash(seed_value: int, _variant: int) -> PackedFloat32Array: + var body: PackedFloat32Array = Dsp.shape(Dsp.bandpass(Dsp.noise(0.9, seed_value), [700.0, 2500.0], 0.7), [[0.0, 0.0], [0.02, 1.0], [0.2, 0.5], [0.9, 0.0]]) + var plunge: PackedFloat32Array = Dsp.decay(Dsp.osc("sine", 0.5, [160.0, 60.0]), 0.002, 0.25) + Dsp.mix_into(body, plunge, 0, 0.7) + return body + + +func _swim(seed_value: int, _variant: int) -> PackedFloat32Array: + return Dsp.shape(Dsp.bandpass(Dsp.noise(0.6, seed_value), [600.0, 1400.0], 1.0), [[0.0, 0.0], [0.15, 1.0], [0.6, 0.0]]) + + +func _surge(seed_value: int, _variant: int) -> PackedFloat32Array: + # A wave breaking over the defences: a swell, the crash and the wash back. + var swell: PackedFloat32Array = Dsp.lowpass(Dsp.brown(3.5, seed_value), [200.0, 1600.0]) + swell = Dsp.shape(swell, [[0.0, 0.0], [1.0, 0.6], [1.3, 1.0], [2.0, 0.6], [3.5, 0.0]]) + var crash: PackedFloat32Array = Dsp.shape(Dsp.lowpass(Dsp.noise(3.5, seed_value + 1), [3000.0, 900.0]), [[0.0, 0.0], [1.15, 0.0], [1.3, 1.0], [3.5, 0.0]]) + Dsp.mix_into(swell, crash, 0, 0.8) + return Dsp.saturate(swell, 1.5) + + +func _bell(_seed_value: int, _variant: int) -> PackedFloat32Array: + # A ship's bell, struck twice: a phase has turned. + var strike: PackedFloat32Array = Dsp.modes(3.0, 523.0, [0.5, 1.0, 1.19, 1.56, 2.0, 2.51, 2.66, 3.01], [0.6, 1.0, 0.5, 0.45, 0.4, 0.25, 0.2, 0.15], [3.0, 2.4, 1.8, 1.5, 1.2, 0.9, 0.8, 0.6]) + var out: PackedFloat32Array = Dsp.silence(3.8) + Dsp.mix_into(out, strike, 0, 1.0) + Dsp.mix_into(out, strike, Dsp.n(0.55), 0.85) + return out + + +func _foghorn(_seed_value: int, _variant: int) -> PackedFloat32Array: + # The tide is rising: a long, low reed note with a beating second voice. + var low: PackedFloat32Array = Dsp.osc("reed", 3.6, [98.0], [0.0, 0.0]) + var beat: PackedFloat32Array = Dsp.osc("reed", 3.6, [98.6], [0.0, 0.0], 0.3) + var fifth: PackedFloat32Array = Dsp.osc("bow", 3.6, [147.0]) + Dsp.mix_into(low, beat, 0, 0.8) + Dsp.mix_into(low, fifth, 0, 0.35) + low = Dsp.lowpass(low, [700.0], 2) + return Dsp.shape(low, [[0.0, 0.0], [0.35, 1.0], [2.9, 0.9], [3.6, 0.0]]) + + +func _lighthouse(_seed_value: int, _variant: int) -> PackedFloat32Array: + # The last land: a slow, pure tone that swells like a turning lamp. + var tone: PackedFloat32Array = Dsp.osc("sine", 4.0, [392.0]) + var upper: PackedFloat32Array = Dsp.osc("sine", 4.0, [588.0]) + Dsp.mix_into(tone, upper, 0, 0.4) + var under: PackedFloat32Array = Dsp.osc("bow", 4.0, [196.0]) + Dsp.mix_into(tone, Dsp.lowpass(under, [500.0]), 0, 0.5) + return Dsp.shape(tone, [[0.0, 0.0], [0.8, 0.7], [1.6, 1.0], [2.6, 0.8], [4.0, 0.0]]) + + +# --- The player ------------------------------------------------------------------- + +func _hurt(seed_value: int, _variant: int) -> PackedFloat32Array: + var thump: PackedFloat32Array = Dsp.decay(Dsp.osc("sine", 0.35, [85.0, 50.0]), 0.002, 0.2) + var breath: PackedFloat32Array = Dsp.shape(Dsp.bandpass(Dsp.noise(0.35, seed_value), [900.0, 600.0], 2.0), [[0.0, 0.0], [0.03, 0.5], [0.35, 0.0]]) + Dsp.mix_into(thump, breath, 0, 0.7) + return thump + + +func _pickup(seed_value: int, _variant: int) -> PackedFloat32Array: + # Rope and canvas: a short rustle and a soft knock. + var rustle: PackedFloat32Array = Dsp.shape(Dsp.bandpass(Dsp.noise(0.3, seed_value), [2000.0, 3200.0], 1.2), [[0.0, 0.0], [0.04, 1.0], [0.3, 0.0]]) + var knock: PackedFloat32Array = Dsp.modes(0.2, 420.0, [1.0, 2.31], [0.5, 0.2], [0.06, 0.04]) + Dsp.mix_into(rustle, knock, Dsp.n(0.08), 0.8) + return rustle + + +func _chest_open(_seed_value: int, _variant: int) -> PackedFloat32Array: + # A latch, then the lid's hinge creaking. + var latch: PackedFloat32Array = Dsp.modes(0.1, 1100.0, [1.0, 2.7], [0.7, 0.3], [0.04, 0.03]) + var creak: PackedFloat32Array = Dsp.osc("saw", 0.6, [220.0, 310.0], [23.0, 0.6]) + creak = Dsp.shape(Dsp.bandpass(creak, [900.0], 4.0), [[0.0, 0.0], [0.1, 0.8], [0.5, 0.6], [0.6, 0.0]]) + var lid: PackedFloat32Array = Dsp.modes(0.3, 170.0, [1.0, 2.31, 3.9], [1.0, 0.5, 0.3], [0.18, 0.1, 0.06]) + return Dsp.sequence([latch, creak, lid], 0.02) + + +func _eliminated(_seed_value: int, _variant: int) -> PackedFloat32Array: + # A falling minor third on the bell's low partial: someone is out. + var first: PackedFloat32Array = Dsp.modes(1.4, 293.7, [1.0, 2.0, 2.76], [1.0, 0.3, 0.15], [1.2, 0.8, 0.5]) + var second: PackedFloat32Array = Dsp.modes(1.6, 246.9, [1.0, 2.0, 2.76], [1.0, 0.3, 0.15], [1.4, 0.9, 0.6]) + var out: PackedFloat32Array = Dsp.silence(2.0) + Dsp.mix_into(out, first, 0, 1.0) + Dsp.mix_into(out, second, Dsp.n(0.35), 1.0) + return out + + +# --- Ambience --------------------------------------------------------------------- + +func _amb_surf(seed_value: int, _variant: int) -> PackedFloat32Array: + # Waves arriving every few seconds over a constant low wash. + var length: float = 8.6 + var wash: PackedFloat32Array = Dsp.lowpass(Dsp.brown(length, seed_value), [500.0]) + var breaking: PackedFloat32Array = Dsp.lowpass(Dsp.noise(length, seed_value + 1), [1400.0]) + var points: Array = [[0.0, 0.15]] + for wave: float in [0.4, 3.1, 5.6]: + points.append([wave + 0.9, 0.9]) + points.append([wave + 2.2, 0.15]) + points.append([length, 0.15]) + breaking = Dsp.shape(breaking, points) + Dsp.mix_into(wash, breaking, 0, 0.45) + return Dsp.make_loop(wash, 0.6) + + +func _amb_wind(seed_value: int, _variant: int) -> PackedFloat32Array: + var length: float = 7.6 + var gust: PackedFloat32Array = Dsp.bandpass(Dsp.noise(length, seed_value), [380.0, 620.0], 1.6) + var whistle: PackedFloat32Array = Dsp.bandpass(Dsp.noise(length, seed_value + 1), [1100.0, 900.0], 8.0) + gust = Dsp.shape(gust, [[0.0, 0.5], [1.8, 1.0], [3.4, 0.4], [5.4, 0.9], [length, 0.5]]) + Dsp.mix_into(gust, Dsp.shape(whistle, [[0.0, 0.0], [2.0, 0.6], [4.0, 0.0], [length, 0.0]]), 0, 0.5) + return Dsp.make_loop(gust, 0.6) + + +func _amb_rain(seed_value: int, _variant: int) -> PackedFloat32Array: + var length: float = 6.6 + var hiss: PackedFloat32Array = Dsp.lowpass(Dsp.highpass(Dsp.noise(length, seed_value), 900.0), [6000.0]) + var rng: RandomNumberGenerator = RandomNumberGenerator.new() + rng.seed = seed_value + 3 + var drop: PackedFloat32Array = Dsp.decay(Dsp.bandpass(Dsp.noise(0.05, seed_value + 4), [3500.0], 3.0), 0.0, 0.02) + for k: int in 260: + Dsp.mix_into(hiss, drop, Dsp.n(rng.randf_range(0.0, length)), rng.randf_range(0.5, 2.0), true) + return Dsp.make_loop(Dsp.scaled(hiss, 0.6), 0.6) + + +# --- Menus ------------------------------------------------------------------------ + +func _ui_hover(_seed_value: int, _variant: int) -> PackedFloat32Array: + return Dsp.modes(0.08, 1250.0, [1.0, 2.31], [0.6, 0.2], [0.03, 0.02]) + + +func _ui_click(_seed_value: int, _variant: int) -> PackedFloat32Array: + # A peg knocked home. + return Dsp.modes(0.14, 640.0, [1.0, 2.31, 3.9], [1.0, 0.5, 0.25], [0.07, 0.05, 0.03]) + + +func _ui_back(_seed_value: int, _variant: int) -> PackedFloat32Array: + var first: PackedFloat32Array = Dsp.modes(0.1, 640.0, [1.0, 2.31], [0.8, 0.3], [0.05, 0.03]) + var second: PackedFloat32Array = Dsp.modes(0.14, 480.0, [1.0, 2.31], [0.8, 0.3], [0.07, 0.04]) + return Dsp.sequence([first, second], 0.03) + + +func _ui_confirm(_seed_value: int, _variant: int) -> PackedFloat32Array: + # A small bell, once. + return Dsp.modes(0.9, 880.0, [1.0, 2.0, 2.76, 4.1], [1.0, 0.4, 0.25, 0.1], [0.7, 0.5, 0.35, 0.2]) diff --git a/tools/audio/recipes.gd.uid b/tools/audio/recipes.gd.uid new file mode 100644 index 0000000..7afaa6e --- /dev/null +++ b/tools/audio/recipes.gd.uid @@ -0,0 +1 @@ +uid://dtpx02g1114b1 diff --git a/tools/audio/score.gd b/tools/audio/score.gd new file mode 100644 index 0000000..b076237 --- /dev/null +++ b/tools/audio/score.gd @@ -0,0 +1,146 @@ +## Tidewall's adaptive score: one eight-bar tune in D Dorian, 6/8 at 72 dotted +## crotchets a minute, rendered as four layers that loop together and are faded in +## and out by the client (MusicDirector) as the tide builds: +## +## drone low D and A bowed together, always there +## drum a frame drum's 6/8 pulse, from the first rise +## concertina chords on the bellows, from the middle phases +## fiddle the tune, in menus, results and the last land +## +## The tune and the chords were written for Tidewall (see assets/PROVENANCE.md). They +## follow no existing song: the melody is the note list below, nothing else. +extends RefCounted + +const Dsp = preload("res://tools/audio/dsp.gd") + +const LAYERS: Array[String] = ["music_drone", "music_drum", "music_concertina", "music_fiddle"] +## Loudness per layer in dBFS RMS, so the full mix sits near -20. +const TARGETS: Dictionary = { + "music_drone": -29.0, + "music_drum": -28.0, + "music_concertina": -29.0, + "music_fiddle": -26.0, +} + +const EIGHTH: float = 60.0 / (72.0 * 3.0) +const BAR_EIGHTHS: int = 6 +const BARS: int = 8 + +## The tune: [MIDI note, length in quavers], six quavers to a bar. +const TUNE: Array = [ + [69, 3], [67, 1], [65, 2], + [64, 2], [62, 1], [64, 3], + [65, 1], [67, 1], [69, 1], [74, 3], + [72, 2], [69, 1], [64, 3], + [62, 1], [65, 1], [69, 1], [71, 2], [69, 1], + [67, 3], [64, 3], + [71, 2], [67, 1], [74, 3], + [69, 3], [62, 3], +] +## One chord a bar, as MIDI notes: Dm C Dm Am Dm C G Dm. +const CHORDS: Array = [ + [50, 53, 57], [48, 52, 55], [50, 53, 57], [45, 52, 57], + [50, 53, 57], [48, 52, 55], [47, 50, 55], [50, 53, 57], +] +## Frame drum strokes per bar, a gain per quaver (0 for a rest); bar 4 and 8 fill. +const DRUM: Array = [1.0, 0.0, 0.45, 0.8, 0.0, 0.45] +const DRUM_FILL: Array = [1.0, 0.35, 0.45, 0.8, 0.5, 0.6] + + +static func loop_seconds() -> float: + return EIGHTH * BAR_EIGHTHS * BARS + + +static func render(layer: String) -> PackedFloat32Array: + match layer: + "music_drone": + return _drone() + "music_drum": + return _drum() + "music_concertina": + return _concertina() + "music_fiddle": + return _fiddle() + return PackedFloat32Array() + + +static func _loop() -> PackedFloat32Array: + var out: PackedFloat32Array = PackedFloat32Array() + out.resize(int(round(loop_seconds() * Dsp.RATE))) + out.fill(0.0) + return out + + +## A bowed note: soft attack, slow vibrato that grows, a short release. +static func _bowed(note: int, seconds: float, vibrato_depth: float) -> PackedFloat32Array: + var hz: float = Dsp.midi_hz(note) + var tone: PackedFloat32Array = Dsp.osc("bow", seconds + 0.15, [hz], [5.3, vibrato_depth]) + tone = Dsp.lowpass(tone, [2600.0]) + return Dsp.shape(tone, [[0.0, 0.0], [0.07, 1.0], [seconds * 0.6, 0.85], [seconds, 0.7], [seconds + 0.15, 0.0]]) + + +static func _drone() -> PackedFloat32Array: + var out: PackedFloat32Array = _loop() + var length: float = loop_seconds() + var fade: float = 1.5 + for note: int in [38, 45, 50]: + var hz: float = Dsp.midi_hz(note) + var tone: PackedFloat32Array = Dsp.osc("bow", length + fade, [hz], [0.21, 0.04]) + tone = Dsp.lowpass(tone, [900.0], 2) + # Swells with the bow, twice a loop. + tone = Dsp.shape(tone, [[0.0, 0.0], [fade, 0.8], [length * 0.25, 1.0], [length * 0.5, 0.75], [length * 0.75, 1.0], [length, 0.8], [length + fade, 0.0]]) + Dsp.mix_into(out, tone, 0, 0.5 if note == 50 else 1.0, true) + return out + + +static func _drum() -> PackedFloat32Array: + var out: PackedFloat32Array = _loop() + var rng: RandomNumberGenerator = RandomNumberGenerator.new() + rng.seed = 6809 + for bar: int in BARS: + var pattern: Array = DRUM_FILL if bar % 4 == 3 else DRUM + for q: int in BAR_EIGHTHS: + var gain: float = float(pattern[q]) + if gain <= 0.0: + continue + var low: bool = q == 0 or q == 3 + var base: float = 82.0 if low else 120.0 + var hit: PackedFloat32Array = Dsp.modes(0.5, base, [1.0, 1.59, 2.14], [1.0, 0.4, 0.2], [0.35 if low else 0.18, 0.12, 0.08], 0.85) + var slap: PackedFloat32Array = Dsp.decay(Dsp.bandpass(Dsp.noise(0.06, rng.randi()), [1600.0], 1.0), 0.0, 0.03) + Dsp.mix_into(hit, slap, 0, 0.5 if low else 0.8) + var at: int = int(round((bar * BAR_EIGHTHS + q) * EIGHTH * Dsp.RATE)) + Dsp.mix_into(out, hit, at, gain * rng.randf_range(0.9, 1.0), true) + return out + + +static func _concertina() -> PackedFloat32Array: + var out: PackedFloat32Array = _loop() + for bar: int in BARS: + var chord: Array = CHORDS[bar] + # Two bellows pushes a bar, on each dotted crotchet. + for half: int in 2: + var seconds: float = EIGHTH * 3.0 - 0.06 + var press: PackedFloat32Array = Dsp.silence(seconds + 0.1) + for note: int in chord: + var hz: float = Dsp.midi_hz(note) + Dsp.mix_into(press, Dsp.osc("reed", seconds + 0.1, [hz * 0.9977]), 0, 0.5) + Dsp.mix_into(press, Dsp.osc("reed", seconds + 0.1, [hz * 1.0023], [0.0, 0.0], 0.37), 0, 0.5) + press = Dsp.lowpass(press, [1700.0], 2) + var gain: float = 1.0 if half == 0 else 0.7 + press = Dsp.shape(press, [[0.0, 0.0], [0.06, gain], [seconds, gain * 0.8], [seconds + 0.1, 0.0]]) + var at: int = int(round((bar * BAR_EIGHTHS + half * 3) * EIGHTH * Dsp.RATE)) + Dsp.mix_into(out, press, at, 1.0, true) + return out + + +static func _fiddle() -> PackedFloat32Array: + var out: PackedFloat32Array = _loop() + var quaver: int = 0 + for entry: Array in TUNE: + var note: int = int(entry[0]) + var length: int = int(entry[1]) + var seconds: float = length * EIGHTH - 0.02 + var tone: PackedFloat32Array = _bowed(note, seconds, 0.05 + 0.04 * length) + Dsp.mix_into(out, tone, int(round(quaver * EIGHTH * Dsp.RATE)), 1.0, true) + quaver += length + return out diff --git a/tools/audio/score.gd.uid b/tools/audio/score.gd.uid new file mode 100644 index 0000000..67e5be0 --- /dev/null +++ b/tools/audio/score.gd.uid @@ -0,0 +1 @@ +uid://dfm7wi1tvyg0c diff --git a/tools/audio/wav.gd b/tools/audio/wav.gd new file mode 100644 index 0000000..1956813 --- /dev/null +++ b/tools/audio/wav.gd @@ -0,0 +1,44 @@ +## Mono 16-bit PCM WAV files, written and read without the engine's importer, so the +## generator's output is byte-for-byte the same on every run. +extends RefCounted + +const Dsp = preload("res://tools/audio/dsp.gd") + + +static func encode(samples: PackedFloat32Array, rate: int = Dsp.RATE) -> PackedByteArray: + var data: StreamPeerBuffer = StreamPeerBuffer.new() + data.big_endian = false + var bytes: int = samples.size() * 2 + data.put_data("RIFF".to_ascii_buffer()) + data.put_u32(36 + bytes) + data.put_data("WAVEfmt ".to_ascii_buffer()) + data.put_u32(16) + data.put_u16(1) + data.put_u16(1) + data.put_u32(rate) + data.put_u32(rate * 2) + data.put_u16(2) + data.put_u16(16) + data.put_data("data".to_ascii_buffer()) + data.put_u32(bytes) + for value: float in samples: + data.put_16(clampi(int(round(clampf(value, -1.0, 1.0) * 32767.0)), -32768, 32767)) + return data.data_array + + +## The samples of a file encode() wrote, or an empty array if it isn't one. +static func decode(bytes: PackedByteArray) -> PackedFloat32Array: + var out: PackedFloat32Array = PackedFloat32Array() + if bytes.size() < 44 or bytes.slice(0, 4).get_string_from_ascii() != "RIFF" or bytes.slice(36, 40).get_string_from_ascii() != "data": + return out + var count: int = bytes.decode_u32(40) / 2 + if 44 + count * 2 > bytes.size(): + return out + out.resize(count) + for i: int in count: + out[i] = bytes.decode_s16(44 + i * 2) / 32767.0 + return out + + +static func rate_of(bytes: PackedByteArray) -> int: + return bytes.decode_u32(24) if bytes.size() >= 44 else 0 diff --git a/tools/audio/wav.gd.uid b/tools/audio/wav.gd.uid new file mode 100644 index 0000000..10de4fc --- /dev/null +++ b/tools/audio/wav.gd.uid @@ -0,0 +1 @@ +uid://35vaxn061683