Mercurial > hg > svapp
comparison framework/TransformUserConfigurator.cpp @ 751:ed5db7d37005 pitch-align
Merge from default branch
author | Chris Cannam |
---|---|
date | Wed, 22 Apr 2020 17:40:09 +0100 |
parents | bac019c94e38 |
children |
comparison
equal
deleted
inserted
replaced
744:36772d79cf44 | 751:ed5db7d37005 |
---|---|
38 parentWidget = w; | 38 parentWidget = w; |
39 } | 39 } |
40 | 40 |
41 bool | 41 bool |
42 TransformUserConfigurator::getChannelRange(TransformId identifier, | 42 TransformUserConfigurator::getChannelRange(TransformId identifier, |
43 Vamp::PluginBase *plugin, | 43 std::shared_ptr<Vamp::PluginBase> plugin, |
44 int &minChannels, int &maxChannels) | 44 int &minChannels, int &maxChannels) |
45 { | 45 { |
46 if (plugin && plugin->getType() == "Feature Extraction Plugin") { | 46 if (plugin && plugin->getType() == "Feature Extraction Plugin") { |
47 Vamp::Plugin *vp = static_cast<Vamp::Plugin *>(plugin); | 47 auto vp = std::dynamic_pointer_cast<Vamp::Plugin>(plugin); |
48 SVDEBUG << "TransformUserConfigurator::getChannelRange: is a Vamp plugin" << endl; | 48 if (vp) { |
49 minChannels = int(vp->getMinChannelCount()); | 49 SVDEBUG << "TransformUserConfigurator::getChannelRange: is a Vamp plugin" << endl; |
50 maxChannels = int(vp->getMaxChannelCount()); | 50 minChannels = int(vp->getMinChannelCount()); |
51 return true; | 51 maxChannels = int(vp->getMaxChannelCount()); |
52 return true; | |
53 } else { | |
54 SVCERR << "TransformUserConfigurator::getChannelRange: inconsistent plugin identity!" << endl; | |
55 return false; | |
56 } | |
52 } else { | 57 } else { |
53 SVDEBUG << "TransformUserConfigurator::getChannelRange: is not a Vamp plugin" << endl; | 58 SVDEBUG << "TransformUserConfigurator::getChannelRange: is not a Vamp plugin" << endl; |
54 return TransformFactory::getInstance()-> | 59 return TransformFactory::getInstance()-> |
55 getTransformChannelRange(identifier, minChannels, maxChannels); | 60 getTransformChannelRange(identifier, minChannels, maxChannels); |
56 } | 61 } |
57 } | 62 } |
58 | 63 |
59 bool | 64 bool |
60 TransformUserConfigurator::configure(ModelTransformer::Input &input, | 65 TransformUserConfigurator::configure(ModelTransformer::Input &input, |
61 Transform &transform, | 66 Transform &transform, |
62 Vamp::PluginBase *plugin, | 67 std::shared_ptr<Vamp::PluginBase> plugin, |
63 ModelId &inputModel, | 68 ModelId &inputModel, |
64 AudioPlaySource *source, | 69 AudioPlaySource *source, |
65 sv_frame_t startFrame, | 70 sv_frame_t startFrame, |
66 sv_frame_t duration, | 71 sv_frame_t duration, |
67 const QMap<QString, ModelId> &modelMap, | 72 const QMap<QString, ModelId> &modelMap, |
83 SVDEBUG << "TransformUserConfigurator::configure: identifier " << id << endl; | 88 SVDEBUG << "TransformUserConfigurator::configure: identifier " << id << endl; |
84 | 89 |
85 if (RealTimePluginFactory::instanceFor(id)) { | 90 if (RealTimePluginFactory::instanceFor(id)) { |
86 | 91 |
87 RealTimePluginFactory *factory = RealTimePluginFactory::instanceFor(id); | 92 RealTimePluginFactory *factory = RealTimePluginFactory::instanceFor(id); |
88 const RealTimePluginDescriptor *desc = factory->getPluginDescriptor(id); | 93 RealTimePluginDescriptor desc = factory->getPluginDescriptor(id); |
89 | 94 |
90 if (desc->audioInputPortCount > 0 && | 95 if (desc.audioInputPortCount > 0 && |
91 desc->audioOutputPortCount > 0 && | 96 desc.audioOutputPortCount > 0 && |
92 !desc->isSynth) { | 97 !desc.isSynth) { |
93 effect = true; | 98 effect = true; |
94 } | 99 } |
95 | 100 |
96 if (desc->audioInputPortCount == 0) { | 101 if (desc.audioInputPortCount == 0) { |
97 generator = true; | 102 generator = true; |
98 } | 103 } |
99 | 104 |
100 if (output != "A") { | 105 if (output != "A") { |
101 int outputNo = output.toInt(); | 106 int outputNo = output.toInt(); |
102 if (outputNo >= 0 && outputNo < int(desc->controlOutputPortCount)) { | 107 if (outputNo >= 0 && outputNo < int(desc.controlOutputPortCount)) { |
103 outputLabel = desc->controlOutputPortNames[outputNo].c_str(); | 108 outputLabel = desc.controlOutputPortNames[outputNo].c_str(); |
104 } | 109 } |
105 } | 110 } |
106 | 111 |
107 RealTimePluginInstance *rtp = | 112 auto auditionable = std::dynamic_pointer_cast<Auditionable>(plugin); |
108 static_cast<RealTimePluginInstance *>(plugin); | 113 |
109 | 114 if (effect && source && auditionable) { |
110 if (effect && source) { | |
111 SVDEBUG << "Setting auditioning effect" << endl; | 115 SVDEBUG << "Setting auditioning effect" << endl; |
112 source->setAuditioningEffect(rtp); | 116 source->setAuditioningEffect(auditionable); |
113 } | 117 } |
114 | 118 |
115 } else { | 119 } else { |
116 | 120 |
117 Vamp::Plugin *vp = static_cast<Vamp::Plugin *>(plugin); | 121 auto vp = std::dynamic_pointer_cast<Vamp::Plugin>(plugin); |
118 | 122 |
119 frequency = (vp->getInputDomain() == Vamp::Plugin::FrequencyDomain); | 123 frequency = (vp->getInputDomain() == Vamp::Plugin::FrequencyDomain); |
120 | 124 |
121 std::vector<Vamp::Plugin::OutputDescriptor> od = | 125 std::vector<Vamp::Plugin::OutputDescriptor> od = |
122 vp->getOutputDescriptors(); | 126 vp->getOutputDescriptors(); |
152 | 156 |
153 PluginParameterDialog *dialog = new PluginParameterDialog | 157 PluginParameterDialog *dialog = new PluginParameterDialog |
154 (plugin, parentWidget); | 158 (plugin, parentWidget); |
155 | 159 |
156 dialog->setMoreInfoUrl(TransformFactory::getInstance()-> | 160 dialog->setMoreInfoUrl(TransformFactory::getInstance()-> |
157 getTransformInfoUrl(transform.getIdentifier())); | 161 getTransformProvider(transform.getIdentifier()) |
162 .infoUrl); | |
158 | 163 |
159 if (candidateModelNames.size() > 1 && !generator) { | 164 if (candidateModelNames.size() > 1 && !generator) { |
160 dialog->setCandidateInputModels(candidateModelNames, | 165 dialog->setCandidateInputModels(candidateModelNames, |
161 defaultModelName); | 166 defaultModelName); |
162 } | 167 } |
227 transform.setWindowType(windowType); | 232 transform.setWindowType(windowType); |
228 | 233 |
229 delete dialog; | 234 delete dialog; |
230 | 235 |
231 if (effect && source) { | 236 if (effect && source) { |
232 source->setAuditioningEffect(nullptr); | 237 source->setAuditioningEffect({}); |
233 } | 238 } |
234 | 239 |
235 return ok; | 240 return ok; |
236 } | 241 } |
237 | 242 |