Mercurial > hg > easaier-soundaccess
comparison plugin/RealTimePluginFactory.cpp @ 0:fc9323a41f5a
start base : Sonic Visualiser sv1-1.0rc1
author | lbajardsilogic |
---|---|
date | Fri, 11 May 2007 09:08:14 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:fc9323a41f5a |
---|---|
1 // -*- c-basic-offset: 4 indent-tabs-mode: nil -*- | |
2 | |
3 /* | |
4 Rosegarden-4 | |
5 A sequencer and musical notation editor. | |
6 | |
7 This program is Copyright 2000-2006 | |
8 Guillaume Laurent <glaurent@telegraph-road.org>, | |
9 Chris Cannam <cannam@all-day-breakfast.com>, | |
10 Richard Bown <bownie@bownie.com> | |
11 | |
12 The moral right of the authors to claim authorship of this work | |
13 has been asserted. | |
14 | |
15 This program is free software; you can redistribute it and/or | |
16 modify it under the terms of the GNU General Public License as | |
17 published by the Free Software Foundation; either version 2 of the | |
18 License, or (at your option) any later version. See the file | |
19 COPYING included with this distribution for more information. | |
20 */ | |
21 | |
22 #include "RealTimePluginFactory.h" | |
23 #include "PluginIdentifier.h" | |
24 | |
25 #include "LADSPAPluginFactory.h" | |
26 #include "DSSIPluginFactory.h" | |
27 | |
28 #include <iostream> | |
29 | |
30 int RealTimePluginFactory::m_sampleRate = 48000; | |
31 | |
32 static LADSPAPluginFactory *_ladspaInstance = 0; | |
33 static LADSPAPluginFactory *_dssiInstance = 0; | |
34 | |
35 RealTimePluginFactory::~RealTimePluginFactory() | |
36 { | |
37 } | |
38 | |
39 RealTimePluginFactory * | |
40 RealTimePluginFactory::instance(QString pluginType) | |
41 { | |
42 if (pluginType == "ladspa") { | |
43 if (!_ladspaInstance) { | |
44 // std::cerr << "RealTimePluginFactory::instance(" << pluginType.toStdString() | |
45 // << "): creating new LADSPAPluginFactory" << std::endl; | |
46 _ladspaInstance = new LADSPAPluginFactory(); | |
47 _ladspaInstance->discoverPlugins(); | |
48 } | |
49 return _ladspaInstance; | |
50 } else if (pluginType == "dssi") { | |
51 if (!_dssiInstance) { | |
52 // std::cerr << "RealTimePluginFactory::instance(" << pluginType.toStdString() | |
53 // << "): creating new DSSIPluginFactory" << std::endl; | |
54 _dssiInstance = new DSSIPluginFactory(); | |
55 _dssiInstance->discoverPlugins(); | |
56 } | |
57 return _dssiInstance; | |
58 } | |
59 | |
60 else return 0; | |
61 } | |
62 | |
63 RealTimePluginFactory * | |
64 RealTimePluginFactory::instanceFor(QString identifier) | |
65 { | |
66 QString type, soName, label; | |
67 PluginIdentifier::parseIdentifier(identifier, type, soName, label); | |
68 return instance(type); | |
69 } | |
70 | |
71 std::vector<QString> | |
72 RealTimePluginFactory::getAllPluginIdentifiers() | |
73 { | |
74 RealTimePluginFactory *factory; | |
75 std::vector<QString> rv; | |
76 | |
77 // Query DSSI plugins before LADSPA ones. | |
78 // This is to provide for the interesting possibility of plugins | |
79 // providing either DSSI or LADSPA versions of themselves, | |
80 // returning both versions if the LADSPA identifiers are queried | |
81 // first but only the DSSI version if the DSSI identifiers are | |
82 // queried first. | |
83 | |
84 factory = instance("dssi"); | |
85 if (factory) { | |
86 const std::vector<QString> &tmp = factory->getPluginIdentifiers(); | |
87 for (size_t i = 0; i < tmp.size(); ++i) { | |
88 rv.push_back(tmp[i]); | |
89 } | |
90 } | |
91 | |
92 factory = instance("ladspa"); | |
93 if (factory) { | |
94 const std::vector<QString> &tmp = factory->getPluginIdentifiers(); | |
95 for (size_t i = 0; i < tmp.size(); ++i) { | |
96 rv.push_back(tmp[i]); | |
97 } | |
98 } | |
99 | |
100 // Plugins can change the locale, revert it to default. | |
101 setlocale(LC_ALL, "C"); | |
102 return rv; | |
103 } | |
104 | |
105 void | |
106 RealTimePluginFactory::enumerateAllPlugins(std::vector<QString> &list) | |
107 { | |
108 RealTimePluginFactory *factory; | |
109 | |
110 // Query DSSI plugins before LADSPA ones. | |
111 // This is to provide for the interesting possibility of plugins | |
112 // providing either DSSI or LADSPA versions of themselves, | |
113 // returning both versions if the LADSPA identifiers are queried | |
114 // first but only the DSSI version if the DSSI identifiers are | |
115 // queried first. | |
116 | |
117 factory = instance("dssi"); | |
118 if (factory) factory->enumeratePlugins(list); | |
119 | |
120 factory = instance("ladspa"); | |
121 if (factory) factory->enumeratePlugins(list); | |
122 | |
123 // Plugins can change the locale, revert it to default. | |
124 setlocale(LC_ALL, "C"); | |
125 } | |
126 |