OscIO

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph cluster_builtins { graph [label=builtins]; node [color=1]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } subgraph "cluster_supriya.osc" { graph [label="supriya.osc"]; node [color=2]; "supriya.osc.OscIO.OscIO" [URL="../api/supriya/osc/OscIO.html#supriya.osc.OscIO.OscIO", color=black, fontcolor=white, label="Osc\nIO", target=_top]; } "builtins.object" -> "supriya.osc.OscIO.OscIO"; }

class supriya.osc.OscIO.OscIO(debug_osc=False, debug_udp=False, ip_address='127.0.0.1', port=57751, timeout=2)[source]

Attributes Summary

Capture
CaptureEntry
OscCallback
OscHandler
OscServer
__del__
boot
capture
match Match callbacks against pattern.
quit
register Register a callback.
send
unregister Unregister a callback.

Special methods

__del__()[source]

Methods

boot(ip_address=None, port=None)[source]
capture()[source]
match(message)[source]

Match callbacks against pattern.

>>> io = supriya.osc.OscIO()
>>> callback = io.register(
...     pattern=['/synced', 1],
...     procedure=lambda: print('ok'),
...     )
>>> other_callback = io.register(
...     pattern=['/synced'],
...     procedure=lambda: print('sure'),
...     )
>>> for callback in io.match(supriya.osc.OscMessage('/synced', 1)):
...     callback
...
OscCallback(pattern=('/synced',), procedure=<function <lambda> at 0x...>, once=False, parse_response=False)
OscCallback(pattern=('/synced', 1), procedure=<function <lambda> at 0x...>, once=False, parse_response=False)
>>> for callback in io.match(supriya.osc.OscMessage('/synced', 2)):
...     callback
...
OscCallback(pattern=('/synced',), procedure=<function <lambda> at 0x...>, once=False, parse_response=False)
>>> for callback in io.match(supriya.osc.OscMessage('/n_go', 1000, 1001)):
...     callback
...
quit()[source]
register(pattern, procedure, once=False, parse_response=False)[source]

Register a callback.

>>> io = supriya.osc.OscIO()
>>> callback = io.register(
...     pattern=['/synced', 1],
...     procedure=lambda: print('ok'),
...     )
>>> import pprint
>>> pprint.pprint(io.callbacks)
{'/synced': ([],
             {1: ([OscCallback(pattern=('/synced', 1), procedure=<function <lambda> at 0x...>, once=False, parse_response=False)],
                  {})})}
send(message, with_request_name=False)[source]
unregister(callback)[source]

Unregister a callback.

>>> io = supriya.osc.OscIO()
>>> callback = io.register(
...     pattern=['/synced', 1],
...     procedure=lambda: print('ok'),
...     )
>>> other_callback = io.register(
...     pattern=['/synced'],
...     procedure=lambda: print('sure'),
...     )
>>> import pprint
>>> pprint.pprint(io.callbacks)
{'/synced': ([OscCallback(pattern=('/synced',), procedure=<function <lambda> at 0x...>, once=False, parse_response=False)],
             {1: ([OscCallback(pattern=('/synced', 1), procedure=<function <lambda> at 0x...>, once=False, parse_response=False)],
                  {})})}
>>> io.unregister(other_callback)
>>> pprint.pprint(io.callbacks)
{'/synced': ([],
             {1: ([OscCallback(pattern=('/synced', 1), procedure=<function <lambda> at 0x...>, once=False, parse_response=False)],
                  {})})}
>>> io.unregister(callback)
>>> pprint.pprint(io.callbacks)
{}