Skip to content

max o2 objects

rbdannenberg edited this page Jan 19, 2017 · 5 revisions

O2 Objects

o2send [applicationName [master]]

creates the ability to send O2 messages using UDP. If applicationName (a string) is provided or edited, it is equivalent to sending the name to inlet 2. If the special string "master" is also provided, it is equivalent to sending the name followed by an integer to inlet 2.

  • inlet 1: a message (see Message Format below)
  • inlet 2: a string (applicationName) or an integer. If a non-empty applicationName arrives at the inlet, and an applicationName has not already been provided, O2 is initialized with the applicationName. If O2 has already been initialized with a different applicationName, O2 is shut down and restarted with the new applicationName. If the string is empty, O2 is shut down (if running). If the input is an integer and O2 is initialized, this O2 process becomes the master clock. Once the process becomes the master clock, this state cannot be revoked except by changing applicationName, which forces O2 to be shut down. After O2 is restarted, it will become the master again if "master" was indicated; otherwise, it will become the master only after an integer is sent to this inlet.

There are no outputs.

If there are multiple o2send and o2sendcmd objects, the first one to provide an applicationName "owns" the right to name the application, and inlet 2 is ignored on all other o2send/o2sendcmd objects.

o2sendcmd [applicationName [master]]

is exactly like o2send except it sends messages via TCP.

o2status [servicename]

provides the status of a service. If servicename is provided after "o2status" (or edited), it is equivalent to sending servicename to inlet 2.

  • inlet 1 - any input, including Bang, gets the current status of the service.
  • inlet 2 - the service name

Output values are: -1 (the service is unknown), 0 (the service is local, clock sync is not established), 1 (the service is remote, clock sync is not established; perhaps the local or remote process has clock sync, but not both), 4 (the service is local and clock sync is established), 5 (the service is remote and clock sync is established).

o2time

gets the current o2time if clock sync has been established.

  • inlet 1 - any input, including Bang, gets the current time.

Output value is a float indicating seconds from the approximate initialization time of this O2 application. If clock sync has not been obtained, -1 is output.

Message Format

Inlet 1 receives a list consisting of

  • a full O2 address, e.g. /service1/node1/node2 or !service1/freq
  • a timestamp, which may be 0.0
  • zero or more floats, ints, and strings A type string is constructed, consisting of "f", "i", and "s". Other O2 types are not supported. The message is sent as an O2 message to the indicated service. If the service does not exist or if the timestamp is non-zero and clock-sync has not been obtained, the message is dropped according to normal O2 behavior.

Clone this wiki locally