yue/keyboard.py

27 lines
488 B
Python
Raw Permalink Normal View History

import math
import os
import sys
2023-03-17 02:59:41 +00:00
import sounddevice as sd
import yue
# Number of times to sample each second
bitrate = 44100
note = []
for i in range(0, 24):
2023-03-22 02:56:34 +00:00
note.append([yue.seething(yue.freq(4, i), j / bitrate) / 4 for j in range(0, 3 * bitrate)])
sd.default.samplerate = bitrate
2023-03-17 02:59:41 +00:00
print("READY")
while True:
2023-03-17 02:59:41 +00:00
os.system("stty raw -echo")
c = sys.stdin.read(1)
2023-03-17 02:59:41 +00:00
os.system("stty -raw echo")
2023-03-17 02:59:41 +00:00
x = "`1234567890-~!@#$%^&*()_".index(c)
print(x)
sd.play(note[x])