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:
@@ -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)
|
||||
Reference in New Issue
Block a user