| examples | cryoscopy | |
| oscule | cryoscopy | |
| test | cryoscopy | |
| LICENSE | cryoscopy | |
| progress.org | cryoscopy | |
| project.janet | cryoscopy | |
| README.org | cryoscopy | |
Open Sound Control
An implementation of the Open Sound Control protocol (or more accurately "data transport specification" or "encoding") in Janet. Provides self-contained encoding and decoding of OSC data, messages, and bundles. OSC describes a transport-independent encoding and does not specify a transport layer, messages can be sent using UDP, TCP, or other protocols. More details at https://OpenSoundControl.org
Translated to janet based on cl-osc https://github.com/zzkt/osc
OSC 1.0 and 1.1 support
Supports the OpenSoundControl Specification 1.0 and the required typetags listed in the OpenSoundControl Specification 1.1 (as described in an NIME 2009 paper).
- R = Required, O = Optional
Usage
(importoscule:asosc)# encode a message(defmsg(osc/encode-message"/filter"12.0"three"))# decode a message(defdecoded(osc/decode-messagemsg))(decoded:address)# returns "/filter"(decoded:args)# returns @[1 2.0 "three"]# encode a bundle with timetag(defbundle(osc/encode-bundle:now(osc/encode-message"/start"0.0)(osc/encode-message"/stop"1.0)))# decode a bundle(defbd(osc/decode-bundlebundle))(bd:timetag)# returns (0 1) for :now(bd:elements)# returns array of messages
Or without a prefix...
(importoscule:prefix"")(encode-message"/filter"12.0"three")
API
Encoding messages and bundles
(encode-message address & args)→ :string — encode an OSC message.(encode-bundle timetag & elements)→ :string — encode a bundle.
Decoding messages and bundles
(decode-message data)→ {:address string :args array} — decode a message.(decode-bundle data)→ {:timetag array :elements array} — decode a bundle.
Networked transmission via UPD
(osc-send host port address & args)Send an OSC message to host:port via UDP.(osc-receive port)Receive an OSC message on the given UDP port.
Printing messages
(message->string msg)Converts an OSC message to a string.
In most cases the correct type should be inferred, however it may be necessary to explicitly encode specific data. Strings in particular may need to be explicitly encoded as ASCII or UTF-8 for compatibility with some other implementations.
(encode-int32 n)→ :string — encode a 32-bit signed integer(decode-int32 data pos)→ :number — decode int32 from position(decode-uint32 data pos)→ :number — decode unsigned 32-bit(encode-float32 f)→ :string — encode a single-precision float(decode-float32 data pos)→ :number — decode float32(decode-float64 data pos)→ :number — decode double-precision float(encode-string s)→ :string — encode (ASCII) string with null padding(decode-string data pos)→ :string — decode null-terminated string(encode-string-utf8 S)→ :string — encode UTF-8 string (i.e. alternate OSC-string?)(encode-blob b)→ :string — encode blob with length prefix(encode-timetag t)→ :string — encode timetag (:now or [second fraction])(encode-char c)→ :string — encode a character as 32-bit integer(encode-rgba r g b a)→ :string — encode RGBA colour as 4 bytes(encode-midi port status data1 data2)→ :string — encode 4-byte MIDI message(decode-char data pos)→ :number — decode 32-bit character value(decode-rgba data pos)→ [r g b a] — decode RGBA colour(decode-midi data pos)→ [port status data1 data2] — decode MIDI message