API
Types
OSC.OSCBlob — TypeOSCBlob type to send blob elements via OSC. Consists of the 32 bit size and the corresponding data vector.
OSC.OSCBundle — TypeOSCBundle type consisting of a timetag and a vector of BundleElements.
OSC.OSCBundleElement — TypeParent type for elements in an OSCBundle. Consists of the element size and its content.
OSC.OSCMessage — TypeBasic 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.
OSC.OSCParseException — TypeException indicating an error while parsing an OSCMessage or OSCBundle from an input buffer.
Encode and Parse
OSC.encodeOSC — MethodencodeOSC(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]OSC.encodedOSCSize — MethodencodedOSCSize(msg)
encodedOSCSize(bundle)Calculate the encoded size of the given msg or bundle in bytes.
OSC.parseOSC — MethodparseOSC(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[]Client
OSC.OSCClientUDP — TypeClient for sending OSC messages via UDP. Creates its own UDP socket. On send, it enforces that the packet does not excceed the max_payload.
Server and Matching
OSC.OSCServerUDP — TypeOSC 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/abc123etc.timed_callbacks- iftrue, read the timestamps of incoming bundles and execute their contents at the provided time. Timestamps in the past are executed immediately.
OSC.listenForever — MethodlistenForever(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.
OSC.matchOSC — MethodmatchOSC(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}")
trueValidate
OSC.validateOSC — MethodvalidateOSC(msg, data)
validateOSC(bundle, data)Check whether the given msg or bundle matches the OSC output data.