29 lines
1.2 KiB
Python
29 lines
1.2 KiB
Python
"""Original eight-second workshop ident: relay, keyboard, CRT hum and PC chime."""
|
|
from pathlib import Path
|
|
import math,random,struct,wave
|
|
|
|
ROOT=Path(__file__).resolve().parents[2]
|
|
|
|
|
|
def main():
|
|
rate=22050;rng=random.Random(184);data=bytearray();low=0
|
|
for i in range(rate*8):
|
|
t=i/rate;noise=rng.uniform(-1,1);low=.94*low+.06*noise
|
|
v=.004*math.sin(math.tau*50*t)+.002*low
|
|
if t>.45:
|
|
age=t-.45
|
|
v+=.055*math.exp(-age*65)*noise+.018*math.exp(-age*6)*math.sin(math.tau*(170*age+90*age*age))
|
|
for onset in [.8,1.4,2.0,2.16,3.05]:
|
|
age=t-onset
|
|
if 0<=age<.08:v+=.045*math.exp(-age*95)*(noise*.7+math.sin(math.tau*1400*age)*.3)
|
|
for onset,hz in [(4.95,523.25),(5.15,659.25),(5.38,783.99)]:
|
|
age=t-onset
|
|
if age>=0:v+=.035*(1-math.exp(-age*80))*math.exp(-age*3)*math.sin(math.tau*hz*age)
|
|
fade=min(1,t/.15,max(0,(8-t)/.55));v*=fade
|
|
pan=.1*math.sin(t*.6)
|
|
for gain in [1-pan,1+pan]:data.extend(struct.pack('<h',round(max(-.8,min(.8,v*gain))*32767)))
|
|
with wave.open(str(ROOT/'assets/audio/startup/studio-workshop-v4.wav'),'wb') as out:
|
|
out.setparams((2,2,rate,0,'NONE','not compressed'));out.writeframes(data)
|
|
|
|
|
|
if __name__=='__main__':main()
|