Skip to main content

Open Sound Control server and client implementations in pure Python

Project description

Open Sound Control server and client implementations in pure python (3.5+).

Current status

This library was developped following the specifications at and is currently in a stable state.


  • UDP blocking/threading/forking/asyncio server implementations
  • UDP client
  • int, int64, float, string, double, MIDI, timestamps, blob OSC arguments
  • simple OSC address<->callback matching system
  • extensive unit test coverage
  • basic client and server examples


Available at


python-osc is a pure python library that has no external dependencies, to install it just use pip (prefered):
$ pip install python-osc

or from the raw sources for the development version:

$ python test
$ python install


Simple client

"""Small example OSC client

This program sends 10 random values between 0.0 and 1.0 to the /filter address,
waiting for 1 seconds between each value.
import argparse
import random
import time

from pythonosc import udp_client

if __name__ == "__main__":
  parser = argparse.ArgumentParser()
  parser.add_argument("--ip", default="",
      help="The ip of the OSC server")
  parser.add_argument("--port", type=int, default=5005,
      help="The port the OSC server is listening on")
  args = parser.parse_args()

  client = udp_client.SimpleUDPClient(args.ip, args.port)

  for x in range(10):
    client.send_message("/filter", random.random())

Simple server

"""Small example OSC server

This program listens to several addresses, and prints some information about
received packets.
import argparse
import math

from pythonosc import dispatcher
from pythonosc import osc_server

def print_volume_handler(unused_addr, args, volume):
  print("[{0}] ~ {1}".format(args[0], volume))

def print_compute_handler(unused_addr, args, volume):
    print("[{0}] ~ {1}".format(args[0], args[1](volume)))
  except ValueError: pass

if __name__ == "__main__":
  parser = argparse.ArgumentParser()
      default="", help="The ip to listen on")
      type=int, default=5005, help="The port to listen on")
  args = parser.parse_args()

  dispatcher = dispatcher.Dispatcher()"/filter", print)"/volume", print_volume_handler, "Volume")"/logvolume", print_compute_handler, "Log volume", math.log)

  server = osc_server.ThreadingOSCUDPServer(
      (args.ip, args.port), dispatcher)
  print("Serving on {}".format(server.server_address))

Building bundles

from pythonosc import osc_bundle_builder
from pythonosc import osc_message_builder

bundle = osc_bundle_builder.OscBundleBuilder(
msg = osc_message_builder.OscMessageBuilder(address="/SYNC")
# Add 4 messages in the bundle, each with more arguments.

sub_bundle =
# Now add the same bundle inside itself.
# The bundle has 5 elements in total now.

bundle =
# You can now send it via a client as described in other examples.


Unlicensed, do what you want with it. (

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for python-osc, version 1.8.0
Filename, size File type Python version Upload date Hashes
Filename, size python_osc-1.8.0-py3-none-any.whl (32.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size python-osc-1.8.0.tar.gz (25.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page