Mercurial > hg > svcore
comparison transform/TransformFactory.cpp @ 63:ba405e5e69d3
* Add auto-normalize option to waveform layer
* Various fixes to display of dB/metered levels in waveform layer. Still need
to fix to ensure they don't waste half the display
* Add mix channels option to waveform layer
* Use multiple transforms menus, one per transform type -- not sure about this
* Give centroid plugin two outputs, for log and linear frequency weightings
* Show scale units from plugin in time-value display
author | Chris Cannam |
---|---|
date | Wed, 29 Mar 2006 12:35:17 +0000 |
parents | 3086ff194ea0 |
children | 4d59dc469b0f |
comparison
equal
deleted
inserted
replaced
62:33285f426852 | 63:ba405e5e69d3 |
---|---|
22 #include "plugin/RealTimePluginFactory.h" | 22 #include "plugin/RealTimePluginFactory.h" |
23 | 23 |
24 #include "widgets/PluginParameterDialog.h" | 24 #include "widgets/PluginParameterDialog.h" |
25 | 25 |
26 #include <iostream> | 26 #include <iostream> |
27 #include <set> | |
28 | |
29 #include <QRegExp> | |
27 | 30 |
28 TransformFactory * | 31 TransformFactory * |
29 TransformFactory::m_instance = new TransformFactory; | 32 TransformFactory::m_instance = new TransformFactory; |
30 | 33 |
31 TransformFactory * | 34 TransformFactory * |
48 i != m_transforms.end(); ++i) { | 51 i != m_transforms.end(); ++i) { |
49 list.push_back(i->second); | 52 list.push_back(i->second); |
50 } | 53 } |
51 | 54 |
52 return list; | 55 return list; |
56 } | |
57 | |
58 std::vector<QString> | |
59 TransformFactory::getAllTransformTypes() | |
60 { | |
61 if (m_transforms.empty()) populateTransforms(); | |
62 | |
63 std::set<QString> types; | |
64 for (TransformDescriptionMap::const_iterator i = m_transforms.begin(); | |
65 i != m_transforms.end(); ++i) { | |
66 types.insert(i->second.type); | |
67 } | |
68 | |
69 std::vector<QString> rv; | |
70 for (std::set<QString>::iterator i = types.begin(); i != types.end(); ++i) { | |
71 rv.push_back(*i); | |
72 } | |
73 | |
74 return rv; | |
53 } | 75 } |
54 | 76 |
55 void | 77 void |
56 TransformFactory::populateTransforms() | 78 TransformFactory::populateTransforms() |
57 { | 79 { |
132 QString transformName = QString("%1:%2") | 154 QString transformName = QString("%1:%2") |
133 .arg(pluginId).arg(outputs[j].name.c_str()); | 155 .arg(pluginId).arg(outputs[j].name.c_str()); |
134 | 156 |
135 QString userDescription; | 157 QString userDescription; |
136 QString friendlyName; | 158 QString friendlyName; |
159 QString units = outputs[j].unit.c_str(); | |
137 | 160 |
138 if (outputs.size() == 1) { | 161 if (outputs.size() == 1) { |
139 userDescription = pluginDescription; | 162 userDescription = pluginDescription; |
140 friendlyName = pluginDescription; | 163 friendlyName = pluginDescription; |
141 } else { | 164 } else { |
147 | 170 |
148 bool configurable = (!plugin->getPrograms().empty() || | 171 bool configurable = (!plugin->getPrograms().empty() || |
149 !plugin->getParameterDescriptors().empty()); | 172 !plugin->getParameterDescriptors().empty()); |
150 | 173 |
151 transforms[transformName] = | 174 transforms[transformName] = |
152 TransformDesc(transformName, | 175 TransformDesc(tr("Analysis Plugin"), |
176 transformName, | |
153 userDescription, | 177 userDescription, |
154 friendlyName, | 178 friendlyName, |
155 plugin->getMaker().c_str(), | 179 plugin->getMaker().c_str(), |
180 units, | |
156 configurable); | 181 configurable); |
157 } | 182 } |
158 } | 183 } |
159 } | 184 } |
160 | 185 |
161 void | 186 void |
162 TransformFactory::populateRealTimePlugins(TransformDescriptionMap &transforms) | 187 TransformFactory::populateRealTimePlugins(TransformDescriptionMap &transforms) |
163 { | 188 { |
164 std::vector<QString> plugs = | 189 std::vector<QString> plugs = |
165 RealTimePluginFactory::getAllPluginIdentifiers(); | 190 RealTimePluginFactory::getAllPluginIdentifiers(); |
191 | |
192 QRegExp unitRE("[\\[\\(]([A-Za-z0-9/]+)[\\)\\]]$"); | |
166 | 193 |
167 for (size_t i = 0; i < plugs.size(); ++i) { | 194 for (size_t i = 0; i < plugs.size(); ++i) { |
168 | 195 |
169 QString pluginId = plugs[i]; | 196 QString pluginId = plugs[i]; |
170 | 197 |
193 | 220 |
194 for (size_t j = 0; j < descriptor->controlOutputPortCount; ++j) { | 221 for (size_t j = 0; j < descriptor->controlOutputPortCount; ++j) { |
195 | 222 |
196 QString transformName = QString("%1:%2").arg(pluginId).arg(j); | 223 QString transformName = QString("%1:%2").arg(pluginId).arg(j); |
197 QString userDescription; | 224 QString userDescription; |
225 QString units; | |
198 | 226 |
199 if (j < descriptor->controlOutputPortNames.size() && | 227 if (j < descriptor->controlOutputPortNames.size() && |
200 descriptor->controlOutputPortNames[j] != "") { | 228 descriptor->controlOutputPortNames[j] != "") { |
229 | |
230 QString portName = descriptor->controlOutputPortNames[j].c_str(); | |
231 | |
201 userDescription = tr("%1: %2") | 232 userDescription = tr("%1: %2") |
202 .arg(pluginDescription) | 233 .arg(pluginDescription) |
203 .arg(descriptor->controlOutputPortNames[j].c_str()); | 234 .arg(portName); |
235 | |
236 if (unitRE.indexIn(portName) >= 0) { | |
237 units = unitRE.cap(1); | |
238 } | |
239 | |
204 } else if (descriptor->controlOutputPortCount > 1) { | 240 } else if (descriptor->controlOutputPortCount > 1) { |
241 | |
205 userDescription = tr("%1: Output %2") | 242 userDescription = tr("%1: Output %2") |
206 .arg(pluginDescription) | 243 .arg(pluginDescription) |
207 .arg(j + 1); | 244 .arg(j + 1); |
245 | |
208 } else { | 246 } else { |
247 | |
209 userDescription = pluginDescription; | 248 userDescription = pluginDescription; |
210 } | 249 } |
211 | 250 |
251 | |
212 bool configurable = (descriptor->parameterCount > 0); | 252 bool configurable = (descriptor->parameterCount > 0); |
213 | 253 |
214 transforms[transformName] = | 254 transforms[transformName] = |
215 TransformDesc(transformName, | 255 TransformDesc(tr("Real-Time Plugin"), |
256 transformName, | |
216 userDescription, | 257 userDescription, |
217 userDescription, | 258 userDescription, |
218 descriptor->maker.c_str(), | 259 descriptor->maker.c_str(), |
260 units, | |
219 configurable); | 261 configurable); |
220 } | 262 } |
221 } | 263 } |
222 } | 264 } |
223 | 265 |
232 QString | 274 QString |
233 TransformFactory::getTransformFriendlyName(TransformName name) | 275 TransformFactory::getTransformFriendlyName(TransformName name) |
234 { | 276 { |
235 if (m_transforms.find(name) != m_transforms.end()) { | 277 if (m_transforms.find(name) != m_transforms.end()) { |
236 return m_transforms[name].friendlyName; | 278 return m_transforms[name].friendlyName; |
279 } else return ""; | |
280 } | |
281 | |
282 QString | |
283 TransformFactory::getTransformUnits(TransformName name) | |
284 { | |
285 if (m_transforms.find(name) != m_transforms.end()) { | |
286 return m_transforms[name].units; | |
237 } else return ""; | 287 } else return ""; |
238 } | 288 } |
239 | 289 |
240 bool | 290 bool |
241 TransformFactory::isTransformConfigurable(TransformName name) | 291 TransformFactory::isTransformConfigurable(TransformName name) |
305 output); | 355 output); |
306 } else if (RealTimePluginFactory::instanceFor(id)) { | 356 } else if (RealTimePluginFactory::instanceFor(id)) { |
307 transform = new RealTimePluginTransform(inputModel, | 357 transform = new RealTimePluginTransform(inputModel, |
308 id, | 358 id, |
309 configurationXml, | 359 configurationXml, |
360 getTransformUnits(name), | |
310 output.toInt()); | 361 output.toInt()); |
311 } else { | 362 } else { |
312 std::cerr << "TransformFactory::createTransform: Unknown transform " | 363 std::cerr << "TransformFactory::createTransform: Unknown transform " |
313 << name.toStdString() << std::endl; | 364 << name.toStdString() << std::endl; |
314 } | 365 } |