-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.py
54 lines (50 loc) · 1.51 KB
/
example.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
#!/usr/bin/env python3
import socket
import time
music = [
[('E', '4', '0.5'), ('E', '2', '1.0')],
[('B', '3', '0.25')],
[('C', '4', '0.25')],
[('D', '4', '0.5'), ('E', '2', '1.0')],
[('C', '4', '0.25')],
[('B', '3', '0.25')],
[('A', '3', '0.50'), ('A', '2', '1.0')],
[('A', '3', '0.25')],
[('C', '4', '0.25')],
[('E', '4', '0.5'), ('A', '2', '1.0')],
[('D', '4', '0.25')],
[('C', '4', '0.25')],
[('B', '3', '0.75'), ('Ab', '2', '1.0')],
[('C', '4', '0.25')],
[('D', '4', '0.5'), ('E', '2', '1.0')],
[('E', '4', '0.5')],
[('C', '4', '0.5'), ('A', '2', '1.5')],
[('A', '3', '0.5')],
[('A', '3', '0.5')],
[('D', '4', '0.5'), ('D', '3', '0.75')],
[('F', '4', '0.25')],
[('A', '4', '0.5'), ('D', '3', '1.0')],
[('G', '4', '0.25')],
[('F', '4', '0.25')],
[('E', '4', '0.75'), ('C', '3', '1.0')],
[('C', '4', '0.25')],
[('E', '4', '0.5'), ('C', '3', '1.0')],
[('D', '4', '0.25')],
[('C', '4', '0.25')],
[('B', '3', '0.5'), ('E', '2', '1.0')],
[('B', '3', '0.25')],
[('C', '4', '0.25')],
[('D', '4', '0.5'), ('E', '2', '1.0')],
[('E', '4', '0.5')],
[('C', '4', '0.5'), ('A', '2', '1.75')],
[('A', '3', '0.5')],
[('A', '3', '0.75')],
]
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('localhost', 1234))
for step in music:
time.sleep(0.01)
for note in step:
data = 'NOTE ' + ' '.join(note) + '\n'
s.send(data.encode('ascii'))
time.sleep(float(step[0][2]))