API

Types

OSC.OSCBlobType

OSCBlob type to send blob elements via OSC. Consists of the 32 bit size and the corresponding data vector.

source
OSC.OSCBundleType

OSCBundle type consisting of a timetag and a vector of BundleElements.

source
OSC.OSCMessageType

Basic OSCMessage consisting of an address, format and a list of args. Contents are in parsed form, meaning the initial ',' in the format string or any trailing null bytes in the data are not present here.

source

Encode and Parse

OSC.encodeOSCMethod
encodeOSC(msg)
encodeOSC(bundle)

Encode the given msg or bundle into its network output byte vector.

Examples

julia> println(encodeOSC(OSCMessage(StringView("/test"), StringView("T"), true)))
UInt8[0x2f, 0x74, 0x65, 0x73, 0x74, 0x00, 0x00, 0x00, 0x2c, 0x54, 0x00, 0x00]


julia> println(encodeOSC(OSCBundle(UInt64(1234), [OSCBundleElement(OSCMessage(StringView("/test"), StringView("T"), true))])))
UInt8[0x23, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xd2, 0x00, 0x00, 0x00, 0x0c, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x00, 0x00, 0x00, 0x2c, 0x54, 0x00, 0x00]
source
OSC.encodedOSCSizeMethod
encodedOSCSize(msg)
encodedOSCSize(bundle)

Calculate the encoded size of the given msg or bundle in bytes.

source
OSC.parseOSCMethod
parseOSC(buffer)

Parse buffer into an OSCBundle if it starts with '#bundle'. Otherwise parse buffer into an OSCMessage

Examples

julia> parseOSC(UInt8[0x2f, 0x74, 0x65, 0x73, 
                      0x74, 0x00, 0x00, 0x00, 0x2c, 
                      0x00, 0x00, 0x00])
OSCMessage:
address: /test
format: 
args: Any[]

julia> parseOSC(UInt8[0x23, 0x62, 0x75, 0x6e, 
                      0x64, 0x6c, 0x65, 0x00, 
                      0x00, 0x00, 0x00, 0x00, 
                      0x00, 0x00, 0x04, 0xd2, 
                      0x00, 0x00, 0x00, 0x0c, 
                      0x2f, 0x74, 0x65, 0x73, 
                      0x74, 0x00, 0x00, 0x00, 
                      0x2c, 0x00, 0x00, 0x00])
OSCBundle:
timetag: 1234

element:OSCBundleElement:
size: 12
content: OSCMessage:
address: /test
format: 
args: Any[]
source

Client

OSC.OSCClientUDPType

Client for sending OSC messages via UDP. Creates its own UDP socket. On send, it enforces that the packet does not excceed the max_payload.

source

Server and Matching

OSC.OSCServerUDPType

OSC Server for handling OSC packages coming in via UDP. Dispatches messages to callback functions defined by match_callbacks.

Additional flags:

  • invert_matching - allow OSC address patterns in match_callbacks and receive addresses from client. This allows a callback like "/addr/*" -> callback() to be invoked by incoming messages with address /addr/abc123 etc.
  • timed_callbacks - if true, read the timestamps of incoming bundles and execute their contents at the provided time. Timestamps in the past are executed immediately.
source
OSC.listenForeverMethod
listenForever(srv)

Continuously try to read data from the srv.socket. When a packet is read it is parsed to an OSCMessage or OSCBundle and the message contents are dispatched via the match_callbacks dictionary.

source
OSC.matchOSCMethod
matchOSC(address, patter)

Check whether the address matches the provided pattern as per the OSC path specification.

Examples


julia> matchOSC("/test", "/test")
true

julia> matchOSC("/test", "/*")
true

julia> matchOSC("/some/long/addr", "//addr")
true

julia> matchOSC("/dont/match/me", "/*/match")
false

julia> matchOSC("/do/match/me", "/*/match/me")
true

julia> matchOSC("/do/match/me/5", "/*/match/me/[0-9]")
true

julia> matchOSC("/wild/card", "/{card,wild}/{card,wild}")
true
source

Validate

OSC.validateOSCMethod
validateOSC(msg, data)
validateOSC(bundle, data)

Check whether the given msg or bundle matches the OSC output data.

source