Ossia library reference for SuperCollider:
Filter:
OSSIA/Guides (extension) | Libraries > Ossia > Guides

Ossia library reference for SuperCollider
ExtensionExtension

getting started with the Ossia library

libossia is a modern C++, cross-environment distributed object model for creative coding and interaction scoring. It allows to expose the parameters of your creative coding application over the network, and score them in time.

It handles various protocols such as OSC, MIDI, Minuit and OSCQuery. It offers bindings for many environments (PureData, Max/MSP, Python, Unity3D, QML, Faust, SuperCollider).

Basic Networking

Local OSCQuery device

A device represents a tree of parameters.

Local devices map to real parameters on the executable libossia is used with. For instance the frequency of a filter, etc.

Remote devices are mirror images of local devices on other applications : remote controls, mobile apps, etc. Every parameter in a local device will be synchronized with the remote devices connected to it.

Devices can be mapped to different protocols : Minuit, OSCQuery, etc. For the sake of simplicity, some bindings tie together device and protocol implementation.

We use OSCQuery as an example of protocol here. Once a device has been created, it is possible to check what's in it by going to http://localhost:5678.

For more information on the OSCQuery protocol, please refer to the proposal.

Creating nodes

The nodes in the device are simply called "nodes" in the API. Nodes are identified with the OSC parameter syntax: /foo/bar.

Nodes per se don't carry any value; they have to be extended with parameters to be able to send and receive messages.

Creating parameters

Each node can only have a single parameter. Parameters can have the following types:

As an optimisation, specific types for 2, 3, and 4 floats are provided; they are referred to as OSSIA_vec2f, OSSIA_vec3f, OSSIA_vec4f through the code.

Values can be written to a parameter, and fetched from it.

This example shows how to create a node, a parameter, and send a value to the parameter:

NOTE: First we create a parameter

NOTE: Then we can send values to this parameter

NOTE: And read them

Parameter callbacks

Parameter callbacks will inform you every time a parameter receives a message. On environments that support this, this will enable listening on the remote end. That is, if a remote device has no callbacks, network messages won't be sent upon modification.

Property binding

This show how, for environments that support it, ossia objects can integrate with existing property environments. In SuperCollider, parameters can easily be integrated with a SynthDef using the .snapshot, .ar and .kr methods.

Device callbacks

The example below shows how to automatically wait for the device to be instantiated and exposed before creating your own tree of nodes & parameters, necessary if you want to build all in a single code region, because the protocols' instantiation is asynchronous :

Remote OSCQuery Device

This shows how to connect to an existing OSCQuery device, and refresh the image that we have of it.

Node attributes

This part presents the attributes that can be set on nodes and parameters.

When using OSCQuery, all attribute changes will propagate across the network, except mute which is local. The "disabled" attribute has the same effect but does propagate.

Access mode

Access mode is a metadata that categorizes parameters between:

For instance:

Domain (min/max)

Domains allow to set a range of accepted values for a given parameter. Only meaningful for nodes with parameters.

NOTE: This sets a node's range between -5 and 5.

NOTE: If the domain is an array, it is possible to filter per value, or with a single, shared, min / max.
NOTE: Instead of a min / max, it is also possible to give a set of accepted values. Values that don't fit will be rounded to the closest accepted value.

Bounding mode

The bounding mode tells what happens when a value is outside of the min / max:

The default is FREE.

Repetition filter

When the repetition filter is enabled, if the same value is sent twice, the second time will be filtered.

Units

Units give a semantic meaning to the value of a parameter.

Position

Orientation

Color

Angle

Distance

Time

Gain

Speed

Extended type

WARNING: NotYetImplemented

Extended types, just like units, are here to give an indicative meaning to a parameter. They can also be used to enable some optimizations.

libossia proposes the following types:

Description

An optional textual description.

Tags

An optional array of tags for nodes.

Priority

Nodes with the highest priority should execute first.

Refresh rate

An optional value that says how often a value should be updated. Currently does nothing.

Step size

An optional value that says by which increment a value should change, for instance in a value editor.

Default value

A default value for a given node. Useful for resetting to a default state.

Zombie

This is a read-only attribute: it informs of whether a node is in a zombie state. A zombie node is an node in a remote device, whose source has been removed. It is kept in the mirrors but marked as such.

Critical

This attribute informs the network protocol that the value has a particular importance and should if possible use a protocol not subject to message loss, eg TCP instead of UDP. This is useful for instance for "play" messages.

Enabled/Disabled

This attribute will disable a node: it will stop sending messages to the network.

Hidden

This attribute is to use for nodes that are not to be exposed to the network.

Muted

This attribute will disable a node: it will stop sending messages to the network. Unlike the "enabled/disabled" attribute, it won't propagate to other computers.

Preset support

Loading and saving presets

Ossia provides preset handling. Files can be loaded and save to the disk to set the state of the device tree.

NOTE: Create a preset from a device and save it to a file

NOTE: Load and apply the preset