As part of a bigger project, I’ve been working on a Rust crate (rust name for libraries) to use Grid and Arc devices via serialosc
in the Rust programming language.
It’s now feature complete. It has the following features and characteristics:
- Enumerating devices, and connecting to multiple devices (of different or the same type) on the same host at the same time
- Using standard and custom port for
serialosc
- Receiving plug/unplug events
- All the standard OSC methods, with an API that is a tad higher level sometimes (for example, there is a method to set all the leds on a grid, appropriately converted to
map
calls if they are not setting intensity and are just on/off) - Support for arc and grid of various sizes, tilt sensors, encoder buttons
- Portable on all OSes (Windows/Linux/Mac, ARM, x86, x86-64 and probably more, but this is what I tested), including the Bela platform, which I’m using for this project
- it uses asynchronous and event-driven networking primitives on all platforms (using tokio), and lock-free message queues (using crossbeam) for optimum performances in soft or hard real-time environment.
- A minimal number of dynamic allocations (but I can probably remove the remaining ones)
- Complete documentation for every little attribute or method of the API
- A variety of examples for various devices and features (accelerators, device enumeration, arc, grid, etc.)
- Continuous integration and some unit tests (with and without device, so that it can run on travis containers.
Rust is a system programming language originally created by Mozilla (where I work), however it’s now in the hand of a strong community. It puts emphasis on performance, reliability, and productivity, and can be used for the same type of tasks than you would use C or C++. It’s very well suited for embedded and/or real-time audio work, and can target all operating systems and a lot of SOCs, with the ability to very easily cross-compile to other targets.
A variety of crates to work with audio are available through the package manager, such as very easy access to the low level audio input/output library used by Firefox, which is intended for use in low-latency scenarios, or various bits of DSP, lock-free data structures, and audio encoding and decoding that are essential to quickly build robust applications.
I’ve written a blog post at https://blog.paul.cx/post/monome-rs-1.0/ that has a bit more info about the library, including how to use it and how to contribute.