- reset_lv2();
-
- lv2_InputPort = lilv_new_uri(world, LV2_CORE__InputPort);
- lv2_OutputPort = lilv_new_uri(world, LV2_CORE__OutputPort);
- lv2_AudioPort = lilv_new_uri(world, LV2_CORE__AudioPort);
- lv2_ControlPort = lilv_new_uri(world, LV2_CORE__ControlPort);
- lv2_CVPort = lilv_new_uri(world, LV2_CORE__CVPort);
- lv2_Optional = lilv_new_uri(world, LV2_CORE__connectionOptional);
- atom_AtomPort = lilv_new_uri(world, LV2_ATOM__AtomPort);
- atom_Sequence = lilv_new_uri(world, LV2_ATOM__Sequence);
- urid_map = lilv_new_uri(world, LV2_URID__map);
- powerOf2BlockLength = lilv_new_uri(world, LV2_BUF_SIZE__powerOf2BlockLength);
- fixedBlockLength = lilv_new_uri(world, LV2_BUF_SIZE__fixedBlockLength);
- boundedBlockLength = lilv_new_uri(world, LV2_BUF_SIZE__boundedBlockLength);
- seq_out = (LV2_Atom_Sequence *) new char[sizeof(LV2_Atom_Sequence) + LV2_SEQ_SIZE];
-
- config.init_lv2(lilv);
- nb_inputs = nb_outputs = 0;
-
- for( int i=0; i<config.nb_ports; ++i ) {
- const LilvPort *lp = lilv_plugin_get_port_by_index(lilv, i);
- int is_input = lilv_port_is_a(lilv, lp, lv2_InputPort);
- if( !is_input && !lilv_port_is_a(lilv, lp, lv2_OutputPort) &&
- !lilv_port_has_property(lilv, lp, lv2_Optional) ) {
- printf("lv2: not input, not output, and not optional: %s\n", config.names[i]);
- continue;
- }
- if( is_input && lilv_port_is_a(lilv, lp, lv2_ControlPort) ) {
- const char *sym = lilv_node_as_string(lilv_port_get_symbol(lilv, lp));
- config.append(new PluginLV2Client_Opt(&config, sym, i));
- continue;
- }
- if( lilv_port_is_a(lilv, lp, lv2_AudioPort) ||
- lilv_port_is_a(lilv, lp, lv2_CVPort ) ) {
- if( is_input ) ++nb_inputs; else ++nb_outputs;
- continue;
- }
- }
-
- map.handle = (void*)&uri_table;
- map.map = uri_table_map;
- map_feature.URI = LV2_URID_MAP_URI;
- map_feature.data = ↦
- unmap.handle = (void*)&uri_table;
- unmap.unmap = uri_table_unmap;
- unmap_feature.URI = LV2_URID_UNMAP_URI;
- unmap_feature.data = &unmap;
- features[0] = &map_feature;
- features[1] = &unmap_feature;
- static const LV2_Feature buf_size_features[3] = {
- { LV2_BUF_SIZE__powerOf2BlockLength, NULL },
- { LV2_BUF_SIZE__fixedBlockLength, NULL },
- { LV2_BUF_SIZE__boundedBlockLength, NULL },
- };
- features[2] = &buf_size_features[0];
- features[3] = &buf_size_features[1];
- features[4] = &buf_size_features[2];
- features[5] = 0;
-
- instance = lilv_plugin_instantiate(lilv, sample_rate, features);
- if( !instance ) {
- printf("lv2: lilv_plugin_instantiate failed: %s\n", server->title);
- return 1;
- }
- lilv_instance_activate(instance);
-// not sure what to do with these
- max_bufsz = nb_inputs &&
- (lilv_plugin_has_feature(lilv, powerOf2BlockLength) ||
- lilv_plugin_has_feature(lilv, fixedBlockLength) ||
- lilv_plugin_has_feature(lilv, boundedBlockLength)) ? 4096 : 0;
- return 0;
-}
-
-LV2_URID PluginLV2Client::uri_table_map(LV2_URID_Map_Handle handle, const char *uri)
-{
- return ((PluginLV2UriTable *)handle)->map(uri);