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>
movement.jump is a triangle tone sweeping straight up from 300 to 1000 Hz
over 0.24 seconds. It holds full volume for 0.04 seconds, then fades out
along a half sine. It matches the SoX recipe the original was most likely
made with (synth 0.24 triangle 300:1000 fade h 0 0.24 0.2), and it was
compared with the original by ear.
It peaks at 0.3, like the library's other short tones, so a game that
wants it as loud as the old file can pass a volume to make_sound.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
libstormgames.sfx makes sound effects with numpy and scipy, so a game can
use them without shipping sound files, and every game that asks for the
same sound with the same seed gets exactly the same samples. The sounds
come from Grave Racer and match it sample for sample.
The modules are synth (waves, filters, envelopes, loops), impacts, ui,
rewards, materials, creatures, babble, vehicles, ambience and alerts.
sfx.make_sound turns a sound into a pygame Sound for the mixer as it is
set up, turning down only a sound that would go past full scale.
sfx.add_sounds adds generated sounds by name, keeping any sound file of
the same name.
The menus' menu-move and menu-select sounds are generated when a game
has no file for them. sfx and scipy are only imported then, so a game
that ships both files, or never uses sfx, is not slowed down or made to
need scipy.
The tests check every sound against a stored fingerprint, so none can
change by accident; tools/update-sfx-fingerprints.py remakes them after
a deliberate change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Everything the library speaks or shows itself is marked for
translation in a libstormgames domain, separate from any game's, so
one translation serves every game: the text box, the text window,
speech history, game_menu's own items, learn_sounds, instructions,
credits, donate and the high scores. Sentences built from pieces are
whole sentences with named placeholders now, such as
"{character} deleted".
set_language(code) chooses the language, so a game that lets players
pick one can make the library speak it too; with no call it follows
the system, and falls back to English. Translations go in
locales/<language>/LC_MESSAGES/libstormgames.po, and
tools/update-translations.sh extracts the text into
locales/libstormgames.pot and compiles them.
The text box now names symbols when moving over or deleting them, as
it already did when typing, and get_input's default prompt is
translated. Game.display_text no longer drops the first and last
lines when Space reads them all or T copies them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>