From ec82210ea6f1eb46b7cdc7bc4540b2cb6c63122e Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Sat, 28 Nov 2026 20:33:01 -0500 Subject: [PATCH] Generated jump sound, matched to Wicked Quest's jump 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 --- README.md | 1 + sfx/__init__.py | 1 + sfx/movement.py | 22 ++++++++++++++++++++++ tests/data/sfx_fingerprints.npz | Bin 106217 -> 106847 bytes tests/sfx_cases.py | 3 +++ tests/test_sfx.py | 2 +- tools/update-sfx-fingerprints.py | 2 +- 7 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 sfx/movement.py diff --git a/README.md b/README.md index 085747e..d67ae49 100644 --- a/README.md +++ b/README.md @@ -633,6 +633,7 @@ The modules: - `ambience`: looping voices `BubblingVoice`, `DrippingVoice`, `GurglingVoice`, `BouncingSpringVoice`, `RatchetVoice`, and `PatternVoice` for any repeating pattern of sounds - `alerts`: live voices `ProximityWarningVoice`, `FallingScreamVoice`, `WhistlingFallVoice`, `ChatteringVoice` +- `movement`: `jump` - `synth`: the building blocks, for making new sounds Voices make sound a block at a time, for a game with its own live mixer. To diff --git a/sfx/__init__.py b/sfx/__init__.py index cecb990..7aef85c 100644 --- a/sfx/__init__.py +++ b/sfx/__init__.py @@ -26,6 +26,7 @@ The modules: - vehicles: skids, and live voices for road surfaces and wind. - ambience: loops such as bubbling, dripping and repeating patterns. - alerts: live voices for warnings, falling screams, whistles and chattering. +- movement: a jump. Generated sounds need numpy and scipy. Nothing else in libstormgames imports this package, so a game that does not use it does not need scipy. diff --git a/sfx/movement.py b/sfx/movement.py new file mode 100644 index 0000000..d11ff7e --- /dev/null +++ b/sfx/movement.py @@ -0,0 +1,22 @@ +"""Movement sounds: jumping.""" + +import numpy as np + +from .synth import sampleRate + + +def jump(seconds=0.24, low=300.0, high=1000.0): + """A triangle tone springing straight up in pitch from low to high as it fades out. + + The tone holds full volume for its first 0.04 seconds, then fades out over + the rest along a half sine. + """ + times = np.arange(int(sampleRate * seconds)) / sampleRate + frequency = low + (high - low) * times / seconds + # Start halfway through the cycle, at the triangle's lowest point. + phases = np.cumsum(frequency) / sampleRate + 0.5 + triangle = 2.0 * np.abs(2.0 * (phases % 1.0) - 1.0) - 1.0 + fadeSeconds = min(0.2, seconds) + fade = np.clip((times - (seconds - fadeSeconds)) / fadeSeconds, 0.0, 1.0) + envelope = 0.5 * (1.0 + np.cos(np.pi * fade)) + return 0.3 * triangle * envelope diff --git a/tests/data/sfx_fingerprints.npz b/tests/data/sfx_fingerprints.npz index 04aa51cede3bd42d0a7108761a874d8d5b8d7e2b..ebca3c157620b701688a524bf803259275cdc20f 100644 GIT binary patch delta 616 zcmaF4m+k%`wuUW?&6RpOh3oJChXO$c5r*9Sveewvyb`^v(%b^Qyn;$b1_1^ICI&G0 zGMV4sp?;a0)hsKntz1u-_1FX=ijOe*7}sp5pPg~IQtQWzzt8#SR4=KQ-CDnF)u(lL z9?tmtlUw_h)ZV_ExA*&Y%rSbsVsFg6kHLLii@yb*UjF97oYEt4`MWR5y8k@<%_&}e z=hQp48SxhD6=piVX{bH@#_s)Xr`S(;Gi%%7f4igBR@P5>F82F%X!r6bPjWW= zFG;PHO1|awd-vz%KSav(H}OZ$pP0NQsqOFTYx83rC+__=E$`C&8zxzAm!FII5MEq4 z>2LdLwW_}8FK^S|6-C~U7fgG<;^g~(C)Do!%l$C#+kWfIZ{EhIzJIw|ckBHH1meQ>=We?B&8e)_7NR(3U$_b$IO zYto4=f4`Z^Bz7?wiNA4Hdw02}=+E50Yd3{QhtC%%u_$|S|NGlaCBD5*>gFmk0!1eb zHd%=6n{zYq;I-q@+!gXSwKuGbIdc2MiF^OQtpCrnwg1ifb9yCT#=oR{e7~3f-m_$RYtFXo`m0mkrrb+dzw`VP z?fBnPzo-8B