aboutsummaryrefslogtreecommitdiff
path: root/keyboard.py
blob: 73892eaf42e65318047e283fe532851400bf0f27 (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.tone(yue.freq(3, 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])