forked from honnet/cyclokino
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.py
More file actions
executable file
·39 lines (29 loc) · 912 Bytes
/
Copy pathscript.py
File metadata and controls
executable file
·39 lines (29 loc) · 912 Bytes
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
#!/usr/bin/python
import os
import sys
import time
import signal
import serial
# first in first out file in which the playback speed is requested
fifo_file = "/tmp/mplayer.fifo"
sound = sys.argv[1] # TODO generate name
# allow a clean exit using ctrl+c
def signal_handler(signal, frame):
os.remove(fifo_file)
os.system("killall mplayer")
sys.exit(0)
# assume that there is only 1 arduino connected:
ser = serial.Serial('/dev/ttyACM0', 9600);
ser.isOpen()
if not os.path.exists(fifo_file):
os.mkfifo(fifo_file)
# generate the player command:
command = "mplayer -af scaletempo -slave -input file=" + fifo_file + " "
# and execute it with the sound argumend
os.system( command + sound + "&")
MAX_VAL=100.0
while True:
speed = int(ser.readline()) / MAX_VAL
print " *** speed = ", speed, " ***\n"
os.system("echo speed_set " + str(speed) + " > " + fifo_file)
time.sleep(0.5)