static gchar * gst_lv2_filter_class_get_param_name (GstLV2FilterClass * klass, const LilvPort * port) { LilvPlugin *lv2plugin = klass->plugin; gchar *ret; ret = g_strdup (lilv_node_as_string (lilv_port_get_symbol (lv2plugin, port))); /* this is the same thing that param_spec_* will do */ g_strcanon (ret, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-'); /* satisfy glib2 (argname[0] must be [A-Za-z]) */ if (!((ret[0] >= 'a' && ret[0] <= 'z') || (ret[0] >= 'A' && ret[0] <= 'Z'))) { gchar *tempstr = ret; ret = g_strconcat ("param-", ret, NULL); g_free (tempstr); } /* check for duplicate property names */ if (g_object_class_find_property (G_OBJECT_CLASS (klass), ret)) { gint n = 1; gchar *nret = g_strdup_printf ("%s-%d", ret, n++); while (g_object_class_find_property (G_OBJECT_CLASS (klass), nret)) { g_free (nret); nret = g_strdup_printf ("%s-%d", ret, n++); } g_free (ret); ret = nret; } GST_DEBUG ("built property name '%s' from port name '%s'", ret, lilv_node_as_string (lilv_port_get_symbol (lv2plugin, port))); return ret; }
Lv2Plugin::Lv2Plugin(const LilvPlugin *plugin, LilvInstance *instance, const Lv2Constants &uris, Lv2Worker *worker) : plugin(plugin), instance(instance), midiOutputCount(0), controlConnections(4), newControlMappingsQueue(16), worker(worker) { // audio inputs audioInputCount = lilv_plugin_get_num_ports_of_class(plugin, uris.lv2AudioPort, uris.lv2InputPort, 0); audioInputIndex = new uint32_t[audioInputCount]; audioInput = new AudioConnector[audioInputCount]; // audio outputs audioOutputCount = lilv_plugin_get_num_ports_of_class(plugin, uris.lv2AudioPort, uris.lv2OutputPort, 0); audioOutputIndex = new uint32_t[audioOutputCount]; audioOutput = new AudioConnection*[audioOutputCount]; for(uint32_t i = 0; i < audioOutputCount; i++) { audioOutput[i] = new AudioConnection(this); audioOutput[i]->clear(); } // initialize port structures uint32_t numPorts = lilv_plugin_get_num_ports(plugin); uint32_t audioInputCounter = 0; uint32_t audioOutputCounter = 0; for(uint32_t i = 0; i < numPorts; i++) { const LilvPort *port = lilv_plugin_get_port_by_index(plugin, i); if(lilv_port_is_a(plugin, port, uris.lv2AudioPort)) { if(lilv_port_is_a(plugin, port, uris.lv2InputPort)) { audioInputIndex[audioInputCounter++] = i; } else if(lilv_port_is_a(plugin, port, uris.lv2OutputPort)) { audioOutputIndex[audioOutputCounter++] = i; } } else if(lilv_port_is_a(plugin, port, uris.lv2ControlPort) && lilv_port_is_a(plugin, port, uris.lv2InputPort)) { // get control name const LilvNode* symbol = lilv_port_get_symbol(plugin, port); std::string portName(lilv_node_as_string(symbol)); // create, connect and hash new control port object Lv2ControlPort *newPort = new Lv2ControlPort(); LilvNode *dfault, *minimum, *maximum; lilv_port_get_range(plugin, port, &dfault, &minimum, &maximum); newPort->dfault = dfault ? lilv_node_as_float(dfault) : 0; newPort->minimum = lilv_node_as_float(minimum); newPort->maximum = lilv_node_as_float(maximum); lilv_instance_connect_port(instance, i, &(newPort->value)); controlMap[portName] = newPort; } else if(lilv_port_is_a(plugin, port, uris.lv2AtomPort)) { // is it a MIDI/atom input? LilvNodes *atomBufferType = lilv_port_get_value(plugin, port, uris.lv2AtomBufferType); LilvNodes* atomSupports = lilv_port_get_value(plugin, port, uris.lv2AtomSupports); if (lilv_port_is_a(plugin, port, uris.lv2InputPort) && lilv_nodes_contains(atomBufferType, uris.lv2AtomSequence) && lilv_nodes_contains(atomSupports, uris.lv2MidiEvent)) { // create new inputs and connect to atom sequence location Lv2MidiInput *newAtomPort = new Lv2MidiInput(); lilv_instance_connect_port(instance, i, newAtomPort->getAtomSequence()); midiInputList.add(newAtomPort); } else if (lilv_port_is_a(plugin, port, uris.lv2OutputPort)) { //atomSequence->atom.type = Lv2PluginFactory::instance()->uridMapper.uriToId(LV2_ATOM__Sequence); Lv2MidiOutput *midiOutput = new Lv2MidiOutput(this); lilv_instance_connect_port(instance, i, midiOutput->getAtomSequence()); midiOutputList.add(midiOutput); midiOutputCount++; } else { // warn std::cout << "!!! unknown atom port at index " << i << ": " << lilv_node_as_string(lilv_port_get_name(plugin, port)) << std::endl; } lilv_nodes_free(atomSupports); lilv_nodes_free(atomBufferType); } else { lilv_instance_connect_port(instance, i, NULL); std::cout << "!!! unknown port at index " << i << ": " << lilv_node_as_string(lilv_port_get_name(plugin, port)) << std::endl; } } }