tur/msg
osc-message
(osc-message [address])
Allocate a new OSC message for the given address.
| address | OSC address pattern string (e.g., "/s_new"). |
Opaque pointer to the allocated message. Must be freed with osc-free! if not consumed by osc-send!. (let [m (osc-message "/s_new")] (osc-free! m))
osc-free!
(osc-free! [msg])
Free an OSC message, ignoring nil/null pointers.
| msg | Opaque message pointer returned by osc-message. |
(osc-free! msg)
osc-add!
(osc-add! [msg arg])
Append a typed argument to an OSC message.
| msg | OSC message pointer. | |
| arg | Value to append (int32, float, cstr, or slice<uint8>). |
(osc-add! msg 440.0)
osc-send!
(osc-send! [world_id msg])
Send an OSC message to a world and free it afterward.
| world_id | Target world handle. | |
| msg | OSC message pointer (will be freed after sending). |
0 on success, -1 on error. (osc-send! w msg)
osc-send
(osc-send [world_id address & args])
Build and send an OSC message in a single call.
| world_id | Target world handle. | |
| address | OSC address pattern string. | |
| args | Zero or more arguments to append to the message. |
0 on success, -1 on error. (osc-send w "/s_new" "mySynth" 1001 2 1)
with-osc-message
(with-osc-message [msg-var address])
Build and send an OSC message with automatic cleanup.
| msg-var | Symbol to bind the new message pointer to. | |
| address | OSC address pattern string. | |
| world_id | Target world handle. | |
| body | Forms that add arguments or otherwise manipulate the message. |
(with-osc-message [m "/n_set"] w
(osc-add! m 1001)
(osc-add! m 0)
(osc-add! m 440.0))
osc-ping
(osc-ping [world_id])
Send a /ping message to check server responsiveness.
| world_id | Target world handle. |
0 on success, -1 on error.
osc-status
(osc-status [world_id])
Send a /status message to query server state.
| world_id | Target world handle. |
0 on success, -1 on error.
osc-sync
(osc-sync [world_id])
Send a /sync message to synchronize with the server.
| world_id | Target world handle. |
0 on success, -1 on error.
osc-s_new
(osc-s_new [world_id synthdef_name node_id add_action target & args])
Send a /s_new message to instantiate a SynthDef.
| world_id | Target world handle. | |
| synthdef_name | Name of the SynthDef to instantiate. | |
| node_id | Node ID to assign (0 for auto-allocate). | |
| add_action | Placement action keyword or integer. | |
| target | Target node ID (typically ROOT_GROUP_ID = 1). | |
| args | Additional control parameter values. |
0 on success, -1 on error. (osc-s_new w "mySynth" 1001 2 1)
osc-n_set
(osc-n_set [world_id node_id & param-value-pairs])
Send a /n_set message to update control parameters on a node.
| world_id | Target world handle. | |
| node_id | Target synth node ID. | |
| param-value-pairs | Alternating parameter name and value pairs. |
0 on success, -1 on error. (osc-n_set w 1001 "freq" 880.0 "amp" 0.5)
osc-n_free
(osc-n_free [world_id node_id])
Send a /n_free message to stop and remove a node.
| world_id | Target world handle. | |
| node_id | Node ID to free. |
0 on success, -1 on error.
osc-n_run
(osc-n_run [world_id node_id run?])
Send a /n_run message to start or pause a node.
| world_id | Target world handle. | |
| node_id | Target node ID. | |
| run? | true to run, false to pause. |
0 on success, -1 on error.
osc-n_free_all
(osc-n_free_all [world_id])
Send a /n_free_all message to clear every node.
| world_id | Target world handle. |
0 on success, -1 on error.
osc-g_new
(osc-g_new [world_id node_id add_action target])
Send a /g_new message to create a new group node.
| world_id | Target world handle. | |
| node_id | Node ID to assign (0 for auto-allocate). | |
| add_action | Placement action. | |
| target | Target node ID. |
0 on success, -1 on error. (osc-g_new w 100 2 1)
osc-g_free
(osc-g_free [world_id node_id])
Send a /g_free message to free a group node.
| world_id | Target world handle. | |
| node_id | Group node ID to free. |
0 on success, -1 on error.
osc-d_load
(osc-d_load [world_id synthdef_name])
Send a /d_load message to load a SynthDef by name.
| world_id | Target world handle. | |
| synthdef_name | SynthDef name or file path. |
0 on success, -1 on error.
osc-d_free
(osc-d_free [world_id synthdef_name])
Send a /d_free message to unload a SynthDef.
| world_id | Target world handle. | |
| synthdef_name | Name of the SynthDef to remove. |
0 on success, -1 on error.
osc-d_recv
(osc-d_recv [world_id on?])
Send a /d_recv message to toggle SynthDef-receive notifications.
| world_id | Target world handle. | |
| on? | true to enable, false to disable. |
0 on success, -1 on error.
osc-notify
(osc-notify [world_id on?])
Send a /notify message to toggle server notifications.
| world_id | Target world handle. | |
| on? | true to enable, false to disable. |
0 on success, -1 on error.
osc-clear-sched
(osc-clear-sched [world_id])
Send a /clearSched message to flush the scheduler queue.
| world_id | Target world handle. |
0 on success, -1 on error.
midi->hz
(midi->hz [note])
Convert a MIDI note number to frequency in Hz.
| note | MIDI note number (0-127; 69 = A4 = 440 Hz). |
Frequency in Hz as a float. (midi->hz 69) ; => 440.0
vel->amp
(vel->amp [vel])
Convert a MIDI velocity to a linear amplitude value.
| vel | MIDI velocity (0-127). |
Amplitude in the range [0.0, 1.0]. (vel->amp 127) ; => 1.0
db->amp
(db->amp [db])
Convert a decibel level to linear amplitude.
| db | Level in decibels (0 dB = amplitude 1.0). |
Linear amplitude as a float. (db->amp 0.0) ; => 1.0
amp->db
(amp->db [amp])
Convert a linear amplitude to decibels.
| amp | Linear amplitude (must be > 0; returns -90.0 for zero). |
Level in decibels. (amp->db 1.0) ; => 0.0