Import current DEMON v0.19 source, assets and development handoff
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
from pathlib import Path
|
||||
import math,random,struct,wave
|
||||
root=Path(__file__).resolve().parent.parent
|
||||
rate=22050;seconds=8;data=[];rng=random.Random(150)
|
||||
melody=[76,76,79,83,81,79,76,74,76,79,81,79,74,76,72,74]
|
||||
for i in range(rate*seconds):
|
||||
t=i/rate;beat=t*2;phase=beat%1;note=melody[int(beat)%16]
|
||||
f=440*2**((note-69)/12)
|
||||
synth=math.sin(2*math.pi*f*t)*.15*min(1,phase*30)*max(0,1-phase/.85)
|
||||
synth+=math.sin(2*math.pi*f*2*t)*.035*math.exp(-phase*5)
|
||||
bass_note=[48,43,45,41][int(beat)//4%4];bass_f=440*2**((bass_note-69)/12)
|
||||
bass=math.sin(2*math.pi*bass_f*t)*.15*math.exp(-phase*4)
|
||||
kick=math.sin(2*math.pi*(70*phase-23*phase*phase))*.28*math.exp(-phase*18)
|
||||
noise=rng.uniform(-1,1)
|
||||
hat=noise*.055*math.exp(-(beat*2%1)*22)
|
||||
clap=noise*.12*math.exp(-phase*28) if int(beat)%2 else 0
|
||||
data.append(synth+bass+kick+hat+clap)
|
||||
peak=max(map(abs,data))
|
||||
out=root/'Demon_v0.16/audio/infernal_pop.wav'
|
||||
with wave.open(str(out),'wb') as f:
|
||||
f.setnchannels(1);f.setsampwidth(2);f.setframerate(rate)
|
||||
f.writeframes(b''.join(struct.pack('<h',int(s/peak*.62*32767)) for s in data))
|
||||
print('Original 8-second pop loop generated:',out)
|
||||
Reference in New Issue
Block a user