mirror of
https://git.exozy.me/a/Never-Gonna-Give-Beep-Up
synced 2024-11-21 19:17:30 +00:00
Add new megalovania beep emulator
This commit is contained in:
parent
af5e812489
commit
6e7454cbe1
35
beepemu2
Executable file
35
beepemu2
Executable file
@ -0,0 +1,35 @@
|
||||
#!/usr/bin/fish -c python beepemu2 | play -r 100000 -t s16 -
|
||||
import math
|
||||
import struct
|
||||
import sys
|
||||
|
||||
def saw(t):
|
||||
t = t % 1
|
||||
if t < 0.25:
|
||||
return 4*t
|
||||
elif t < 0.75:
|
||||
return 2-4*t
|
||||
else:
|
||||
return 4*t-4
|
||||
|
||||
t,s = 0,0
|
||||
flag = ''
|
||||
flags = {}
|
||||
with open("megalovania.sh") as f:
|
||||
for x in f.read().split():
|
||||
if x == 'beep':
|
||||
pass
|
||||
elif x[0] == '-':
|
||||
flag = x[1]
|
||||
else:
|
||||
flags[flag] = int(x)
|
||||
if flag == 'l' and x != '-l':
|
||||
t += flags['D']
|
||||
while s < t:
|
||||
sys.stdout.buffer.write(struct.pack('h', 0))
|
||||
s += 1/100
|
||||
flags['D'] = 0
|
||||
t += flags['l']
|
||||
while s < t:
|
||||
sys.stdout.buffer.write(struct.pack('h', int(math.e**(-flags['f']/500)*2**14*saw(flags['f']*s/1000))))
|
||||
s += 1/100
|
Loading…
Reference in New Issue
Block a user