Skip to content

Instantly share code, notes, and snippets.

@cleemy-desu-wayo
Last active September 10, 2025 19:59
simple samples for testing OSC Type Tag "T", "F", and "N" with python-osc
#!/usr/bin/env python3
#
# client side test for OSC Type Tag "T", "F", and "N" with python-osc
#
# see also: https://github.com/attwad/python-osc
from pythonosc import udp_client
import time
ip = "localhost" # change this line appropriately
port = 9002 # change this line appropriately
osc_client = udp_client.SimpleUDPClient(ip, port)
i = 0
while True:
i = i + 1
osc_client.send_message("/test", [True]) ; time.sleep(0.04)
osc_client.send_message("/test", [False]) ; time.sleep(0.04)
osc_client.send_message("/test", [None]) ; time.sleep(0.04)
osc_client.send_message("/test", [True, False, None]) ; time.sleep(0.04)
osc_client.send_message("/test", ["aaa" + str(i), True]) ; time.sleep(0.04)
osc_client.send_message("/test", [1, 2, 3, True]) ; time.sleep(0.04)
osc_client.send_message("/test", [True, 4, 5, 6]) ; time.sleep(0.04)
osc_client.send_message("/test", [7, 8, 9, None]) ; time.sleep(0.04)
osc_client.send_message("/test", [None, 10, 11, 12]) ; time.sleep(0.04)
time.sleep(1)
#!/usr/bin/env python3
#
# client side test for OSC Type Tag "T", "F", and "N" with python-osc
#
# see also: https://github.com/attwad/python-osc
from pythonosc import dispatcher
from pythonosc import osc_server
def print_osc(addr, *args):
print(f"addr: {addr} -- args: {args}")
ip = "localhost" # change this line appropriately
port = 9003 # change this line appropriately
dispatcher = dispatcher.Dispatcher()
dispatcher.map("/*", print_osc)
server = osc_server.ThreadingOSCUDPServer((ip, port), dispatcher)
print("Serving on {}".format(server.server_address))
server.serve_forever()
@cleemy-desu-wayo
Copy link
Author

the issue I opened for osc-ruby is here: aberant/osc-ruby#21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment