Add an air horn sound, for the end of a timed match.
ui.air_horn(seconds=1.2): two brassy reeds a major third apart, each a pair of detuned sawtooths, scooping up into pitch, blaring with a faint flutter, then a short tail. Grave Racer's destruction derby ends with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
17fe11d229
commit
30b42f3efe
5 files changed
+32
-4
No files matched your search
+1
-1
@@ -181,7 +181,7 @@ sfx.add_sounds(sounds, {
|
|||||||
|
|
||||||
What there is, by what a game needs:
|
What there is, by what a game needs:
|
||||||
|
|
||||||
- **Interface:** `ui.beep`, `ui.fanfare`, `ui.toggle_sweep(rising)`,
|
- **Interface:** `ui.beep`, `ui.fanfare`, `ui.air_horn`, `ui.toggle_sweep(rising)`,
|
||||||
`ui.denied_click`, `ui.menu_move`, `ui.confirm_chime(step)`.
|
`ui.denied_click`, `ui.menu_move`, `ui.confirm_chime(step)`.
|
||||||
- **Rewards and pickups:** `rewards.sparkle`, `rewards.bell_chime(count)`,
|
- **Rewards and pickups:** `rewards.sparkle`, `rewards.bell_chime(count)`,
|
||||||
`rewards.beacon_blip`, `rewards.power_charge`, `rewards.bonus_run`,
|
`rewards.beacon_blip`, `rewards.power_charge`, `rewards.bonus_run`,
|
||||||
|
|||||||
@@ -828,7 +828,7 @@ fit; every other sound keeps its level.
|
|||||||
The modules:
|
The modules:
|
||||||
|
|
||||||
- `impacts`: `thunder`, `explosion`, `heavy_boom`, `thud`, `shatter`
|
- `impacts`: `thunder`, `explosion`, `heavy_boom`, `thud`, `shatter`
|
||||||
- `ui`: `beep`, `fanfare`, `toggle_sweep`, `denied_click`, `menu_move`, `confirm_chime`
|
- `ui`: `beep`, `fanfare`, `air_horn`, `toggle_sweep`, `denied_click`, `menu_move`, `confirm_chime`
|
||||||
- `rewards`: `sparkle`, `bell_chime`, `beacon_blip`, `power_charge`, `bonus_run`, `rising_sweep`, `item_spill`
|
- `rewards`: `sparkle`, `bell_chime`, `beacon_blip`, `power_charge`, `bonus_run`, `rising_sweep`, `item_spill`
|
||||||
- `materials`: `finger_snap`, `metal_clank`, `rattle`, `hollow_knock`, `squelch`, `wet_splat`, `thick_splash`,
|
- `materials`: `finger_snap`, `metal_clank`, `rattle`, `hollow_knock`, `squelch`, `wet_splat`, `thick_splash`,
|
||||||
`wooden_launch`
|
`wooden_launch`
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
"""Interface sounds: beeps, menu moves, confirmations and on/off sweeps."""
|
"""Interface sounds: beeps, menu moves, confirmations, on/off sweeps and an air horn."""
|
||||||
|
|
||||||
import math
|
import math
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from .synth import sampleRate, soften, square_wave
|
from .synth import Biquad, sampleRate, saw_wave, soften, square_wave
|
||||||
|
|
||||||
|
|
||||||
def beep(frequency, seconds):
|
def beep(frequency, seconds):
|
||||||
@@ -22,6 +22,33 @@ def fanfare():
|
|||||||
return np.concatenate(parts)
|
return np.concatenate(parts)
|
||||||
|
|
||||||
|
|
||||||
|
def air_horn(seconds=1.2):
|
||||||
|
"""A loud stadium air horn, for something ending, such as time running out.
|
||||||
|
|
||||||
|
Two brassy reeds a major third apart, each a pair of slightly detuned
|
||||||
|
sawtooths, scoop up into pitch as the air hits them, then blare with a
|
||||||
|
faint flutter and cut off with a short tail.
|
||||||
|
"""
|
||||||
|
length = int(sampleRate * seconds)
|
||||||
|
times = np.arange(length) / sampleRate
|
||||||
|
# The pitch scoops up from a little flat over the first 80 milliseconds.
|
||||||
|
scoop = 1.0 - 0.12 * np.exp(-times / 0.03)
|
||||||
|
flutter = 1.0 + 0.004 * np.sin(2.0 * math.pi * 6.0 * times)
|
||||||
|
horn = np.zeros(length)
|
||||||
|
for frequency, level in ((349.2, 1.0), (440.0, 0.8)):
|
||||||
|
for detune in (0.997, 1.004):
|
||||||
|
phaseStep = frequency * detune * scoop * flutter / sampleRate
|
||||||
|
horn += level * saw_wave(np.cumsum(phaseStep) % 1.0, phaseStep)
|
||||||
|
# A reedy, nasal body: the band where an air horn blares, with the fizz above it taken off.
|
||||||
|
body = Biquad("bandpass").process(horn, 1100.0, 0.9) + 0.35 * Biquad("lowpass").process(horn, 600.0)
|
||||||
|
body = Biquad("lowpass").process(body, 3500.0)
|
||||||
|
# Overblown: squash it, so it sounds strained.
|
||||||
|
body = np.tanh(1.8 * body / np.max(np.abs(body)))
|
||||||
|
attack = np.minimum(1.0, times / 0.02)
|
||||||
|
release = np.clip((seconds - times) / 0.18, 0.0, 1.0) ** 1.5
|
||||||
|
return 0.5 * body * attack * release
|
||||||
|
|
||||||
|
|
||||||
def toggle_sweep(rising, seconds=0.14, low=500.0, high=1000.0):
|
def toggle_sweep(rising, seconds=0.14, low=500.0, high=1000.0):
|
||||||
"""A short triangle tone gliding up an octave for something turning on, or down for turning off."""
|
"""A short triangle tone gliding up an octave for something turning on, or down for turning off."""
|
||||||
times = np.arange(int(sampleRate * seconds)) / sampleRate
|
times = np.arange(int(sampleRate * seconds)) / sampleRate
|
||||||
|
|||||||
Binary file not shown.
@@ -98,6 +98,7 @@ def cases(modules):
|
|||||||
|
|
||||||
"ui.beep": lambda: ui.beep(880.0, 0.15),
|
"ui.beep": lambda: ui.beep(880.0, 0.15),
|
||||||
"ui.fanfare": ui.fanfare,
|
"ui.fanfare": ui.fanfare,
|
||||||
|
"ui.air_horn": ui.air_horn,
|
||||||
"ui.toggle_sweep_rising": lambda: ui.toggle_sweep(True),
|
"ui.toggle_sweep_rising": lambda: ui.toggle_sweep(True),
|
||||||
"ui.toggle_sweep_falling": lambda: ui.toggle_sweep(False),
|
"ui.toggle_sweep_falling": lambda: ui.toggle_sweep(False),
|
||||||
"ui.denied_click": ui.denied_click,
|
"ui.denied_click": ui.denied_click,
|
||||||
|
|||||||
Reference in new issue
Block a user