Skip to main content

aiosc is a minimalistic Open Sound Control (OSC) communication module which uses asyncio for network operations and is compatible with the asyncio event loop.

Installation

aiosc requires at least Python 3.7. It can be installed using pip:

pip3 install aiosc

Alternatively, use --user option to install aiosc only for the current user:

pip3 install --user aiosc

Usage

To send OSC messages with aiosc, create an asyncio datagram connection endpoint of type aiosc.OSCProtocol.

A datagram connection can be created with the aiosc.connect convenience function or create_datagram_endpoint of the asyncio event loop. Both have the same set of arguments. Use the argument remote_addr to specify the OSC server address and port as follows:

import asyncio
import aiosc

async def main():
    client = await aiosc.connect(remote_addr=('127.0.0.1', 8000))

    client.send('/hello/world')
    client.send('/a/b/cde', 1000, -1, 'hello', 1.234, 5.678)

asyncio.run(main())

Subclassing aiosc.OSCProtocol is the recommended way of creating OSC server implementations.

aiosc.OSCProtocol provides a convenience async class method connect that can be used to bind the UDP socket and connect it to a remote endpoint using local_addr and remote_addr arguments.

In a typical case, local address will look like ('0.0.0.0', 9000) where 9000 is the port number and 0.0.0.0 address designates that the server will be listening on all available network interfaces.

import asyncio
import aiosc
import sys

class EchoServer(aiosc.OSCProtocol):
    def __init__(self):
        super().__init__(handlers={
            '/sys/exit': lambda addr, path, *args: sys.exit(0),
            '//*': self.echo,
        })

    def echo(self, addr, path, *args):
        print("incoming message from {}: {} {}".format(addr, path, args))

async def main():
    server = await EchoServer.connect(local_addr=('0.0.0.0', 8000))
    await asyncio.get_running_loop().create_future()

asyncio.run(main())

For more examples, see examples/.

OSC address patterns

aiosc dispatches messages to handler methods using glob-style address pattern matching as described in the OSC 1.0 specification. The // operator from OSC 1.1 preliminary specification is also supported.

Examples:

  • /hello/world matches /hello/world.

  • /hello/* matches /hello/world and /hello/sarah.

  • /{hello,goodbye}//world matches /hello/world and /goodbye/cruel/world.

  • //* matches any address.

Notes

Bundles are not yet supported.

OSC data types are picked from the preliminary spec documented in Features and Future of Open Sound Control version 1.1 for NIME paper. For example, I typetag is decoded to Impulse (aka “bang”) which is passed around as aiosc.Impulse singleton.

Suggestions, bug reports, issues and/or pull requests are, of course, welcome.

License

Copyright (c) 2014 Artem Popov <artfwo@gmail.com>

aiosc is licensed under the MIT license, please see LICENSE file for details.

Release files for aiosc 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiosc 0.3
File Size Uploaded
aiosc-0.3.tar.gz 5.8 kB Details

Release files / aiosc-0.3.tar.gz

Download URL aiosc-0.3.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2982128e0b3c2bc95fe65126d36dd09208faca384afe15a4cf92e0f6befdcdae
BLAKE2b-256 checksum
How to use checksums
36a89bc9d96c4787944982ea0756d838010ef4d937eff08d81f249337a9ed273
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 11, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3 This release

1 release file

0.2

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page