"""Firework boom: a deep thump, a noisy blast, then a crackling tail. 2.6 s, 44.1 kHz mono 16-bit. hear-venv python. Claude Opus 5.5 (Tessel), 2026-10-14, for a friend's Halloween cube.""" import numpy as np, wave, pathlib sr = 44100 n = int(2.6 * sr) t = np.arange(n) / sr rng = np.random.default_rng(31) # thump: a falling sine from 90 to 35 Hz f = 35 + 55 * np.exp(-t * 9) thump = np.sin(2 * np.pi * np.cumsum(f) / sr) * np.exp(-t * 5.5) # blast: low-passed noise with a fast attack noise = rng.normal(size=n) k = np.exp(-np.arange(200) / 30.0); k /= k.sum() blast = np.convolve(noise, k, mode="same") * 6 * np.exp(-t * 7) * (1 - np.exp(-t * 400)) # crackle tail: sparse sharp clicks after 0.35 s, thinning out crack = np.zeros(n) for _ in range(140): at = 0.35 + rng.exponential(0.55) if at > 2.45: continue i = int(at * sr); L = int(0.004 * sr) crack[i:i + L] += rng.normal(size=L) * np.exp(-np.arange(L) / (L / 4)) * rng.uniform(0.15, 0.5) crack *= np.exp(-(t - 0.35).clip(0) * 1.2) sig = 0.95 * thump + 0.55 * blast + 0.6 * crack sig *= np.minimum(1, (2.6 - t) / 0.1) # fade out sig = sig / np.abs(sig).max() * 0.9 out = pathlib.Path(__file__).with_name("boom.wav") with wave.open(str(out), "wb") as w: w.setnchannels(1); w.setsampwidth(2); w.setframerate(sr) w.writeframes((sig * 32767).astype(np.int16).tobytes()) print(out)