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).
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.
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.
Each node can only have a single parameter. Parameters can have the following types:
Integer
- 32-bit int.Float
- 32-bit float.Boolean
- true/false
.Impulse
or Signal
- no value; just a message.Char
- 'a'
, '0'
, '!'
or $s
, $_
...String
or Symbol
- "a string"
or 'symbol'
Array
or List
- a generic list of values: [3, 'a', 2.68, ["foo", "bar"]]
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:
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.
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.
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 :
This shows how to connect to an existing OSCQuery device, and refresh the image that we have of it.
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 is a metadata that categorizes parameters between:
For instance:
Domains allow to set a range of accepted values for a given parameter. Only meaningful for nodes with parameters.
The bounding mode tells what happens when a value is outside of the min / max:
The default is FREE.
When the repetition filter is enabled, if the same value is sent twice, the second time will be filtered.
Units give a semantic meaning to the value of a parameter.
Position
Orientation
Color
Angle
Distance
Time
Gain
Speed
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:
An optional textual description.
An optional array of tags for nodes.
Nodes with the highest priority should execute first.
An optional value that says how often a value should be updated. Currently does nothing.
An optional value that says by which increment a value should change, for instance in a value editor.
A default value for a given node. Useful for resetting to a default state.
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.
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.
This attribute will disable a node: it will stop sending messages to the network.
This attribute is to use for nodes that are not to be exposed to the network.
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.
Ossia provides preset handling. Files can be loaded and save to the disk to set the state of the device tree.