35 lines
711 B
Python
35 lines
711 B
Python
|
|
from osc4py3.as_eventloop import *
|
||
|
|
from osc4py3 import oscbuildparse
|
||
|
|
|
||
|
|
class OscBroadcaster:
|
||
|
|
|
||
|
|
def __init__(self, name: str, host: str, port: str, command_channel: str):
|
||
|
|
self.name = name
|
||
|
|
self.host = host
|
||
|
|
self.port = port
|
||
|
|
self.cmd = command_channel
|
||
|
|
osc_udp_client(self.host, self.port, self.name)
|
||
|
|
|
||
|
|
def utterance(self, utterance: str, channel: str):
|
||
|
|
msg = oscbuildparse.OSCMessage(channel, None, [utterance])
|
||
|
|
osc_send(msg, self.name)
|
||
|
|
osc_process()
|
||
|
|
|
||
|
|
def command(self, command: str):
|
||
|
|
msg = oscbuildparse.OSCMessage(self.cmd, None, [command])
|
||
|
|
osc_send(msg, self.name)
|
||
|
|
osc_process()
|
||
|
|
|
||
|
|
@staticmethod
|
||
|
|
def start_osc():
|
||
|
|
osc_startup()
|
||
|
|
|
||
|
|
@staticmethod
|
||
|
|
def terminate_osc():
|
||
|
|
osc_terminate()
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|