A8: Synthesized sound effects and an adaptive score

Every sound is made by scripts in tools/audio/ and committed as a WAV in
assets/audio/ with a manifest of hashes and levels:

- dsp.gd: seeded noise, wavetable oscillators, filters, envelopes and
  struck modes. recipes.gd: 50 effects (footsteps on five surfaces,
  a report per weapon, impacts, carpentry building and breaking, the
  tide's bell, foghorn, surge and lighthouse, player, ambience, menus).
- score.gd: an original eight-bar tune and chords in D Dorian, 6/8,
  rendered as four looping layers (drone, frame drum, concertina,
  fiddle).
- loudness.gd and check.gd: per-category loudness targets, a -1 dBFS
  peak ceiling and the mix order (the tide loudest). make audio and
  make audio-check.

In the client, SoundDirector turns FX records, footsteps, building,
the tide and the player's own hurts into sounds, placed on 3D voices
at the event so gunfire and footsteps come from their direction.
MusicDirector fades the score's layers with the tide on an
AudioStreamSynchronized, full in menus. MenuSounds knocks for buttons.

Closes #48

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-13 14:28:34 -05:00
co-authored by Claude Opus 5.5
parent b3c59d66ac
commit 2545337204
149 changed files with 4143 additions and 8 deletions
+40
View File
@@ -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)