aboutsummaryrefslogtreecommitdiff
path: root/keyboard.py
blob: 6dd05f009f0f9af90acf40bb75ad38a9e920f2d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import math
import os
import sys
import sounddevice as sd
import yue

# Number of times to sample each second
bitrate = 44100


note = []
for i in range(0, 24):
    note.append([yue.seething(yue.freq(4, i), j / bitrate) / 4 for j in range(0, 3 * bitrate)])

sd.default.samplerate = bitrate
print("READY")

while True:
    os.system("stty raw -echo")
    c = sys.stdin.read(1)
    os.system("stty -raw echo")

    x = "`1234567890-~!@#$%^&*()_".index(c)
    print(x)

    sd.play(note[x])