/* This file is part of Ingen.
* Copyright (C) 2007 Dave Robillard These are the commands the engine recognizes. A client can control every
* aspect of the engine entirely with these commands. All commands on this page are in the "control band". If a client needs to
* know about the state of the engine, it must listen to the "notification band".
* See the "Client OSC Namespace Documentation" for details. \b /ingen/ping - Immediately sends a successful response to the given response id.
* \arg \b response-id (integer) \b /ingen/ping_queued - Sends response after going through the event queue.
* \arg \b response-id (integer)
*
* \li See the documentation for /ingen/set_port_value_queued for an explanation of how
* this differs from /ingen/ping. This is useful to send after sending a large cluster of
* events as a sentinel and wait on it's response, to know when the events are all
* finished processing. \b /ingen/quit - Terminates the engine.
* \arg \b response-id (integer)
*
* \li Note that there is NO order guarantees with this command at all. You could
* send 10 messages then quit, and the quit reply could come immediately and the
* 10 messages would never get executed. \b /ingen/register_client - Registers a new client with the engine
* \arg \b response-id (integer) \n\n
* \li The incoming address will be used for the new registered client. If you
* want to register a different specific address, use the URL version. \b /ingen/unregister_client - Unregisters a client
* \arg \b response-id (integer) \b /ingen/load_plugins - Locates all available plugins, making them available for use.
* \arg \b response-id (integer) \b /ingen/activate - Activate the engine (MIDI, audio, everything)
* \arg \b response-id (integer) \b /ingen/deactivate - Deactivate the engine completely.
* \arg \b response-id (integer) \b /ingen/create_patch - Creates a new, empty, toplevel patch.
* \arg \b response-id (integer)
* \arg \b patch-path (string) - Patch path (complete, ie /master/parent/new_patch)
* \arg \b poly (integer) - Patch's (internal) polyphony \b /ingen/rename - Rename an Object (only Nodes, for now)
* \arg \b response-id (integer)
* \arg \b path - Object's path
* \arg \b name - New name for object \b /ingen/enable_patch - Enable DSP processing of a patch
* \arg \b response-id (integer)
* \arg \b patch-path - Patch's path \b /ingen/disable_patch - Disable DSP processing of a patch
* \arg \b response-id (integer)
* \arg \b patch-path - Patch's path \b /ingen/clear_patch - Remove all nodes from a patch
* \arg \b response-id (integer)
* \arg \b patch-path - Patch's path \b /ingen/set_polyphony - Set the polyphony of a patch
* \arg \b response-id (integer)
* \arg \b patch-path - Patch's path
* \arg \b poly (integer) \b /ingen/set_polyphonic - Toggle a node's or port's polyphonic mode
* \arg \b response-id (integer)
* \arg \b path - Object's path
* \arg \b polyphonic (bool) \b /ingen/create_port - Add a port into a given patch (load a plugin by URI)
* \arg \b response-id (integer)
* \arg \b path (string) - Full path of the new port (ie. /patch2/subpatch/newport)
* \arg \b data-type (string) - Type of port (ingen:AudioPort, ingen:ControlPort, ingen:MIDIPort, or ingen:OSCPort)
* \arg \b direction ("is-output") (integer) - Direction of data flow (Input = 0, Output = 1) \b /ingen/create_node - Add a node into a given patch (load a plugin by URI)
* \arg \b response-id (integer)
* \arg \b node-path (string) - Full path of the new node (ie. /patch2/subpatch/newnode)
* \arg \b plug-uri (string) - URI of the plugin to load
* \arg \b polyphonic (boolean) - Whether node is polyphonic \b /ingen/create_node - Add a node into a given patch (load a plugin by libname, label) \b DEPRECATED
* \arg \b response-id (integer)
* \arg \b node-path (string) - Full path of the new node (ie. /patch2/subpatch/newnode)
* \arg \b type (string) - Plugin type ("LADSPA" or "Internal")
* \arg \b lib-name (string) - Name of library where plugin resides (eg "cmt.so")
* \arg \b plug-label (string) - Label (ID) of plugin (eg "sine_fcaa")
* \arg \b poly (boolean) - Whether node is polyphonic
*
* \li This is only here to provide backwards compatibility for old patches that store LADSPA plugin
* references as libname, label. It is to be removed ASAP, don't use it.
* \b /ingen/destroy - Removes (destroys) a Patch or a Node
* \arg \b response-id (integer)
* \arg \b node-path (string) - Full path of the object \b /ingen/connect - Connects two ports (must be in the same patch)
* \arg \b response-id (integer)
* \arg \b src-port-path (string) - Full path of source port
* \arg \b dst-port-path (string) - Full path of destination port \b /ingen/disconnect - Disconnects two ports.
* \arg \b response-id (integer)
* \arg \b src-port-path (string) - Full path of source port
* \arg \b dst-port-path (string) - Full path of destination port \b /ingen/disconnect_all - Disconnect all connections to/from a node/port.
* \arg \b response-id (integer)
* \arg \b patch-path (string) - The (parent) patch in which to disconnect object.
\b /ingen/set_port_value_immediate - Sets the value of a port for all voices (both AR and CR) * \arg \b response-id (integer) * \arg \b port-path (string) - Name of port * \arg \b type (string (URI or QName)) - Type of value being set (ingen:Float or ingen:EventBuffer) * \arg \b value (float or blob) - Value to set port to
\n \n */ /** \page engine_osc_namespace *\b /ingen/set_port_value_immediate - Sets the value of a port for a specific voice (both AR and CR) * \arg \b response-id (integer) * \arg \b port-path (string) - Name of port * \arg \b type (string (URI or QName)) - Type of value being set (ingen:Float or ingen:Event) * \arg \b voice (integer) - Voice to set port value for * \arg \b value (float or blob) - Value to set port to
\n \n * * See documentation for set_port_value for the distinction between these two messages. */ int OSCEngineReceiver::_set_port_value_immediate_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) { if (argc < 3 || argc > 5 || strncmp(types, "is", 2)) return 1; const char* port_path = &argv[1]->s; if (!strcmp(types, "isf")) { // float, all voices const float value = argv[2]->f; set_port_value_immediate(port_path, "ingen:Float", sizeof(float), &value); } else if (!strcmp(types, "isif")) { // float, specific voice const float value = argv[3]->f; set_port_value_immediate(port_path, "ingen:Float", argv[2]->i, sizeof(float), &value); } else if (!strcmp(types, "issb")) { // blob (event), all voices lo_blob b = argv[3]; size_t data_size = lo_blob_datasize(b); void* data = lo_blob_dataptr(b); set_port_value_immediate(port_path, &argv[2]->s, data_size, data); } else if (!strcmp(types, "isisb")) { // blob (event), specific voice lo_blob b = argv[4]; size_t data_size = lo_blob_datasize(b); void* data = lo_blob_dataptr(b); set_port_value_immediate(port_path, &argv[3]->s, argv[2]->i, data_size, data); } else { return 1; } return 0; } /** \page engine_osc_namespace *\b /ingen/set_port_value - Sets the value of a port for all voices (as a QueuedEvent) * \arg \b response-id (integer) * \arg \b port-path (string) - Name of port * \arg \b value (float) - Value to set port to * * \li This is the queued way to set a port value (it is in the same threading class as e.g. * node creation). This way the client can stream a sequence of events which depend on each * other (e.g. a node creation followed by several set_port_value messages to set the node's * controls) without needing to wait on a response to the first (node creation) message. * * There is also a fast "immediate" version of this message, set_port_value_immediate, which * does not have this ordering guarantee.
\n \n */ /** \page engine_osc_namespace *\b /ingen/set_port_value - Sets the value of a port for all voices (as a QueuedEvent) * \arg \b response-id (integer) * \arg \b port-path (string) - Name of port * \arg \b value (float) - Value to set port to * * \li This is the queued way to set a port value (it is in the same threading class as e.g. * node creation). This way the client can stream a sequence of events which depend on each * other (e.g. a node creation followed by several set_port_value messages to set the node's * controls) without needing to wait on a response to the first (node creation) message. * * There is also a fast "immediate" version of this message, set_port_value_immediate, which * does not have this ordering guarantee.
\n \n */ int OSCEngineReceiver::_set_port_value_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) { if (argc < 3 || argc > 5 || strncmp(types, "is", 2)) return 1; const char* port_path = &argv[1]->s; if (!strcmp(types, "isf")) { // float, all voices const float value = argv[2]->f; set_port_value_immediate(port_path, "ingen:Float", sizeof(float), &value); } else if (!strcmp(types, "isif")) { // float, specific voice const float value = argv[3]->f; set_port_value_immediate(port_path, "ingen:Float", argv[2]->i, sizeof(float), &value); } else if (!strcmp(types, "issb")) { // blob (event), all voices lo_blob b = argv[3]; size_t data_size = lo_blob_datasize(b); void* data = lo_blob_dataptr(b); set_port_value_immediate(port_path, &argv[2]->s, data_size, data); } else if (!strcmp(types, "isisb")) { // blob (event), specific voice lo_blob b = argv[4]; size_t data_size = lo_blob_datasize(b); void* data = lo_blob_dataptr(b); set_port_value_immediate(port_path, &argv[3]->s, argv[2]->i, data_size, data); } else { return 1; } return 0; } /** \page engine_osc_namespace *\b /ingen/enable_port_broadcasting - Enable broadcasting of changing port values * \arg \b response-id (integer) * \arg \b port-path (string) - Name of port
\n \n */ int OSCEngineReceiver::_enable_port_broadcasting_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) { const char* port_path = &argv[1]->s; enable_port_broadcasting(port_path); return 0; } /** \page engine_osc_namespace *\b /ingen/disable_port_broadcasting - Enable broadcasting of changing port values * \arg \b response-id (integer) * \arg \b port-path (string) - Name of port
\n \n */ int OSCEngineReceiver::_disable_port_broadcasting_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) { const char* port_path = &argv[1]->s; disable_port_broadcasting(port_path); return 0; } /** \page engine_osc_namespace *\b /ingen/note_on - Triggers a note-on, just as if it came from MIDI * \arg \b response-id (integer) * \arg \b node-path (string) - Patch of Node to trigger (must be a trigger or note node) * \arg \b note-num (int) - MIDI style note number (0-127) * \arg \b velocity (int) - MIDI style velocity (0-127)
\n \n */ int OSCEngineReceiver::_note_on_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) { /* const char* node_path = &argv[1]->s; const uchar note_num = argv[2]->i; const uchar velocity = argv[3]->i; */ cerr << "FIXME: OSC note on\n"; //note_on(node_path, note_num, velocity); return 0; } /** \page engine_osc_namespace *\b /ingen/note_off - Triggers a note-off, just as if it came from MIDI * \arg \b response-id (integer) * \arg \b node-path (string) - Patch of Node to trigger (must be a trigger or note node) * \arg \b note-num (int) - MIDI style note number (0-127)
\n \n */ int OSCEngineReceiver::_note_off_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) { /* const char* patch_path = &argv[1]->s; const uchar note_num = argv[2]->i; */ cerr << "FIXME: OSC note off\n"; //note_off(patch_path, note_num); return 0; } /** \page engine_osc_namespace *\b /ingen/all_notes_off - Triggers a note-off for all voices, just as if it came from MIDI * \arg \b response-id (integer) * \arg \b patch-path (string) - Patch of patch to send event to
\n \n */ int OSCEngineReceiver::_all_notes_off_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) { /* const char* patch_path = &argv[1]->s; */ cerr << "FIXME: OSC all notes off\n"; //all_notes_off(patch_path); return 0; } /** \page engine_osc_namespace *\b /ingen/midi_learn - Initiate MIDI learn for a given (MIDI Control) Node * \arg \b response-id (integer) * \arg \b node-path (string) - Patch of the Node that should learn the next MIDI event. * * \li This of course will only do anything for MIDI control nodes. The node will learn the next MIDI * event that arrives at it's MIDI input port - no behind the scenes voodoo happens here. It is planned * that a plugin specification supporting arbitrary OSC commands for plugins will exist one day, and this * method will go away completely.
\n \n */ int OSCEngineReceiver::_midi_learn_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) { const char* patch_path = &argv[1]->s; midi_learn(patch_path); return 0; } /** \page engine_osc_namespace *\b /ingen/set_variable - Sets a piece of variable, associated with a synth-space object (node, etc) * \arg \b response-id (integer) * \arg \b object-path (string) - Full path of object to associate variable with * \arg \b key (string) - Key (index) for new piece of variable * \arg \b value (string) - Value of new piece of variable
\n \n */ int OSCEngineReceiver::_variable_set_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) { if (argc != 4 || types[0] != 'i' || types[1] != 's' || types[2] != 's') return 1; const char* object_path = &argv[1]->s; const char* key = &argv[2]->s; Raul::Atom value = Raul::AtomLiblo::lo_arg_to_atom(types[3], argv[3]); set_variable(object_path, key, value); return 0; } /** \page engine_osc_namespace *\b /ingen/request_variable - Requests the engine send a piece of variable, associated with a synth-space object (node, etc) * \arg \b response-id (integer) * \arg \b object-path (string) - Full path of object variable is associated with * \arg \b key (string) - Key (index) for piece of variable * * \li Reply will be sent to client registered with the source address of this message.
\n \n */ int OSCEngineReceiver::_variable_get_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) { const char* object_path = &argv[1]->s; const char* key = &argv[2]->s; request_variable(object_path, key); return 0; } /** \page engine_osc_namespace *\b /ingen/request_plugin - Requests the engine send the value of a port. * \arg \b response-id (integer) * \arg \b port-path (string) - Full path of port to send the value of \n\n * \li Reply will be sent to client registered with the source address of this message.
\n\n */ int OSCEngineReceiver::_request_plugin_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) { const char* uri = &argv[1]->s; request_plugin(uri); return 0; } /** \page engine_osc_namespace *\b /ingen/request_object - Requests the engine send the value of a port. * \arg \b response-id (integer) * \arg \b port-path (string) - Full path of port to send the value of \n\n * \li Reply will be sent to client registered with the source address of this message.
\n\n */ int OSCEngineReceiver::_request_object_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) { const char* object_path = &argv[1]->s; request_object(object_path); return 0; } /** \page engine_osc_namespace *\b /ingen/request_port_value - Requests the engine send the value of a port. * \arg \b response-id (integer) * \arg \b port-path (string) - Full path of port to send the value of \n\n * \li Reply will be sent to client registered with the source address of this message.
\n\n */ int OSCEngineReceiver::_request_port_value_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) { const char* port_path = &argv[1]->s; request_port_value(port_path); return 0; } /** \page engine_osc_namespace *\b /ingen/request_plugins - Requests the engine send a list of all known plugins. * \arg \b response-id (integer) \n\n * \li Reply will be sent to client registered with the source address of this message.
\n\n */ int OSCEngineReceiver::_request_plugins_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) { request_plugins(); return 0; } /** \page engine_osc_namespace *\b /ingen/request_all_objects - Requests the engine send information about \em all objects (patches, nodes, etc) * \arg \b response-id (integer)\n\n * \li Reply will be sent to client registered with the source address of this message.
\n \n */ int OSCEngineReceiver::_request_all_objects_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) { request_all_objects(); return 0; } // Static Callbacks // // Display incoming OSC messages (for debugging purposes) int OSCEngineReceiver::generic_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg, void* user_data) { printf("[OSCMsg] %s (%s)\t", path, types); for (int i=0; i < argc; ++i) { lo_arg_pp(lo_type(types[i]), argv[i]); printf("\t"); } printf("\n"); return 1; // not handled } int OSCEngineReceiver::unknown_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg, void* user_data) { const lo_address addr = lo_message_get_source(msg); char* const url = lo_address_get_url(addr); cerr << "Unknown command " << path << " (" << types << "), sending error.\n"; string error_msg = "Unknown command: "; error_msg.append(path).append(" ").append(types); OSCClientSender(url).error(error_msg); return 0; } } // namespace Ingen