Mercurial > hg > sonic-visualiser
comparison transform/TransformFactory.cpp @ 27:61259228d029
* More to do with passing around step/blocksize etc from plugin dialog to
plugins. Still some puzzling unresolved details.
author | Chris Cannam |
---|---|
date | Tue, 19 Sep 2006 14:37:06 +0000 |
parents | d88d117e0c34 |
children | b5f55ea61bb8 |
comparison
equal
deleted
inserted
replaced
26:d88d117e0c34 | 27:61259228d029 |
---|---|
348 } | 348 } |
349 | 349 |
350 bool | 350 bool |
351 TransformFactory::getConfigurationForTransform(TransformName name, | 351 TransformFactory::getConfigurationForTransform(TransformName name, |
352 Model *inputModel, | 352 Model *inputModel, |
353 int &channel, | 353 PluginTransform::ExecutionContext &context, |
354 QString &configurationXml) | 354 QString &configurationXml) |
355 { | 355 { |
356 QString id = name.section(':', 0, 2); | 356 QString id = name.section(':', 0, 2); |
357 QString output = name.section(':', 3); | 357 QString output = name.section(':', 3); |
358 | 358 |
380 plugin = RealTimePluginFactory::instanceFor(id)->instantiatePlugin | 380 plugin = RealTimePluginFactory::instanceFor(id)->instantiatePlugin |
381 (id, 0, 0, inputModel->getSampleRate(), 1024, 1); | 381 (id, 0, 0, inputModel->getSampleRate(), 1024, 1); |
382 } | 382 } |
383 | 383 |
384 if (plugin) { | 384 if (plugin) { |
385 | |
386 context = PluginTransform::ExecutionContext(context.channel, plugin); | |
387 | |
385 if (configurationXml != "") { | 388 if (configurationXml != "") { |
386 PluginXml(plugin).setParametersFromXml(configurationXml); | 389 PluginXml(plugin).setParametersFromXml(configurationXml); |
387 } | 390 } |
388 | 391 |
389 int sourceChannels = 1; | 392 int sourceChannels = 1; |
397 | 400 |
398 int targetChannels = sourceChannels; | 401 int targetChannels = sourceChannels; |
399 if (sourceChannels < minChannels) targetChannels = minChannels; | 402 if (sourceChannels < minChannels) targetChannels = minChannels; |
400 if (sourceChannels > maxChannels) targetChannels = maxChannels; | 403 if (sourceChannels > maxChannels) targetChannels = maxChannels; |
401 | 404 |
402 int defaultChannel = channel; | 405 int defaultChannel = context.channel; |
403 | 406 |
404 PluginParameterDialog *dialog = new PluginParameterDialog(plugin, | 407 PluginParameterDialog *dialog = new PluginParameterDialog(plugin, |
405 sourceChannels, | 408 sourceChannels, |
406 targetChannels, | 409 targetChannels, |
407 defaultChannel, | 410 defaultChannel, |
410 frequency); | 413 frequency); |
411 if (dialog->exec() == QDialog::Accepted) { | 414 if (dialog->exec() == QDialog::Accepted) { |
412 ok = true; | 415 ok = true; |
413 } | 416 } |
414 configurationXml = PluginXml(plugin).toXmlString(); | 417 configurationXml = PluginXml(plugin).toXmlString(); |
415 channel = dialog->getChannel(); | 418 context.channel = dialog->getChannel(); |
416 | 419 |
417 //!!! where now for step size, block size, etc? | 420 dialog->getProcessingParameters(context.stepSize, |
418 // dialog->getProcessingParameters(stepSize, blockSize, windowType); | 421 context.blockSize, |
422 context.windowType); | |
423 | |
424 context.makeConsistentWithPlugin(plugin); | |
419 | 425 |
420 delete dialog; | 426 delete dialog; |
421 delete plugin; | 427 delete plugin; |
422 } | 428 } |
423 | 429 |
426 return ok; | 432 return ok; |
427 } | 433 } |
428 | 434 |
429 Transform * | 435 Transform * |
430 TransformFactory::createTransform(TransformName name, Model *inputModel, | 436 TransformFactory::createTransform(TransformName name, Model *inputModel, |
431 int channel, QString configurationXml, bool start) | 437 const PluginTransform::ExecutionContext &context, |
438 QString configurationXml, bool start) | |
432 { | 439 { |
433 Transform *transform = 0; | 440 Transform *transform = 0; |
434 | 441 |
435 //!!! use channel | |
436 | |
437 QString id = name.section(':', 0, 2); | 442 QString id = name.section(':', 0, 2); |
438 QString output = name.section(':', 3); | 443 QString output = name.section(':', 3); |
439 | 444 |
440 if (FeatureExtractionPluginFactory::instanceFor(id)) { | 445 if (FeatureExtractionPluginFactory::instanceFor(id)) { |
441 transform = new FeatureExtractionPluginTransform(inputModel, | 446 transform = new FeatureExtractionPluginTransform(inputModel, |
442 id, | 447 id, |
443 channel, | 448 context, |
444 configurationXml, | 449 configurationXml, |
445 output); | 450 output); |
446 } else if (RealTimePluginFactory::instanceFor(id)) { | 451 } else if (RealTimePluginFactory::instanceFor(id)) { |
447 transform = new RealTimePluginTransform(inputModel, | 452 transform = new RealTimePluginTransform(inputModel, |
448 id, | 453 id, |
449 channel, | 454 context, |
450 configurationXml, | 455 configurationXml, |
451 getTransformUnits(name), | 456 getTransformUnits(name), |
452 output.toInt()); | 457 output.toInt()); |
453 } else { | 458 } else { |
454 std::cerr << "TransformFactory::createTransform: Unknown transform \"" | 459 std::cerr << "TransformFactory::createTransform: Unknown transform \"" |
461 return transform; | 466 return transform; |
462 } | 467 } |
463 | 468 |
464 Model * | 469 Model * |
465 TransformFactory::transform(TransformName name, Model *inputModel, | 470 TransformFactory::transform(TransformName name, Model *inputModel, |
466 int channel, QString configurationXml) | 471 const PluginTransform::ExecutionContext &context, |
467 { | 472 QString configurationXml) |
468 Transform *t = createTransform(name, inputModel, channel, | 473 { |
474 Transform *t = createTransform(name, inputModel, context, | |
469 configurationXml, false); | 475 configurationXml, false); |
470 | 476 |
471 if (!t) return 0; | 477 if (!t) return 0; |
472 | 478 |
473 connect(t, SIGNAL(finished()), this, SLOT(transformFinished())); | 479 connect(t, SIGNAL(finished()), this, SLOT(transformFinished())); |