"""Small original PCM effects for UI, dice and skill checks; offline only.""" import math from pathlib import Path import random import struct import wave RATE = 44100 TARGET = Path(__file__).resolve().parents[2] / "assets/audio/generated" def save(name, samples): with wave.open(str(TARGET / name), "wb") as output: output.setparams((1, 2, RATE, 0, "NONE", "not compressed")) output.writeframes(b"".join(struct.pack("= len(samples): break t = index / RATE attack = min(1, t / 0.0007) click = rng.uniform(-1, 1) * math.exp(-t * 130) knock = math.sin(2 * math.pi * pitch * t) * math.exp(-t * 60) samples[offset + index] += amplitude * attack * (click + 0.4 * knock) save("dice-roll.wav", samples) print("Generated 7 short game effects; original recordings unchanged.") if __name__ == "__main__": main()