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 <noreply@anthropic.com>
This commit is contained in:
Storm DragonandClaude Opus 5.5 committed 2026-11-28 20:33:01 -05:00
1 parent f164697cf6
commit ec82210ea6
7 files changed
+29 -2

No files matched your search

+1
View File
@@ -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.
+22
View File
@@ -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