comparison framework/SVFileReader.cpp @ 308:289d65722123 tonioni

More work on mixing and file i/o for sample stuff
author Chris Cannam
date Tue, 07 Jan 2014 15:50:04 +0000
parents 933b5aed341a
children 71050ffd0141
comparison
equal deleted inserted replaced
307:6eb15c3aee0a 308:289d65722123
1269 if (ok) parameters->setPlayPan(pan); 1269 if (ok) parameters->setPlayPan(pan);
1270 1270
1271 float gain = attributes.value("gain").toFloat(&ok); 1271 float gain = attributes.value("gain").toFloat(&ok);
1272 if (ok) parameters->setPlayGain(gain); 1272 if (ok) parameters->setPlayGain(gain);
1273 1273
1274 QString pluginId = attributes.value("pluginId"); 1274 QString sampleId = attributes.value("sampleId");
1275 if (pluginId != "") parameters->setPlayPluginId(pluginId); 1275 if (sampleId != "") parameters->setPlaySampleId(sampleId);
1276 1276
1277 m_currentPlayParameters = parameters; 1277 m_currentPlayParameters = parameters;
1278 1278
1279 // cerr << "Current play parameters for model: " << m_models[modelId] << ": " << m_currentPlayParameters << endl; 1279 // cerr << "Current play parameters for model: " << m_models[modelId] << ": " << m_currentPlayParameters << endl;
1280 1280
1289 } 1289 }
1290 1290
1291 bool 1291 bool
1292 SVFileReader::readPlugin(const QXmlAttributes &attributes) 1292 SVFileReader::readPlugin(const QXmlAttributes &attributes)
1293 { 1293 {
1294 if (m_currentDerivedModelId < 0 && !m_currentPlayParameters) { 1294 if (m_currentDerivedModelId >= 0) {
1295 return readPluginForTransform(attributes);
1296 } else if (m_currentPlayParameters) {
1297 return readPluginForPlayback(attributes);
1298 } else {
1295 cerr << "WARNING: SV-XML: Plugin found outside derivation or play parameters" << endl; 1299 cerr << "WARNING: SV-XML: Plugin found outside derivation or play parameters" << endl;
1296 return false; 1300 return false;
1297 } 1301 }
1298 1302 }
1299 if (!m_currentPlayParameters && m_currentTransformIsNewStyle) { 1303
1304 bool
1305 SVFileReader::readPluginForTransform(const QXmlAttributes &attributes)
1306 {
1307 if (m_currentTransformIsNewStyle) {
1308 // Not needed, we have the transform element instead
1300 return true; 1309 return true;
1301 } 1310 }
1302 1311
1303 QString configurationXml = "<plugin"; 1312 QString configurationXml = "<plugin";
1304 1313
1305 for (int i = 0; i < attributes.length(); ++i) { 1314 for (int i = 0; i < attributes.length(); ++i) {
1306 configurationXml += QString(" %1=\"%2\"") 1315 configurationXml += QString(" %1=\"%2\"")
1307 .arg(attributes.qName(i)) 1316 .arg(attributes.qName(i))
1308 .arg(XmlExportable::encodeEntities(attributes.value(i))); 1317 .arg(XmlExportable::encodeEntities(attributes.value(i)));
1309 } 1318 }
1310 1319
1311 configurationXml += "/>"; 1320 configurationXml += "/>";
1312 1321
1313 if (m_currentPlayParameters) { 1322 TransformFactory::getInstance()->
1314 m_currentPlayParameters->setPlayPluginConfiguration(configurationXml); 1323 setParametersFromPluginConfigurationXml(m_currentTransform,
1315 } else { 1324 configurationXml);
1316 TransformFactory::getInstance()-> 1325 return true;
1317 setParametersFromPluginConfigurationXml(m_currentTransform, 1326 }
1318 configurationXml); 1327
1328 bool
1329 SVFileReader::readPluginForPlayback(const QXmlAttributes &attributes)
1330 {
1331 // Obsolete but supported for compatibility
1332
1333 QString ident = attributes.value("identifier");
1334 if (ident == "sample_player") {
1335 QString sampleId = attributes.value("program");
1336 if (sampleId != "") m_currentPlayParameters->setPlaySampleId(sampleId);
1319 } 1337 }
1320 1338
1321 return true; 1339 return true;
1322 } 1340 }
1323 1341