sfx.music holds looping background music pieces, made from code like the sound effects. There are two so far, both for distorted guitars, bass and drums: - battle_music: original heavy metal in D minor in the manner of Bach's D minor harpsichord concerto. A unison opening riff, arpeggios through a circle of fifths, a gallop over a held A, then the riff again. It loops every 24 seconds at 160 beats a minute. - moonlight_metal: Beethoven's Moonlight Sonata sped up and made heavy, in C sharp minor. The sonata's triplet arpeggios and opening chords, with a new lead melody, a triplet gallop and double kick. It loops every 27 seconds at 140 beats a minute. Each piece is its own module in sfx/music/pieces, named after its function, and is loaded the first time a game asks for it. A game only loads the pieces it plays, and a piece is added by adding its module, with nothing to register. The instruments the pieces share are in sfx/music/instruments.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
43 lines
1.3 KiB
Python
Executable File
43 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Remake tests/data/sfx_fingerprints.npz from the sounds the library makes now.
|
|
|
|
Run this only after listening to a sound that was changed on purpose, since it
|
|
makes the tests accept whatever the generators make now. From the library root:
|
|
|
|
python tools/update-sfx-fingerprints.py
|
|
"""
|
|
|
|
import importlib
|
|
from pathlib import Path
|
|
import sys
|
|
from types import ModuleType
|
|
|
|
import numpy as np
|
|
|
|
libraryRoot = Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0, str(libraryRoot / "tests"))
|
|
import sfx_cases # noqa: E402
|
|
|
|
moduleNames = ("synth", "impacts", "ui", "rewards", "materials", "creatures", "babble", "vehicles", "ambience",
|
|
"alerts", "movement", "music")
|
|
|
|
|
|
def load_modules():
|
|
packageName = "_sfx_fingerprint_library"
|
|
package = ModuleType(packageName)
|
|
package.__path__ = [str(libraryRoot)]
|
|
sys.modules[packageName] = package
|
|
return {name: importlib.import_module(f"{packageName}.sfx.{name}") for name in moduleNames}
|
|
|
|
|
|
def main():
|
|
cases = sfx_cases.cases(load_modules())
|
|
prints = {name: sfx_cases.fingerprint(make()) for name, make in cases.items()}
|
|
outputPath = libraryRoot / "tests" / "data" / "sfx_fingerprints.npz"
|
|
np.savez_compressed(outputPath, **prints)
|
|
print(f"Wrote fingerprints of {len(prints)} sounds to {outputPath}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|