Mercurial > hg > sonic-visualiser
comparison transform/TransformFactory.cpp @ 41:fbd7a497fd89
* Audition effects plugins during playback
author | Chris Cannam |
---|---|
date | Wed, 04 Oct 2006 11:01:39 +0000 |
parents | 06787742542a |
children | c0ae41c72421 |
comparison
equal
deleted
inserted
replaced
40:75c5951cf9d7 | 41:fbd7a497fd89 |
---|---|
26 | 26 |
27 #include "data/model/DenseTimeValueModel.h" | 27 #include "data/model/DenseTimeValueModel.h" |
28 | 28 |
29 #include "vamp-sdk/PluginHostAdapter.h" | 29 #include "vamp-sdk/PluginHostAdapter.h" |
30 | 30 |
31 #include "sv/audioio/AudioCallbackPlaySource.h" //!!! shouldn't include here | |
32 | |
31 #include <iostream> | 33 #include <iostream> |
32 #include <set> | 34 #include <set> |
33 | 35 |
34 #include <QRegExp> | 36 #include <QRegExp> |
35 | 37 |
441 | 443 |
442 bool | 444 bool |
443 TransformFactory::getConfigurationForTransform(TransformName name, | 445 TransformFactory::getConfigurationForTransform(TransformName name, |
444 Model *inputModel, | 446 Model *inputModel, |
445 PluginTransform::ExecutionContext &context, | 447 PluginTransform::ExecutionContext &context, |
446 QString &configurationXml) | 448 QString &configurationXml, |
449 AudioCallbackPlaySource *source) | |
447 { | 450 { |
448 QString id = name.section(':', 0, 2); | 451 QString id = name.section(':', 0, 2); |
449 QString output = name.section(':', 3); | 452 QString output = name.section(':', 3); |
450 | 453 |
451 bool ok = false; | 454 bool ok = false; |
454 // std::cerr << "last configuration: " << configurationXml.toStdString() << std::endl; | 457 // std::cerr << "last configuration: " << configurationXml.toStdString() << std::endl; |
455 | 458 |
456 Vamp::PluginBase *plugin = 0; | 459 Vamp::PluginBase *plugin = 0; |
457 | 460 |
458 bool frequency = false; | 461 bool frequency = false; |
462 bool effect = false; | |
459 | 463 |
460 if (FeatureExtractionPluginFactory::instanceFor(id)) { | 464 if (FeatureExtractionPluginFactory::instanceFor(id)) { |
461 | 465 |
462 Vamp::Plugin *vp = | 466 Vamp::Plugin *vp = |
463 FeatureExtractionPluginFactory::instanceFor(id)->instantiatePlugin | 467 FeatureExtractionPluginFactory::instanceFor(id)->instantiatePlugin |
467 frequency = (vp->getInputDomain() == Vamp::Plugin::FrequencyDomain); | 471 frequency = (vp->getInputDomain() == Vamp::Plugin::FrequencyDomain); |
468 } | 472 } |
469 | 473 |
470 } else if (RealTimePluginFactory::instanceFor(id)) { | 474 } else if (RealTimePluginFactory::instanceFor(id)) { |
471 | 475 |
472 plugin = RealTimePluginFactory::instanceFor(id)->instantiatePlugin | 476 RealTimePluginFactory *factory = RealTimePluginFactory::instanceFor(id); |
473 (id, 0, 0, inputModel->getSampleRate(), 1024, 1); | 477 const RealTimePluginDescriptor *desc = factory->getPluginDescriptor(id); |
478 | |
479 if (desc->audioInputPortCount > 0 && | |
480 desc->audioOutputPortCount > 0 && | |
481 !desc->isSynth) { | |
482 effect = true; | |
483 } | |
484 | |
485 size_t sampleRate = inputModel->getSampleRate(); | |
486 size_t blockSize = 1024; | |
487 size_t channels = 1; | |
488 if (effect && source) { | |
489 sampleRate = source->getTargetSampleRate(); | |
490 blockSize = source->getTargetBlockSize(); | |
491 channels = source->getTargetChannelCount(); | |
492 } | |
493 | |
494 RealTimePluginInstance *rtp = factory->instantiatePlugin | |
495 (id, 0, 0, sampleRate, blockSize, channels); | |
496 | |
497 plugin = rtp; | |
498 | |
499 if (effect && source && rtp) { | |
500 source->setAuditioningPlugin(rtp); | |
501 } | |
474 } | 502 } |
475 | 503 |
476 if (plugin) { | 504 if (plugin) { |
477 | 505 |
478 context = PluginTransform::ExecutionContext(context.channel, plugin); | 506 context = PluginTransform::ExecutionContext(context.channel, plugin); |
514 context.windowType); | 542 context.windowType); |
515 | 543 |
516 context.makeConsistentWithPlugin(plugin); | 544 context.makeConsistentWithPlugin(plugin); |
517 | 545 |
518 delete dialog; | 546 delete dialog; |
519 delete plugin; | 547 |
548 if (effect && source) { | |
549 source->setAuditioningPlugin(0); // will delete our plugin | |
550 } else { | |
551 delete plugin; | |
552 } | |
520 } | 553 } |
521 | 554 |
522 if (ok) m_lastConfigurations[name] = configurationXml; | 555 if (ok) m_lastConfigurations[name] = configurationXml; |
523 | 556 |
524 return ok; | 557 return ok; |