SuperCollider 3.9dev Classes (extension) | External Control > OSC

OSCCommands
ExtensionExtension

A utility-class that let's you collect OSC command-names form incoming OSC
Inherits from: Object

Description

OSCCommands implements a couple of methods that let the user collect OSC command-names (including their path/namespace - e.g. '/my, super/long/and/winding/pth/to/cmdname' - resp. the number of addressable msg-slots. E.g. from an orientation-sensor: [ '/cmdname', <x-value>, <y-value>, <z-value> ] (one command-name, 3 slots). Collected command-names can be stored to disk under a name set by the user. For convenience OSCCommands has its own GUI which shows the user which names have already been collected resp. allowing her/him to remove unwanted names from the list. Command-names will be stored to disk in a file named "OSCCommands" in the same directory as the class-file itself.

Class Methods

OSCCommands.collect(play: true)

Starts the collection-process when set to true. Stop the process by calling the same method, argument play set to false

Arguments:

play

a Boolean, indicating whether the process shall be started or stopped - default: true

Returns:

this (OSCCommands)

OSCCommands.collectTempIPsAndCmds(play: true)

Collect OSC command-names and the sizes of their messages (i.e. how many slots are sent within the message). Command-names will be stored in *tempIPsAndCmds, an Event, under a key thats made up of a combination of the IP-address and port: <IP-address>:<port>.

OSCCommands.collectTempIPsAndCmds // invoke collection
OSCCommands.tempCollectRunning // should return true
OSCCommands.tempIPsAndCmds // see what has come in already
/* send some OSC to sclang... */
OSCCommands.tempIPsAndCmds // now there should be something
OSCCommands.collectTempIPsAndCmds(false) // stop collecting
OSCCommands.tempCollectRunning // should return false now

Arguments:

play

a Boolean, indicating whether the process shall be started or stopped - default: true

Returns:

this (OSCCommands)

OSCCommands.saveCmdSet(deviceName)

Save the current list of commands to disk.

Arguments:

deviceName

a String or a Symbol representing the name of the current collection. If the collection-process is still active it will be stopped.

Returns:

this (OSCCommands)

OSCCommands.front

Open the interactive GUI that shows the user all currently collected command-names resp. remove unwanted names.

Returns:

this (OSCCommands)

OSCCommands.window

The Window created when calling *front.

Returns:

OSCCommands.deviceCmds(deviceName)

If a deviceName has been given return an Event with command-names stored to disk under the device-name deviceName. Else return an Event with all currently stored commands resp. their keys.

Arguments:

deviceName

a String or a Symbol representing the name under which the list of commands has been stored.

Returns:

an Event

OSCCommands.clearCmdsAt(deviceName)

Removes all commands stored to disk under the name given in deviceName.

Arguments:

deviceName

a String or a Symbol

Returns:

this (OSCCommands)

OSCCommands.storedDevices

Returnes a Set of all currently stored device-names.

Returns:

a Set

OSCCommands.tempIPsAndCmds

an Event keeping command-names and IP-addresses/ports collected by *collectTempIPsAndCmds

Returns:

an Event

OSCCommands.tempCollectRunning

Indicate whether a process invoked by *collectTempIPsAndCmds is currently running or not.

Returns:

Inherited class methods

Undocumented class methods

OSCCommands.makeWindow

Instance Methods

Inherited instance methods

Examples

For the following example you will have to have installed an application capable of sending OSC-messages somewhere in your local network (it might be e.g. an application on your computer or some OSC-controller on a mobile phone). Very likely you will have to tell this application to send its output to the IP-address of the computer where SuperCollider is running resp. to the receiving port of SC which is by default 57120 (setting a non-standard port should work using SC >= 3.5).

// most easy
OSCCommands.front;

// start the collecting-process
// the application sending OSC-commands should be up and running
OSCCommands.collect(true);

/**************************************************************************
wiggle your phone, slide over your touchpad,
do anything with your device that could make it send an OSC-message

do this for at least a few seconds...
**************************************************************************/

// save the collected commands to disk
// the collection-process will stop automatically
// you may replace \myAppOrDeviceName with e.g. \TouchOSC or whatever seems suitable
OSCCommands.saveCmdSet(\myAppOrDeviceName);

// see what's been stored under \myAppOrDeviceName
// if no deviceName is given return ALL stored commands
OSCCommands.deviceCmds(\myAppOrDeviceName);

// see stored deviceNames
OSCCommands.storedDevices;

// delete a stored device including its command-names
OSCCommands.clearCmdsAt(\myAppOrDeviceName);