Streaming Data to Touch Designer from Python module for the Thalmic Labs Myo armband.
Cross platform and multithreaded and works without the Myo SDK.
Checkout the main repo from PerlinWarp for full instructions and current tutorials on how to use pyomyo.
- Switch to the examples directory from pyomyo and run:
python3 myo_multithreading_examp.py
- Drag and drop td-examples/getEMGdataViaUDP.tox to your TD Scene
- Go into base1 and switch EMG toggle to activate/deactive data stream
- Trail CHOP should visualize received data as a plot
I just show the important parts. Open getEMGdataViaUDP.tox and myo_multithreading_examp.py to see the full setup.
import socket
upd_ip = "127.0.0.1"
udp_port = 7000
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
def msg_to_bytes(msg):
return msg.encode('utf-8')
try:
while True:
while not(q.empty()):
emg = list(q.get())
#print(emg)
#convert each int of list to string
string_ints = [str(int) for int in emg]
#add strings back to one line seperated by comma
str_of_ints = ",". join(string_ints)
print(msg_to_bytes(str_of_ints))
#send encoded string as bytes to udp ip + port
sock.sendto(msg_to_bytes(str_of_ints), (upd_ip, udp_port))