Files
Diabolo/DoOtboy/tools/make_phone_effects.py
T

21 lines
742 B
Python
Raw Normal View History

"""Original fictional distant hum; no sampled real-world attacks."""
from pathlib import Path
import math
import struct
import wave
target = Path(__file__).resolve().parents[1] / "do-otboy/assets/audio/approach.wav"
rate = 22050
samples = []
for i in range(rate * 6):
t = i / rate
envelope = min(1, t / 2) * min(1, (6 - t) / .3)
signal = .22 * math.sin(2 * math.pi * (68 * t + .6 * t * t))
signal += .08 * math.sin(2 * math.pi * 137 * t)
signal += .03 * math.sin(2 * math.pi * 281 * t)
samples.append(struct.pack("<h", int(signal * envelope * 32767)))
with wave.open(str(target), "wb") as output:
output.setparams((1, 2, rate, 0, "NONE", "not compressed"))
output.writeframes(b"".join(samples))
print(target)