-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path111.py
54 lines (41 loc) · 1.19 KB
/
111.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from threading import Thread
import mido
from playsound import playsound
import requests
import time
music = r"SNA.mid"
class Decode(Thread):
def __init__(self):
"""Инициализация потока"""
Thread.__init__(self)
def run(self):
playsound(music)
class Play(Thread):
def __init__(self):
"""Инициализация потока"""
Thread.__init__(self)
def run(self):
time.sleep(0.5)
mid = mido.MidiFile(music)
for msg in mid.play():
note = str(msg).split(" ")[2].split("=")[1]
volume = str(msg).split(" ")[3].split("=")[1]
res = int(note) * int(volume) / 100
print(note)
if int(res) <= 0:
res = 0
if 0 < int(res) <= 10:
res = 11
res = int(res)
res = str(res)
try:
req = requests.get("http://109.254.211.5:1234/brig_r/" + res + "/brig_g/" + res + "/brig_b/" + res)
except:
None
def create_threads():
Playy = Play()
Decodee = Decode()
Playy.start()
Decodee.start()
if __name__ == "__main__":
create_threads()