"""Original short, softly enveloped cues; reproducible, no external audio license.""" import math, struct, wave from pathlib import Path root = Path(__file__).resolve().parent.parent / 'public/assets/audio' root.mkdir(parents=True, exist_ok=True) for kind, notes in [('success', [(660, 0, .14), (880, .075, .16)]), ('error', [(330, 0, .17)])]: rate, duration = 22050, .26 frames = [] for i in range(int(rate * duration)): t = i / rate value = 0 for freq, start, length in notes: x = t - start if 0 <= x < length: envelope = min(1, x / .012) * (1 - x / length) ** 2 value += .32 * envelope * math.sin(2 * math.pi * freq * x) frames.append(struct.pack('