forked from PositiveVibe/gixhwswlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend_osc.py
37 lines (27 loc) · 1005 Bytes
/
send_osc.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
"""Send OSC to Supercollider
This program sends a string to Supercollider to trigger an instrument.
"""
import argparse
import random
import time
from pythonosc import osc_message_builder
from pythonosc import udp_client
parser = argparse.ArgumentParser()
parser.add_argument("--ip", default="127.0.0.1",
help="The ip of the OSC server")
parser.add_argument("--port", type=int, default=57120,
help="The port the OSC server is listening on")
args = parser.parse_args()
client = udp_client.SimpleUDPClient(args.ip, args.port)
def send_osc(gesture):
client.send_message('/bang', gesture)
# send_osc('cowbell')
# print("osc sent")
# Unit Test: brute force test gesture assignment
# gestures = ["drums","bass", "guitar", "cowbell", "head nod", "T-Pose", "hands up", "crouch"]
gestures = ["drums","guitar", "cowbell"]
# Unit Test: iterate through gestures array
for gesture in gestures:
client.send_message("/hello", random.random())
send_osc(gesture)
# time.sleep(4)