61 Profiler profiler(
"DSSIPluginFactory::enumeratePlugins");
63 for (std::vector<QString>::iterator i =
m_identifiers.begin();
69 const LADSPA_Descriptor *descriptor = ddesc->LADSPA_Plugin;
70 if (!descriptor)
continue;
75 list.push_back(descriptor->Name);
76 list.push_back(QString(
"%1").arg(descriptor->UniqueID));
77 list.push_back(descriptor->Label);
78 list.push_back(descriptor->Maker);
79 list.push_back(descriptor->Copyright);
80 list.push_back((ddesc->run_synth || ddesc->run_multiple_synths) ?
"true" :
"false");
81 list.push_back(ddesc->run_multiple_synths ?
"true" :
"false");
83 list.push_back(QString(
"%1").arg(descriptor->PortCount));
85 for (
unsigned long p = 0; p < descriptor->PortCount; ++p) {
88 if (LADSPA_IS_PORT_CONTROL(descriptor->PortDescriptors[p])) {
93 if (LADSPA_IS_PORT_INPUT(descriptor->PortDescriptors[p])) {
99 list.push_back(QString(
"%1").arg(p));
100 list.push_back(descriptor->PortNames[p]);
101 list.push_back(QString(
"%1").arg(type));
116 unsigned int sampleRate,
117 unsigned int blockSize,
118 unsigned int channels)
120 Profiler profiler(
"DSSIPluginFactory::instantiatePlugin");
128 (
this, instrument, identifier, position, sampleRate, blockSize, channels,
139 const DSSI_Descriptor *
142 QString type, soname, label;
146 if (label ==
"sample_player") {
157 bool firstInLibrary =
false;
162 cerr <<
"WARNING: DSSIPluginFactory::getDSSIDescriptor: loadLibrary failed for " << soname << endl;
165 firstInLibrary =
true;
170 DSSI_Descriptor_Function fn = (DSSI_Descriptor_Function)
171 DLSYM(libraryHandle,
"dssi_descriptor");
174 cerr <<
"WARNING: DSSIPluginFactory::getDSSIDescriptor: No descriptor function in library " << soname << endl;
178 const DSSI_Descriptor *descriptor = 0;
181 while ((descriptor = fn(index))) {
182 if (descriptor->LADSPA_Plugin->Label == label) {
183 if (firstInLibrary && (descriptor->DSSI_API_Version >= 2)) {
191 cerr <<
"WARNING: DSSIPluginFactory::getDSSIDescriptor: No such plugin as " << label <<
" in library " << soname << endl;
196 const LADSPA_Descriptor *
200 if (dssiDescriptor)
return dssiDescriptor->LADSPA_Plugin;
208 std::vector<QString> pathList;
211 char *cpath = getenv(
"DSSI_PATH");
212 if (cpath) path = cpath;
218 char *home = getenv(
"HOME");
220 std::string::size_type f;
221 while ((f = path.find(
"$HOME")) != std::string::npos &&
223 path.replace(f, 5, home);
228 char *pfiles = getenv(
"ProgramFiles");
229 if (!pfiles) pfiles =
"C:\\Program Files";
231 std::string::size_type f;
232 while ((f = path.find(
"%ProgramFiles%")) != std::string::npos &&
234 path.replace(f, 14, pfiles);
240 std::string::size_type index = 0, newindex = 0;
242 while ((newindex = path.find(
PATH_SEPARATOR, index)) < path.size()) {
243 pathList.push_back(path.substr(index, newindex - index).c_str());
244 index = newindex + 1;
247 pathList.push_back(path.substr(index).c_str());
256 std::vector<QString> lrdfPaths;
261 lrdfPaths.push_back(
"/usr/local/share/dssi/rdf");
262 lrdfPaths.push_back(
"/usr/share/dssi/rdf");
264 lrdfPaths.push_back(
"/usr/local/share/ladspa/rdf");
265 lrdfPaths.push_back(
"/usr/share/ladspa/rdf");
267 for (std::vector<QString>::iterator i = pathList.begin();
268 i != pathList.end(); ++i) {
269 lrdfPaths.push_back(*i +
"/rdf");
275 baseUri =
"http://dssi.sourceforge.net/ontology#";
289 Profiler profiler(
"DSSIPluginFactory::discoverPlugins");
294 void *libraryHandle =
DLOPEN(soname, RTLD_LAZY);
296 if (!libraryHandle) {
297 cerr <<
"WARNING: DSSIPluginFactory::discoverPlugins: couldn't load plugin library " 298 << soname <<
" - " <<
DLERROR() << endl;
302 DSSI_Descriptor_Function fn = (DSSI_Descriptor_Function)
303 DLSYM(libraryHandle,
"dssi_descriptor");
306 cerr <<
"WARNING: DSSIPluginFactory::discoverPlugins: No descriptor function in " << soname << endl;
310 const DSSI_Descriptor *descriptor = 0;
313 while ((descriptor = fn(index))) {
315 const LADSPA_Descriptor *ladspaDescriptor = descriptor->LADSPA_Plugin;
316 if (!ladspaDescriptor) {
317 cerr <<
"WARNING: DSSIPluginFactory::discoverPlugins: No LADSPA descriptor for plugin " << index <<
" in " << soname << endl;
323 rtd->
name = ladspaDescriptor->Name;
324 rtd->
label = ladspaDescriptor->Label;
325 rtd->
maker = ladspaDescriptor->Maker;
326 rtd->
copyright = ladspaDescriptor->Copyright;
328 rtd->
isSynth = (descriptor->run_synth ||
329 descriptor->run_multiple_synths);
336 (
"dssi", soname, ladspaDescriptor->Label);
340 lrdf_defaults *defs = 0;
344 if (category ==
"" &&
m_lrdfTaxonomy[ladspaDescriptor->UniqueID] !=
"") {
349 if (category ==
"") {
350 std::string name = rtd->
name;
351 if (name.length() > 4 &&
352 name.substr(name.length() - 4) ==
" VST") {
353 if (descriptor->run_synth || descriptor->run_multiple_synths) {
354 category =
"VST instruments";
356 category =
"VST effects";
362 rtd->
category = category.toStdString();
371 def_uri = lrdf_get_default_uri(ladspaDescriptor->UniqueID);
373 defs = lrdf_get_setting_values(def_uri);
376 unsigned int controlPortNumber = 1;
378 for (
unsigned long i = 0; i < ladspaDescriptor->PortCount; i++) {
380 if (LADSPA_IS_PORT_CONTROL(ladspaDescriptor->PortDescriptors[i])) {
382 if (def_uri && defs) {
384 for (
unsigned int j = 0; j < defs->count; j++) {
385 if (defs->items[j].pid == controlPortNumber) {
388 defs->items[j].value;
398 for (
unsigned long i = 0; i < ladspaDescriptor->PortCount; i++) {
399 if (LADSPA_IS_PORT_CONTROL(ladspaDescriptor->PortDescriptors[i])) {
400 if (LADSPA_IS_PORT_INPUT(ladspaDescriptor->PortDescriptors[i])) {
403 if (strcmp(ladspaDescriptor->PortNames[i],
"latency") &&
404 strcmp(ladspaDescriptor->PortNames[i],
"_latency")) {
407 (ladspaDescriptor->PortNames[i]);
411 if (LADSPA_IS_PORT_INPUT(ladspaDescriptor->PortDescriptors[i])) {
413 }
else if (LADSPA_IS_PORT_OUTPUT(ladspaDescriptor->PortDescriptors[i])) {
426 if (
DLCLOSE(libraryHandle) != 0) {
427 cerr <<
"WARNING: DSSIPluginFactory::discoverPlugins - can't unload " << libraryHandle << endl;
virtual ~DSSIPluginFactory()
std::vector< std::string > controlOutputPortNames
static int requestMidiSend(LADSPA_Handle instance, unsigned char ports, unsigned char channels)
int getPortDisplayHint(const LADSPA_Descriptor *, int port)
static void midiSend(LADSPA_Handle instance, snd_seq_event_t *events, unsigned long eventCount)
LibraryHandleMap m_libraryHandles
virtual const LADSPA_Descriptor * getLADSPADescriptor(QString identifier)
virtual void enumeratePlugins(std::vector< QString > &list)
Append to the given list descriptions of all the available plugins and their ports.
static void parseIdentifier(QString identifier, QString &type, QString &soName, QString &label)
static QString createIdentifier(QString type, QString soName, QString label)
virtual std::vector< QString > getPluginPath()
float getPortDefault(const LADSPA_Descriptor *, int port)
unsigned int audioInputPortCount
unsigned int parameterCount
virtual RealTimePluginInstance * instantiatePlugin(QString identifier, int clientId, int position, unsigned int sampleRate, unsigned int blockSize, unsigned int channels)
Instantiate a plugin.
unsigned int controlOutputPortCount
static const DSSI_Descriptor * getDescriptor(unsigned long index)
float getPortMaximum(const LADSPA_Descriptor *, int port)
static QString BUILTIN_PLUGIN_SONAME
void unloadUnusedLibraries()
virtual const DSSI_Descriptor * getDSSIDescriptor(QString identifier)
DSSI_Host_Descriptor m_hostDescriptor
std::map< unsigned long, std::map< int, float > > m_portDefaults
std::set< RealTimePluginInstance * > m_instances
std::map< QString, QString > m_taxonomy
std::map< QString, RealTimePluginDescriptor * > m_rtDescriptors
static int requestNonRTThread(LADSPA_Handle instance, void(*runFunction)(LADSPA_Handle))
std::vector< QString > m_identifiers
virtual std::vector< QString > getLRDFPath(QString &baseUri)
std::map< unsigned long, QString > m_lrdfTaxonomy
static RealTimePluginFactory * instance(QString pluginType)
#define DEFAULT_DSSI_PATH
void loadLibrary(QString soName)
virtual void discoverPluginsFrom(QString soName)
float getPortMinimum(const LADSPA_Descriptor *, int port)
unsigned int audioOutputPortCount
Profile point instance class.