Methcla uses OpenSoundControl (OSC) as a serialisation format for commands sent from one or more application threads to the engine. This allows to keep the C API small and doesn't require packing C structures from other programming languages, which can be difficult and non-portable.
Methcla_Error methcla_engine_send(Methcla_Engine* engine, const void* packet, size_t size);
Send an OSC packet (data and size) to the engine.
Methcla_Time methcla_engine_current_time(const Methcla_Engine* engine);
Get the current engine time as a Methcla_Time value (currently double precision float in seconds).
uint64_t methcla_time_to_uint64(Methcla_Time time);
Encode a Methcla_Time value as a 64 bit unsigned integer for use as an OSC bundle timestamp.
Used by /group/new and /synth/new to specify where a new node is inserted relative to target-id:
| Constant | Meaning |
|---|---|
kMethcla_NodePlacementHeadOfGroup |
head of target group |
kMethcla_NodePlacementTailOfGroup |
tail of target group |
kMethcla_NodePlacementBeforeNode |
immediately before target node |
kMethcla_NodePlacementAfterNode |
immediately after target node |
-
/group/newi:node-id i:target-id i:target-specCreate a new group with id
node-idand insert it into the node tree relative totarget-idaccording totarget-spec. -
/group/freeAlli:node-idFree all child nodes of the group
node-id, keeping the group itself alive. -
/synth/news:definition-name i:node-id i:target-id i:target-spec [f:synth-controls] [synth-options]Create a new synth with id
node-idfrom the synth definitiondefinition-nameand insert it into the node tree relative totarget-idaccording totarget-spec.synth-controlsis an array of initial control values; its length must match the number of control inputs provided by the synth.synth-optionsis an array of options passed to the synth constructor; it may be empty and its interpretation depends on the synth definition. -
/synth/activatei:node-idActivate a synth after it has been created. In order to produce output, each
/synth/newmust be followed by/synth/activate. The intention is to be able to do useful asynchronous work (such as loading a soundfile) in the synth constructor by performing/synth/newinstantly and scheduling/synth/activateinto the future by the desired amount so as to compensate for the I/O latency and jitter. -
/synth/map/inputi:node-id i:index i:bus-id i:flagsMap a synth's audio input
indextobus-id. Flags may be one of-
kMethcla_BusMappingInternal = 0x00Map to an internal audio bus.
-
kMethcla_BusMappingExternal = 0x01Map to an external (hardware) audio bus.
-
kMethcla_BusMappingFeedback = 0x02Don't zero bus before reading, allowing feedback loops with a delay of one block size.
-
kMethcla_BusMappingReplace = 0x04Zero bus before reading (default).
-
-
/synth/map/outputi:node-id i:index i:bus-id i:flagsMap a synth's audio output
indextobus-id. Flags may be one of-
kMethcla_BusMappingInternal = 0x00Map to an internal audio bus.
-
kMethcla_BusMappingExternal = 0x01Map to an external (hardware) audio bus.
-
kMethcla_BusMappingFeedback = 0x02Mix output with previous bus contents (default).
-
kMethcla_BusMappingReplace = 0x04Replace bus contents by output.
-
-
/synth/property/doneFlags/seti:node-id i:flagsSet the done-action flags for a synth.
flagsis a bitmask of:Constant Effect when synthDonefireskMethcla_NodeDoneDoNothingnothing — synth goes silent but stays allocated kMethcla_NodeDoneFreeSelffree this synth kMethcla_NodeDoneFreePreceedingfree the node immediately before this one kMethcla_NodeDoneFreeFollowingfree the node immediately after this one kMethcla_NodeDoneFreeAllSiblingsfree all other nodes in the same group kMethcla_NodeDoneFreeParentfree the parent group kMethcla_NodeDoneNotifysend a /node/donenotification to the host -
/node/freei:node-idFree a node and all associated resources. Freeing a group frees all its children recursively.
-
/node/seti:node-id i:index f:valueSet a synth's control input at
indexto the specified value.
These messages take a request-id and return a response message at the same address. On error the engine responds with /error instead (see below).
-
/node/tree/statisticsi:request-idRequest node tree statistics. Response:
/node/tree/statisticsi:num-groups i:num-synths -
/engine/realtime-memory/statisticsi:request-idRequest realtime memory statistics. Response:
/engine/realtime-memory/statisticsi:free-bytes i:used-bytes
The engine sends these messages to the host without a corresponding request. They arrive on the packet handler registered via methcla_engine_options_set_packet_handler with requestId == kMethcla_Notification.
-
/node/donei:node-idSent when a synth signals completion (
synthDone) andkMethcla_NodeDoneNotifyis set in its done flags. -
/node/endedi:node-idSent unconditionally when any node is freed (by any means, including
/node/free, done-action flags, or parent group teardown).
-
/errori:error-code s:messageReturned in place of the normal response when a query fails, or dispatched as a notification when a command fails.
error-codeis aMethcla_ErrorCodevalue.