Esempio n. 1
0
int
main(int argc, char** argv)
{
	if (argc != 2) {
		fprintf(stderr, "USAGE: %s BUNDLE\n", argv[0]);
		return 1;
	}

	const char* bundle_path = argv[1];
	LilvWorld*  world       = lilv_world_new();

	// Load test plugin bundle
	uint8_t*  abs_bundle = (uint8_t*)lilv_path_absolute(bundle_path);
	SerdNode  bundle     = serd_node_new_file_uri(abs_bundle, 0, 0, true);
	LilvNode* bundle_uri = lilv_new_uri(world, (const char*)bundle.buf);
	lilv_world_load_bundle(world, bundle_uri);
	free(abs_bundle);
	serd_node_free(&bundle);

	LilvNode*          plugin_uri = lilv_new_uri(world, PLUGIN_URI);
	const LilvPlugins* plugins    = lilv_world_get_all_plugins(world);
	const LilvPlugin*  plugin     = lilv_plugins_get_by_uri(plugins, plugin_uri);
	TEST_ASSERT(plugin);

	LilvInstance* instance = lilv_plugin_instantiate(plugin, 48000.0, NULL);
	TEST_ASSERT(instance);

	lilv_world_free(world);

	return 0;
}
Esempio n. 2
0
bool LV2EffectsModule::IsPluginValid(const wxString & path)
{
   LilvNode *uri = lilv_new_uri(gWorld, path.ToUTF8());
   const LilvPlugin *plugin = lilv_plugins_get_by_uri(lilv_world_get_all_plugins(gWorld), uri);
   lilv_node_free(uri);

   return plugin != NULL;
}
Esempio n. 3
0
const LilvPlugin *LV2EffectsModule::GetPlugin(const wxString & path)
{
   LilvNode *uri = lilv_new_uri(gWorld, path.ToUTF8());
   if (!uri)
   {
      return NULL;
   }

   const LilvPlugin *plug = lilv_plugins_get_by_uri(lilv_world_get_all_plugins(gWorld), uri);

   lilv_node_free(uri);

   return plug;
}
Esempio n. 4
0
bool LV2EffectsModule::AutoRegisterPlugins(PluginManagerInterface & pm)
{
   EffectManager& em = EffectManager::Get();

#ifdef EFFECT_CATEGORIES

   // Add all LV2 categories and their relationships
   LilvPluginClasses classes = Lilv_world_get_plugin_classes(gWorld);
   for (unsigned index = 0; index < Lilv_plugin_classes_size(classes);++index){
      LilvPluginClass c = Lilv_plugin_classes_get_at(classes, index);
      em.AddCategory(wxString::FromUTF8(lilv_node_as_uri(Lilv_plugin_class_get_uri(c))),
                     wxString::FromUTF8(lilv_node_as_string(Lilv_plugin_class_get_label(c))));
   }
   for (unsigned index = 0; index < Lilv_plugin_classes_size(classes);++index){
      LilvPluginClass c = Lilv_plugin_classes_get_at(classes, index);
      LilvPluginClasses ch = Lilv_plugin_class_get_children(c);
      EffectCategory* pCat = em.LookupCategory(wxString::FromUTF8(lilv_node_as_uri(Lilv_plugin_class_get_uri(c))));
      for (unsigned j = 0; j < Lilv_plugin_classes_size(ch); ++j) {
         EffectCategory* chCat = em.LookupCategory(wxString::FromUTF8(lilv_node_as_uri(Lilv_plugin_class_get_uri(Lilv_plugin_classes_get_at(ch, j)))));
         if (chCat && pCat) {
            em.AddCategoryParent(chCat, pCat);
         }
      }
   }

#endif

   // Retrieve data about all plugins
   const LilvPlugins *plugs = lilv_world_get_all_plugins(gWorld);

   // Iterate over all plugins and register them with the EffectManager
   LILV_FOREACH(plugins, i, plugs)
   {
      const LilvPlugin *plug = lilv_plugins_get(plugs, i);
      std::set<wxString> cats;
      cats.insert(wxString::FromUTF8(lilv_node_as_uri(lilv_plugin_class_get_uri(lilv_plugin_get_class(plug)))));
      LV2Effect *effect = new LV2Effect(plug, cats);
      if (effect->IsValid())
      {
         em.RegisterEffect(this, effect);
      }
      else
      {
         delete effect;
      }
   }

   return true;
}
Esempio n. 5
0
int
main(int argc, char** argv)
{
	uint32_t block_size   = 512;
	uint32_t sample_count = (1 << 19);

	for (int i = 1; i < argc; ++i) {
		if (!strcmp(argv[i], "--version")) {
			print_version();
			return 0;
		} else if (!strcmp(argv[i], "--help")) {
			print_usage();
			return 0;
		} else if (!strcmp(argv[i], "-f")) {
			full_output = true;
		} else if (!strcmp(argv[i], "-n") && (i + 1 < argc)) {
			sample_count = atoi(argv[++i]);
		} else if (!strcmp(argv[i], "-b") && (i + 1 < argc)) {
			block_size = atoi(argv[++i]);
		} else {
			print_usage();
			return 1;
		}
	}

	LilvWorld* world = lilv_world_new();
	lilv_world_load_all(world);

	atom_AtomPort   = lilv_new_uri(world, LV2_ATOM__AtomPort);
	atom_Sequence   = lilv_new_uri(world, LV2_ATOM__Sequence);
	lv2_AudioPort   = lilv_new_uri(world, LV2_CORE__AudioPort);
	lv2_CVPort      = lilv_new_uri(world, LV2_CORE__CVPort);
	lv2_ControlPort = lilv_new_uri(world, LV2_CORE__ControlPort);
	lv2_InputPort   = lilv_new_uri(world, LV2_CORE__InputPort);
	lv2_OutputPort  = lilv_new_uri(world, LV2_CORE__OutputPort);
	urid_map        = lilv_new_uri(world, LV2_URID__map);

	if (full_output) {
		printf("# Block Samples Time Plugin\n");
	}

	const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
	LILV_FOREACH(plugins, i, plugins) {
		bench(lilv_plugins_get(plugins, i), sample_count, block_size);
	}
Esempio n. 6
0
wxArrayString LV2EffectsModule::FindPlugins(PluginManagerInterface & WXUNUSED(pm))
{
   // Retrieve data about all LV2 plugins
   const LilvPlugins *plugs = lilv_world_get_all_plugins(gWorld);

   // Iterate over all plugins retrieve their URI
   wxArrayString plugins;
   LILV_FOREACH(plugins, i, plugs)
   {
      const LilvPlugin *plug = lilv_plugins_get(plugs, i);

      // Bypass Instrument (MIDI) plugins for now
      const LilvPluginClass *cls = lilv_plugin_get_class(plug);
      if (lilv_node_equals(lilv_plugin_class_get_uri(cls), LV2Effect::gInstrument))
      {
         continue;
      }

      plugins.Add(LilvString(lilv_plugin_get_uri(plug)));
   }

   return plugins;
}
Esempio n. 7
0
/**
 * Initialize the Lv2Liv
 */
void Lv2Lib_constructor(Lv2Lib * lv2Liv) {
    lv2Liv->world = lilv_world_new();
    lilv_world_load_all(lv2Liv->world);

    lv2Liv->plugins = lilv_world_get_all_plugins(lv2Liv->world);
}
Esempio n. 8
0
const LilvPlugins*
LV2World::getAllPlugins() const
{
    return lilv_world_get_all_plugins (world);
}
Esempio n. 9
0
Lv2PluginCache::Lv2PluginCache() : world(lilv_world_new()), lv2Constants(world) {

    // plugins
    lilv_world_load_all(world);
    plugins = lilv_world_get_all_plugins(world);

    // supported features
    supported[LV2_URID__map] = true;
    supported[LV2_URID__unmap] = true;
    supported[LV2_OPTIONS__options] = true;
    supported[LV2_BUF_SIZE__boundedBlockLength] = true;
    supported[LV2_STATE__mapPath] = true;
    supported[LV2_WORKER__schedule] = true;

    // URID feature (map/unmap)
    map.map = &uridMap;
    map.handle = &uridMapper;
    static LV2_Feature uridMapFeature  = { LV2_URID__map, &map };
    lv2Features[0] = &uridMapFeature;

    unmap.unmap = &uridUnmap;
    unmap.handle = &uridMapper;
    static LV2_Feature uridUnmapFeature  = { LV2_URID__unmap, &unmap };
    lv2Features[1] = &uridUnmapFeature;

    // Options feature
    options[0] = { LV2_OPTIONS_INSTANCE, 0, uridMapper.uriToId(LV2_BUF_SIZE__minBlockLength),
            sizeof(float), uridMapper.uriToId(LV2_ATOM__Int), &blockLength };
    options[1] = { LV2_OPTIONS_INSTANCE, 0, uridMapper.uriToId(LV2_BUF_SIZE__maxBlockLength),
            sizeof(float), uridMapper.uriToId(LV2_ATOM__Int), &blockLength };
    options[2] = { LV2_OPTIONS_INSTANCE, 0, 0, 0, 0, NULL };

    static LV2_Feature optionsFeature = { LV2_OPTIONS__options, &options };
    lv2Features[2] = &optionsFeature;

    static LV2_Feature boundedBlockFeature = { LV2_BUF_SIZE__boundedBlockLength, NULL };
    lv2Features[3] = &boundedBlockFeature;

    // state map path feature
    mapPath.handle = &pathMapper;
    mapPath.absolute_path = &mapAbsolutePath;
    mapPath.abstract_path = &mapAbstractPath;
    static LV2_Feature stateMapPathFeature = { LV2_STATE__mapPath, &mapPath };
    lv2Features[4] = &stateMapPathFeature;

    // worker schedule feature
    schedule.handle = 0; // assigned in factory method
    schedule.schedule_work = &scheduleWork;
    static LV2_Feature workerFeature = { LV2_WORKER__schedule, &schedule };
    lv2Features[5] = &workerFeature;

    // end of features
    lv2Features[6] = 0;

    // URIDs
    Lv2Plugin::atomTypes.intType = uridMapper.uriToId(LV2_ATOM__Int);
    Lv2Plugin::atomTypes.longType = uridMapper.uriToId(LV2_ATOM__Long);
    Lv2Plugin::atomTypes.floatType = uridMapper.uriToId(LV2_ATOM__Float);
    Lv2Plugin::atomTypes.doubleType = uridMapper.uriToId(LV2_ATOM__Double);
    Lv2Plugin::atomTypes.stringType = uridMapper.uriToId(LV2_ATOM__String);
    Lv2MidiEvent::midiEventTypeId = uridMapper.uriToId(LILV_URI_MIDI_EVENT);
}