Chris@320
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@320
|
2
|
Chris@320
|
3 /*
|
Chris@320
|
4 Sonic Visualiser
|
Chris@320
|
5 An audio file viewer and annotation editor.
|
Chris@320
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@320
|
7 This file copyright 2006 Chris Cannam and QMUL.
|
Chris@320
|
8
|
Chris@320
|
9 This program is free software; you can redistribute it and/or
|
Chris@320
|
10 modify it under the terms of the GNU General Public License as
|
Chris@320
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@320
|
12 License, or (at your option) any later version. See the file
|
Chris@320
|
13 COPYING included with this distribution for more information.
|
Chris@320
|
14 */
|
Chris@320
|
15
|
Chris@331
|
16 #include "FeatureExtractionModelTransformer.h"
|
Chris@320
|
17
|
Chris@320
|
18 #include "plugin/FeatureExtractionPluginFactory.h"
|
Chris@320
|
19 #include "plugin/PluginXml.h"
|
Chris@475
|
20 #include <vamp-hostsdk/Plugin.h>
|
Chris@320
|
21
|
Chris@320
|
22 #include "data/model/Model.h"
|
Chris@320
|
23 #include "base/Window.h"
|
Chris@387
|
24 #include "base/Exceptions.h"
|
Chris@320
|
25 #include "data/model/SparseOneDimensionalModel.h"
|
Chris@320
|
26 #include "data/model/SparseTimeValueModel.h"
|
Chris@320
|
27 #include "data/model/EditableDenseThreeDimensionalModel.h"
|
Chris@320
|
28 #include "data/model/DenseTimeValueModel.h"
|
Chris@320
|
29 #include "data/model/NoteModel.h"
|
gyorgyf@786
|
30 #include "data/model/FlexiNoteModel.h"
|
Chris@441
|
31 #include "data/model/RegionModel.h"
|
Chris@320
|
32 #include "data/model/FFTModel.h"
|
Chris@320
|
33 #include "data/model/WaveFileModel.h"
|
Chris@558
|
34 #include "rdf/PluginRDFDescription.h"
|
Chris@320
|
35
|
Chris@350
|
36 #include "TransformFactory.h"
|
Chris@350
|
37
|
Chris@320
|
38 #include <iostream>
|
Chris@320
|
39
|
Chris@350
|
40 FeatureExtractionModelTransformer::FeatureExtractionModelTransformer(Input in,
|
gyorgyf@786
|
41 const Transform &transform,
|
gyorgyf@786
|
42 const PreferredOutputModel outputmodel) :
|
Chris@350
|
43 ModelTransformer(in, transform),
|
Chris@320
|
44 m_plugin(0),
|
Chris@320
|
45 m_descriptor(0),
|
gyorgyf@786
|
46 m_outputFeatureNo(0),
|
gyorgyf@786
|
47 m_preferredOutputModel(outputmodel)
|
Chris@320
|
48 {
|
Chris@690
|
49 // SVDEBUG << "FeatureExtractionModelTransformer::FeatureExtractionModelTransformer: plugin " << pluginId << ", outputName " << m_transform.getOutput() << endl;
|
Chris@350
|
50
|
Chris@350
|
51 QString pluginId = transform.getPluginIdentifier();
|
Chris@320
|
52
|
Chris@320
|
53 FeatureExtractionPluginFactory *factory =
|
Chris@320
|
54 FeatureExtractionPluginFactory::instanceFor(pluginId);
|
Chris@320
|
55
|
Chris@320
|
56 if (!factory) {
|
Chris@361
|
57 m_message = tr("No factory available for feature extraction plugin id \"%1\" (unknown plugin type, or internal error?)").arg(pluginId);
|
Chris@320
|
58 return;
|
Chris@320
|
59 }
|
Chris@320
|
60
|
Chris@350
|
61 DenseTimeValueModel *input = getConformingInput();
|
Chris@350
|
62 if (!input) {
|
Chris@361
|
63 m_message = tr("Input model for feature extraction plugin \"%1\" is of wrong type (internal error?)").arg(pluginId);
|
Chris@350
|
64 return;
|
Chris@350
|
65 }
|
Chris@320
|
66
|
Chris@350
|
67 m_plugin = factory->instantiatePlugin(pluginId, input->getSampleRate());
|
Chris@320
|
68 if (!m_plugin) {
|
Chris@361
|
69 m_message = tr("Failed to instantiate plugin \"%1\"").arg(pluginId);
|
Chris@320
|
70 return;
|
Chris@320
|
71 }
|
Chris@320
|
72
|
Chris@350
|
73 TransformFactory::getInstance()->makeContextConsistentWithPlugin
|
Chris@350
|
74 (m_transform, m_plugin);
|
Chris@343
|
75
|
Chris@350
|
76 TransformFactory::getInstance()->setPluginParameters
|
Chris@350
|
77 (m_transform, m_plugin);
|
Chris@320
|
78
|
Chris@320
|
79 size_t channelCount = input->getChannelCount();
|
Chris@320
|
80 if (m_plugin->getMaxChannelCount() < channelCount) {
|
Chris@320
|
81 channelCount = 1;
|
Chris@320
|
82 }
|
Chris@320
|
83 if (m_plugin->getMinChannelCount() > channelCount) {
|
Chris@361
|
84 m_message = tr("Cannot provide enough channels to feature extraction plugin \"%1\" (plugin min is %2, max %3; input model has %4)")
|
Chris@361
|
85 .arg(pluginId)
|
Chris@361
|
86 .arg(m_plugin->getMinChannelCount())
|
Chris@361
|
87 .arg(m_plugin->getMaxChannelCount())
|
Chris@361
|
88 .arg(input->getChannelCount());
|
Chris@320
|
89 return;
|
Chris@320
|
90 }
|
Chris@320
|
91
|
Chris@690
|
92 SVDEBUG << "Initialising feature extraction plugin with channels = "
|
Chris@350
|
93 << channelCount << ", step = " << m_transform.getStepSize()
|
Chris@687
|
94 << ", block = " << m_transform.getBlockSize() << endl;
|
Chris@320
|
95
|
Chris@320
|
96 if (!m_plugin->initialise(channelCount,
|
Chris@350
|
97 m_transform.getStepSize(),
|
Chris@350
|
98 m_transform.getBlockSize())) {
|
Chris@361
|
99
|
Chris@361
|
100 size_t pstep = m_transform.getStepSize();
|
Chris@361
|
101 size_t pblock = m_transform.getBlockSize();
|
Chris@361
|
102
|
Chris@361
|
103 m_transform.setStepSize(0);
|
Chris@361
|
104 m_transform.setBlockSize(0);
|
Chris@361
|
105 TransformFactory::getInstance()->makeContextConsistentWithPlugin
|
Chris@361
|
106 (m_transform, m_plugin);
|
Chris@361
|
107
|
Chris@361
|
108 if (m_transform.getStepSize() != pstep ||
|
Chris@361
|
109 m_transform.getBlockSize() != pblock) {
|
Chris@361
|
110
|
Chris@361
|
111 if (!m_plugin->initialise(channelCount,
|
Chris@361
|
112 m_transform.getStepSize(),
|
Chris@361
|
113 m_transform.getBlockSize())) {
|
Chris@361
|
114
|
Chris@361
|
115 m_message = tr("Failed to initialise feature extraction plugin \"%1\"").arg(pluginId);
|
Chris@361
|
116 return;
|
Chris@361
|
117
|
Chris@361
|
118 } else {
|
Chris@361
|
119
|
Chris@361
|
120 m_message = tr("Feature extraction plugin \"%1\" rejected the given step and block sizes (%2 and %3); using plugin defaults (%4 and %5) instead")
|
Chris@361
|
121 .arg(pluginId)
|
Chris@361
|
122 .arg(pstep)
|
Chris@361
|
123 .arg(pblock)
|
Chris@361
|
124 .arg(m_transform.getStepSize())
|
Chris@361
|
125 .arg(m_transform.getBlockSize());
|
Chris@361
|
126 }
|
Chris@361
|
127
|
Chris@361
|
128 } else {
|
Chris@361
|
129
|
Chris@361
|
130 m_message = tr("Failed to initialise feature extraction plugin \"%1\"").arg(pluginId);
|
Chris@361
|
131 return;
|
Chris@361
|
132 }
|
Chris@320
|
133 }
|
Chris@320
|
134
|
Chris@366
|
135 if (m_transform.getPluginVersion() != "") {
|
Chris@366
|
136 QString pv = QString("%1").arg(m_plugin->getPluginVersion());
|
Chris@366
|
137 if (pv != m_transform.getPluginVersion()) {
|
Chris@366
|
138 QString vm = tr("Transform was configured for version %1 of plugin \"%2\", but the plugin being used is version %3")
|
Chris@366
|
139 .arg(m_transform.getPluginVersion())
|
Chris@366
|
140 .arg(pluginId)
|
Chris@366
|
141 .arg(pv);
|
Chris@366
|
142 if (m_message != "") {
|
Chris@366
|
143 m_message = QString("%1; %2").arg(vm).arg(m_message);
|
Chris@366
|
144 } else {
|
Chris@366
|
145 m_message = vm;
|
Chris@366
|
146 }
|
Chris@366
|
147 }
|
Chris@366
|
148 }
|
Chris@366
|
149
|
Chris@320
|
150 Vamp::Plugin::OutputList outputs = m_plugin->getOutputDescriptors();
|
Chris@320
|
151
|
Chris@320
|
152 if (outputs.empty()) {
|
Chris@361
|
153 m_message = tr("Plugin \"%1\" has no outputs").arg(pluginId);
|
Chris@320
|
154 return;
|
Chris@320
|
155 }
|
Chris@320
|
156
|
Chris@320
|
157 for (size_t i = 0; i < outputs.size(); ++i) {
|
Chris@690
|
158 // SVDEBUG << "comparing output " << i << " name \"" << outputs[i].identifier << "\" with expected \"" << m_transform.getOutput() << "\"" << endl;
|
Chris@350
|
159 if (m_transform.getOutput() == "" ||
|
Chris@350
|
160 outputs[i].identifier == m_transform.getOutput().toStdString()) {
|
Chris@320
|
161 m_outputFeatureNo = i;
|
Chris@441
|
162 m_descriptor = new Vamp::Plugin::OutputDescriptor(outputs[i]);
|
Chris@320
|
163 break;
|
Chris@320
|
164 }
|
Chris@320
|
165 }
|
Chris@320
|
166
|
Chris@320
|
167 if (!m_descriptor) {
|
Chris@361
|
168 m_message = tr("Plugin \"%1\" has no output named \"%2\"")
|
Chris@361
|
169 .arg(pluginId)
|
Chris@361
|
170 .arg(m_transform.getOutput());
|
Chris@320
|
171 return;
|
Chris@320
|
172 }
|
Chris@320
|
173
|
Chris@558
|
174 createOutputModel();
|
Chris@558
|
175 }
|
Chris@558
|
176
|
Chris@558
|
177 void
|
Chris@558
|
178 FeatureExtractionModelTransformer::createOutputModel()
|
Chris@558
|
179 {
|
Chris@558
|
180 DenseTimeValueModel *input = getConformingInput();
|
Chris@558
|
181
|
Chris@712
|
182 // std::cerr << "FeatureExtractionModelTransformer::createOutputModel: sample type " << m_descriptor->sampleType << ", rate " << m_descriptor->sampleRate << std::endl;
|
Chris@712
|
183
|
Chris@558
|
184 PluginRDFDescription description(m_transform.getPluginIdentifier());
|
Chris@558
|
185 QString outputId = m_transform.getOutput();
|
Chris@558
|
186
|
Chris@320
|
187 int binCount = 1;
|
Chris@320
|
188 float minValue = 0.0, maxValue = 0.0;
|
Chris@320
|
189 bool haveExtents = false;
|
Chris@320
|
190
|
Chris@320
|
191 if (m_descriptor->hasFixedBinCount) {
|
Chris@320
|
192 binCount = m_descriptor->binCount;
|
Chris@320
|
193 }
|
Chris@320
|
194
|
Chris@331
|
195 // std::cerr << "FeatureExtractionModelTransformer: output bin count "
|
Chris@320
|
196 // << binCount << std::endl;
|
Chris@320
|
197
|
Chris@320
|
198 if (binCount > 0 && m_descriptor->hasKnownExtents) {
|
Chris@320
|
199 minValue = m_descriptor->minValue;
|
Chris@320
|
200 maxValue = m_descriptor->maxValue;
|
Chris@320
|
201 haveExtents = true;
|
Chris@320
|
202 }
|
Chris@320
|
203
|
Chris@350
|
204 size_t modelRate = input->getSampleRate();
|
Chris@320
|
205 size_t modelResolution = 1;
|
Chris@712
|
206
|
Chris@320
|
207 switch (m_descriptor->sampleType) {
|
Chris@320
|
208
|
Chris@320
|
209 case Vamp::Plugin::OutputDescriptor::VariableSampleRate:
|
Chris@320
|
210 if (m_descriptor->sampleRate != 0.0) {
|
Chris@320
|
211 modelResolution = size_t(modelRate / m_descriptor->sampleRate + 0.001);
|
Chris@320
|
212 }
|
Chris@320
|
213 break;
|
Chris@320
|
214
|
Chris@320
|
215 case Vamp::Plugin::OutputDescriptor::OneSamplePerStep:
|
Chris@350
|
216 modelResolution = m_transform.getStepSize();
|
Chris@320
|
217 break;
|
Chris@320
|
218
|
Chris@320
|
219 case Vamp::Plugin::OutputDescriptor::FixedSampleRate:
|
Chris@451
|
220 //!!! SV doesn't actually support display of models that have
|
Chris@451
|
221 //!!! different underlying rates together -- so we always set
|
Chris@451
|
222 //!!! the model rate to be the input model's rate, and adjust
|
Chris@451
|
223 //!!! the resolution appropriately. We can't properly display
|
Chris@451
|
224 //!!! data with a higher resolution than the base model at all
|
Chris@451
|
225 // modelRate = size_t(m_descriptor->sampleRate + 0.001);
|
Chris@451
|
226 if (m_descriptor->sampleRate > input->getSampleRate()) {
|
Chris@451
|
227 modelResolution = 1;
|
Chris@451
|
228 } else {
|
Chris@451
|
229 modelResolution = size_t(input->getSampleRate() /
|
Chris@451
|
230 m_descriptor->sampleRate);
|
Chris@451
|
231 }
|
Chris@320
|
232 break;
|
Chris@320
|
233 }
|
Chris@320
|
234
|
Chris@441
|
235 bool preDurationPlugin = (m_plugin->getVampApiVersion() < 2);
|
Chris@441
|
236
|
Chris@441
|
237 if (binCount == 0 &&
|
Chris@441
|
238 (preDurationPlugin || !m_descriptor->hasDuration)) {
|
Chris@320
|
239
|
Chris@445
|
240 // Anything with no value and no duration is an instant
|
Chris@445
|
241
|
Chris@320
|
242 m_output = new SparseOneDimensionalModel(modelRate, modelResolution,
|
Chris@320
|
243 false);
|
Chris@320
|
244
|
Chris@558
|
245 QString outputEventTypeURI = description.getOutputEventTypeURI(outputId);
|
Chris@558
|
246 m_output->setRDFTypeURI(outputEventTypeURI);
|
Chris@558
|
247
|
Chris@441
|
248 } else if ((preDurationPlugin && binCount > 1 &&
|
Chris@441
|
249 (m_descriptor->sampleType ==
|
Chris@441
|
250 Vamp::Plugin::OutputDescriptor::VariableSampleRate)) ||
|
Chris@441
|
251 (!preDurationPlugin && m_descriptor->hasDuration)) {
|
Chris@441
|
252
|
Chris@441
|
253 // For plugins using the old v1 API without explicit duration,
|
Chris@441
|
254 // we treat anything that has multiple bins (i.e. that has the
|
Chris@441
|
255 // potential to have value and duration) and a variable sample
|
Chris@441
|
256 // rate as a note model, taking its values as pitch, duration
|
Chris@441
|
257 // and velocity (if present) respectively. This is the same
|
Chris@441
|
258 // behaviour as always applied by SV to these plugins in the
|
Chris@441
|
259 // past.
|
Chris@441
|
260
|
Chris@441
|
261 // For plugins with the newer API, we treat anything with
|
Chris@441
|
262 // duration as either a note model with pitch and velocity, or
|
Chris@441
|
263 // a region model.
|
Chris@441
|
264
|
Chris@441
|
265 // How do we know whether it's an interval or note model?
|
Chris@441
|
266 // What's the essential difference? Is a note model any
|
Chris@441
|
267 // interval model using a Hz or "MIDI pitch" scale? There
|
Chris@441
|
268 // isn't really a reliable test for "MIDI pitch"... Does a
|
Chris@441
|
269 // note model always have velocity? This is a good question
|
Chris@441
|
270 // to be addressed by accompanying RDF, but for the moment we
|
Chris@441
|
271 // will do the following...
|
Chris@441
|
272
|
Chris@441
|
273 bool isNoteModel = false;
|
Chris@441
|
274
|
Chris@441
|
275 // Regions have only value (and duration -- we can't extract a
|
Chris@441
|
276 // region model from an old-style plugin that doesn't support
|
Chris@441
|
277 // duration)
|
Chris@441
|
278 if (binCount > 1) isNoteModel = true;
|
Chris@441
|
279
|
Chris@595
|
280 // Regions do not have units of Hz or MIDI things (a sweeping
|
Chris@595
|
281 // assumption!)
|
Chris@595
|
282 if (m_descriptor->unit == "Hz" ||
|
Chris@595
|
283 m_descriptor->unit.find("MIDI") != std::string::npos ||
|
Chris@595
|
284 m_descriptor->unit.find("midi") != std::string::npos) {
|
Chris@595
|
285 isNoteModel = true;
|
Chris@595
|
286 }
|
Chris@441
|
287
|
Chris@441
|
288 // If we had a "sparse 3D model", we would have the additional
|
Chris@441
|
289 // problem of determining whether to use that here (if bin
|
Chris@441
|
290 // count > 1). But we don't.
|
Chris@441
|
291
|
gyorgyf@786
|
292 if (isNoteModel && m_preferredOutputModel == NoteOutputModel) {
|
Chris@441
|
293
|
Chris@441
|
294 NoteModel *model;
|
gyorgyf@786
|
295 // FlexiNoteModel *model;
|
Chris@441
|
296 if (haveExtents) {
|
gyorgyf@786
|
297 // GF: hard coding FlexiNoteModel
|
gyorgyf@786
|
298 model = new NoteModel (modelRate, modelResolution, minValue, maxValue, false);
|
gyorgyf@786
|
299 // model = new FlexiNoteModel (modelRate, modelResolution, minValue, maxValue, false);
|
Chris@441
|
300 } else {
|
gyorgyf@786
|
301 model = new NoteModel (modelRate, modelResolution, false);
|
gyorgyf@786
|
302 // model = new FlexiNoteModel (modelRate, modelResolution, false);
|
gyorgyf@786
|
303 }
|
gyorgyf@786
|
304 model->setScaleUnits(m_descriptor->unit.c_str());
|
gyorgyf@786
|
305 m_output = model;
|
gyorgyf@786
|
306
|
gyorgyf@786
|
307 } else if (isNoteModel && m_preferredOutputModel == FlexiNoteOutputModel) {
|
gyorgyf@786
|
308
|
gyorgyf@786
|
309 // NoteModel *model;
|
gyorgyf@786
|
310 FlexiNoteModel *model;
|
gyorgyf@786
|
311 if (haveExtents) {
|
gyorgyf@786
|
312 // GF: hard coding FlexiNoteModel
|
gyorgyf@786
|
313 // model = new NoteModel (modelRate, modelResolution, minValue, maxValue, false);
|
gyorgyf@786
|
314 model = new FlexiNoteModel (modelRate, modelResolution, minValue, maxValue, false);
|
gyorgyf@786
|
315 } else {
|
gyorgyf@786
|
316 // model = new NoteModel (modelRate, modelResolution, false);
|
gyorgyf@786
|
317 model = new FlexiNoteModel (modelRate, modelResolution, false);
|
Chris@441
|
318 }
|
Chris@441
|
319 model->setScaleUnits(m_descriptor->unit.c_str());
|
Chris@441
|
320 m_output = model;
|
Chris@441
|
321
|
Chris@441
|
322 } else {
|
Chris@441
|
323
|
Chris@441
|
324 RegionModel *model;
|
Chris@441
|
325 if (haveExtents) {
|
Chris@441
|
326 model = new RegionModel
|
Chris@441
|
327 (modelRate, modelResolution, minValue, maxValue, false);
|
Chris@441
|
328 } else {
|
Chris@441
|
329 model = new RegionModel
|
Chris@441
|
330 (modelRate, modelResolution, false);
|
Chris@441
|
331 }
|
Chris@441
|
332 model->setScaleUnits(m_descriptor->unit.c_str());
|
Chris@441
|
333 m_output = model;
|
Chris@441
|
334 }
|
Chris@441
|
335
|
Chris@558
|
336 QString outputEventTypeURI = description.getOutputEventTypeURI(outputId);
|
Chris@558
|
337 m_output->setRDFTypeURI(outputEventTypeURI);
|
Chris@558
|
338
|
Chris@441
|
339 } else if (binCount == 1 ||
|
Chris@441
|
340 (m_descriptor->sampleType ==
|
Chris@441
|
341 Vamp::Plugin::OutputDescriptor::VariableSampleRate)) {
|
Chris@441
|
342
|
Chris@441
|
343 // Anything that is not a 1D, note, or interval model and that
|
Chris@441
|
344 // has only one value per result must be a sparse time value
|
Chris@441
|
345 // model.
|
Chris@441
|
346
|
Chris@441
|
347 // Anything that is not a 1D, note, or interval model and that
|
Chris@441
|
348 // has a variable sample rate is also treated as a sparse time
|
Chris@441
|
349 // value model regardless of its bin count, because we lack a
|
Chris@441
|
350 // sparse 3D model.
|
Chris@320
|
351
|
Chris@320
|
352 SparseTimeValueModel *model;
|
Chris@320
|
353 if (haveExtents) {
|
Chris@320
|
354 model = new SparseTimeValueModel
|
Chris@320
|
355 (modelRate, modelResolution, minValue, maxValue, false);
|
Chris@320
|
356 } else {
|
Chris@320
|
357 model = new SparseTimeValueModel
|
Chris@320
|
358 (modelRate, modelResolution, false);
|
Chris@320
|
359 }
|
Chris@558
|
360
|
Chris@558
|
361 Vamp::Plugin::OutputList outputs = m_plugin->getOutputDescriptors();
|
Chris@320
|
362 model->setScaleUnits(outputs[m_outputFeatureNo].unit.c_str());
|
Chris@320
|
363
|
Chris@320
|
364 m_output = model;
|
Chris@320
|
365
|
Chris@558
|
366 QString outputEventTypeURI = description.getOutputEventTypeURI(outputId);
|
Chris@558
|
367 m_output->setRDFTypeURI(outputEventTypeURI);
|
Chris@558
|
368
|
Chris@441
|
369 } else {
|
Chris@320
|
370
|
Chris@441
|
371 // Anything that is not a 1D, note, or interval model and that
|
Chris@441
|
372 // has a fixed sample rate and more than one value per result
|
Chris@441
|
373 // must be a dense 3D model.
|
Chris@320
|
374
|
Chris@320
|
375 EditableDenseThreeDimensionalModel *model =
|
Chris@320
|
376 new EditableDenseThreeDimensionalModel
|
Chris@535
|
377 (modelRate, modelResolution, binCount,
|
Chris@535
|
378 EditableDenseThreeDimensionalModel::BasicMultirateCompression,
|
Chris@535
|
379 false);
|
Chris@320
|
380
|
Chris@320
|
381 if (!m_descriptor->binNames.empty()) {
|
Chris@320
|
382 std::vector<QString> names;
|
Chris@320
|
383 for (size_t i = 0; i < m_descriptor->binNames.size(); ++i) {
|
Chris@320
|
384 names.push_back(m_descriptor->binNames[i].c_str());
|
Chris@320
|
385 }
|
Chris@320
|
386 model->setBinNames(names);
|
Chris@320
|
387 }
|
Chris@320
|
388
|
Chris@320
|
389 m_output = model;
|
Chris@558
|
390
|
Chris@558
|
391 QString outputSignalTypeURI = description.getOutputSignalTypeURI(outputId);
|
Chris@558
|
392 m_output->setRDFTypeURI(outputSignalTypeURI);
|
Chris@320
|
393 }
|
Chris@333
|
394
|
Chris@350
|
395 if (m_output) m_output->setSourceModel(input);
|
Chris@320
|
396 }
|
Chris@320
|
397
|
Chris@331
|
398 FeatureExtractionModelTransformer::~FeatureExtractionModelTransformer()
|
Chris@320
|
399 {
|
Chris@690
|
400 // SVDEBUG << "FeatureExtractionModelTransformer::~FeatureExtractionModelTransformer()" << endl;
|
Chris@320
|
401 delete m_plugin;
|
Chris@320
|
402 delete m_descriptor;
|
Chris@320
|
403 }
|
Chris@320
|
404
|
Chris@320
|
405 DenseTimeValueModel *
|
Chris@350
|
406 FeatureExtractionModelTransformer::getConformingInput()
|
Chris@320
|
407 {
|
Chris@690
|
408 // SVDEBUG << "FeatureExtractionModelTransformer::getConformingInput: input model is " << getInputModel() << endl;
|
Chris@408
|
409
|
Chris@320
|
410 DenseTimeValueModel *dtvm =
|
Chris@320
|
411 dynamic_cast<DenseTimeValueModel *>(getInputModel());
|
Chris@320
|
412 if (!dtvm) {
|
Chris@690
|
413 SVDEBUG << "FeatureExtractionModelTransformer::getConformingInput: WARNING: Input model is not conformable to DenseTimeValueModel" << endl;
|
Chris@320
|
414 }
|
Chris@320
|
415 return dtvm;
|
Chris@320
|
416 }
|
Chris@320
|
417
|
Chris@320
|
418 void
|
Chris@331
|
419 FeatureExtractionModelTransformer::run()
|
Chris@320
|
420 {
|
Chris@350
|
421 DenseTimeValueModel *input = getConformingInput();
|
Chris@320
|
422 if (!input) return;
|
Chris@320
|
423
|
Chris@320
|
424 if (!m_output) return;
|
Chris@320
|
425
|
Chris@497
|
426 while (!input->isReady() && !m_abandoned) {
|
Chris@690
|
427 SVDEBUG << "FeatureExtractionModelTransformer::run: Waiting for input model to be ready..." << endl;
|
Chris@497
|
428 usleep(500000);
|
Chris@320
|
429 }
|
Chris@497
|
430 if (m_abandoned) return;
|
Chris@320
|
431
|
Chris@350
|
432 size_t sampleRate = input->getSampleRate();
|
Chris@320
|
433
|
Chris@320
|
434 size_t channelCount = input->getChannelCount();
|
Chris@320
|
435 if (m_plugin->getMaxChannelCount() < channelCount) {
|
Chris@320
|
436 channelCount = 1;
|
Chris@320
|
437 }
|
Chris@320
|
438
|
Chris@320
|
439 float **buffers = new float*[channelCount];
|
Chris@320
|
440 for (size_t ch = 0; ch < channelCount; ++ch) {
|
Chris@350
|
441 buffers[ch] = new float[m_transform.getBlockSize() + 2];
|
Chris@320
|
442 }
|
Chris@320
|
443
|
Chris@350
|
444 size_t stepSize = m_transform.getStepSize();
|
Chris@350
|
445 size_t blockSize = m_transform.getBlockSize();
|
Chris@350
|
446
|
Chris@320
|
447 bool frequencyDomain = (m_plugin->getInputDomain() ==
|
Chris@320
|
448 Vamp::Plugin::FrequencyDomain);
|
Chris@320
|
449 std::vector<FFTModel *> fftModels;
|
Chris@320
|
450
|
Chris@320
|
451 if (frequencyDomain) {
|
Chris@320
|
452 for (size_t ch = 0; ch < channelCount; ++ch) {
|
Chris@320
|
453 FFTModel *model = new FFTModel
|
Chris@350
|
454 (getConformingInput(),
|
Chris@350
|
455 channelCount == 1 ? m_input.getChannel() : ch,
|
Chris@350
|
456 m_transform.getWindowType(),
|
Chris@350
|
457 blockSize,
|
Chris@350
|
458 stepSize,
|
Chris@350
|
459 blockSize,
|
Chris@334
|
460 false,
|
Chris@334
|
461 StorageAdviser::PrecisionCritical);
|
Chris@320
|
462 if (!model->isOK()) {
|
Chris@320
|
463 delete model;
|
Chris@320
|
464 setCompletion(100);
|
Chris@387
|
465 //!!! need a better way to handle this -- previously we were using a QMessageBox but that isn't an appropriate thing to do here either
|
Chris@387
|
466 throw AllocationFailed("Failed to create the FFT model for this feature extraction model transformer");
|
Chris@320
|
467 }
|
Chris@320
|
468 model->resume();
|
Chris@320
|
469 fftModels.push_back(model);
|
Chris@320
|
470 }
|
Chris@320
|
471 }
|
Chris@320
|
472
|
Chris@350
|
473 long startFrame = m_input.getModel()->getStartFrame();
|
Chris@350
|
474 long endFrame = m_input.getModel()->getEndFrame();
|
Chris@320
|
475
|
Chris@350
|
476 RealTime contextStartRT = m_transform.getStartTime();
|
Chris@350
|
477 RealTime contextDurationRT = m_transform.getDuration();
|
Chris@350
|
478
|
Chris@350
|
479 long contextStart =
|
Chris@350
|
480 RealTime::realTime2Frame(contextStartRT, sampleRate);
|
Chris@350
|
481
|
Chris@350
|
482 long contextDuration =
|
Chris@350
|
483 RealTime::realTime2Frame(contextDurationRT, sampleRate);
|
Chris@320
|
484
|
Chris@320
|
485 if (contextStart == 0 || contextStart < startFrame) {
|
Chris@320
|
486 contextStart = startFrame;
|
Chris@320
|
487 }
|
Chris@320
|
488
|
Chris@320
|
489 if (contextDuration == 0) {
|
Chris@320
|
490 contextDuration = endFrame - contextStart;
|
Chris@320
|
491 }
|
Chris@320
|
492 if (contextStart + contextDuration > endFrame) {
|
Chris@320
|
493 contextDuration = endFrame - contextStart;
|
Chris@320
|
494 }
|
Chris@320
|
495
|
Chris@320
|
496 long blockFrame = contextStart;
|
Chris@320
|
497
|
Chris@320
|
498 long prevCompletion = 0;
|
Chris@320
|
499
|
Chris@320
|
500 setCompletion(0);
|
Chris@320
|
501
|
Chris@556
|
502 float *reals = 0;
|
Chris@556
|
503 float *imaginaries = 0;
|
Chris@556
|
504 if (frequencyDomain) {
|
Chris@556
|
505 reals = new float[blockSize/2 + 1];
|
Chris@556
|
506 imaginaries = new float[blockSize/2 + 1];
|
Chris@556
|
507 }
|
Chris@556
|
508
|
Chris@678
|
509 QString error = "";
|
Chris@678
|
510
|
Chris@320
|
511 while (!m_abandoned) {
|
Chris@320
|
512
|
Chris@320
|
513 if (frequencyDomain) {
|
Chris@350
|
514 if (blockFrame - int(blockSize)/2 >
|
Chris@320
|
515 contextStart + contextDuration) break;
|
Chris@320
|
516 } else {
|
Chris@320
|
517 if (blockFrame >=
|
Chris@320
|
518 contextStart + contextDuration) break;
|
Chris@320
|
519 }
|
Chris@320
|
520
|
Chris@690
|
521 // SVDEBUG << "FeatureExtractionModelTransformer::run: blockFrame "
|
Chris@320
|
522 // << blockFrame << ", endFrame " << endFrame << ", blockSize "
|
Chris@687
|
523 // << blockSize << endl;
|
Chris@320
|
524
|
Chris@320
|
525 long completion =
|
Chris@350
|
526 (((blockFrame - contextStart) / stepSize) * 99) /
|
Chris@557
|
527 (contextDuration / stepSize + 1);
|
Chris@320
|
528
|
Chris@350
|
529 // channelCount is either m_input.getModel()->channelCount or 1
|
Chris@320
|
530
|
Chris@363
|
531 if (frequencyDomain) {
|
Chris@363
|
532 for (size_t ch = 0; ch < channelCount; ++ch) {
|
Chris@350
|
533 int column = (blockFrame - startFrame) / stepSize;
|
Chris@556
|
534 fftModels[ch]->getValuesAt(column, reals, imaginaries);
|
Chris@350
|
535 for (size_t i = 0; i <= blockSize/2; ++i) {
|
Chris@556
|
536 buffers[ch][i*2] = reals[i];
|
Chris@556
|
537 buffers[ch][i*2+1] = imaginaries[i];
|
Chris@320
|
538 }
|
Chris@678
|
539 error = fftModels[ch]->getError();
|
Chris@678
|
540 if (error != "") {
|
Chris@686
|
541 std::cerr << "FeatureExtractionModelTransformer::run: Abandoning, error is " << error << std::endl;
|
Chris@678
|
542 m_abandoned = true;
|
Chris@678
|
543 m_message = error;
|
Chris@678
|
544 }
|
Chris@363
|
545 }
|
Chris@363
|
546 } else {
|
Chris@363
|
547 getFrames(channelCount, blockFrame, blockSize, buffers);
|
Chris@320
|
548 }
|
Chris@320
|
549
|
Chris@497
|
550 if (m_abandoned) break;
|
Chris@497
|
551
|
Chris@320
|
552 Vamp::Plugin::FeatureSet features = m_plugin->process
|
Chris@320
|
553 (buffers, Vamp::RealTime::frame2RealTime(blockFrame, sampleRate));
|
Chris@320
|
554
|
Chris@497
|
555 if (m_abandoned) break;
|
Chris@497
|
556
|
Chris@320
|
557 for (size_t fi = 0; fi < features[m_outputFeatureNo].size(); ++fi) {
|
Chris@320
|
558 Vamp::Plugin::Feature feature =
|
Chris@320
|
559 features[m_outputFeatureNo][fi];
|
Chris@320
|
560 addFeature(blockFrame, feature);
|
Chris@320
|
561 }
|
Chris@320
|
562
|
Chris@320
|
563 if (blockFrame == contextStart || completion > prevCompletion) {
|
Chris@320
|
564 setCompletion(completion);
|
Chris@320
|
565 prevCompletion = completion;
|
Chris@320
|
566 }
|
Chris@320
|
567
|
Chris@350
|
568 blockFrame += stepSize;
|
Chris@320
|
569 }
|
Chris@320
|
570
|
Chris@497
|
571 if (!m_abandoned) {
|
Chris@497
|
572 Vamp::Plugin::FeatureSet features = m_plugin->getRemainingFeatures();
|
Chris@320
|
573
|
Chris@497
|
574 for (size_t fi = 0; fi < features[m_outputFeatureNo].size(); ++fi) {
|
Chris@497
|
575 Vamp::Plugin::Feature feature =
|
Chris@497
|
576 features[m_outputFeatureNo][fi];
|
Chris@497
|
577 addFeature(blockFrame, feature);
|
Chris@497
|
578 }
|
Chris@497
|
579 }
|
Chris@320
|
580
|
Chris@497
|
581 setCompletion(100);
|
Chris@320
|
582
|
Chris@320
|
583 if (frequencyDomain) {
|
Chris@320
|
584 for (size_t ch = 0; ch < channelCount; ++ch) {
|
Chris@320
|
585 delete fftModels[ch];
|
Chris@320
|
586 }
|
Chris@556
|
587 delete[] reals;
|
Chris@556
|
588 delete[] imaginaries;
|
Chris@320
|
589 }
|
Chris@320
|
590 }
|
Chris@320
|
591
|
Chris@320
|
592 void
|
Chris@363
|
593 FeatureExtractionModelTransformer::getFrames(int channelCount,
|
Chris@363
|
594 long startFrame, long size,
|
Chris@363
|
595 float **buffers)
|
Chris@320
|
596 {
|
Chris@320
|
597 long offset = 0;
|
Chris@320
|
598
|
Chris@320
|
599 if (startFrame < 0) {
|
Chris@363
|
600 for (int c = 0; c < channelCount; ++c) {
|
Chris@363
|
601 for (int i = 0; i < size && startFrame + i < 0; ++i) {
|
Chris@363
|
602 buffers[c][i] = 0.0f;
|
Chris@363
|
603 }
|
Chris@320
|
604 }
|
Chris@320
|
605 offset = -startFrame;
|
Chris@320
|
606 size -= offset;
|
Chris@320
|
607 if (size <= 0) return;
|
Chris@320
|
608 startFrame = 0;
|
Chris@320
|
609 }
|
Chris@320
|
610
|
Chris@350
|
611 DenseTimeValueModel *input = getConformingInput();
|
Chris@350
|
612 if (!input) return;
|
Chris@363
|
613
|
Chris@363
|
614 long got = 0;
|
Chris@350
|
615
|
Chris@363
|
616 if (channelCount == 1) {
|
Chris@363
|
617
|
Chris@363
|
618 got = input->getData(m_input.getChannel(), startFrame, size,
|
Chris@363
|
619 buffers[0] + offset);
|
Chris@363
|
620
|
Chris@363
|
621 if (m_input.getChannel() == -1 && input->getChannelCount() > 1) {
|
Chris@363
|
622 // use mean instead of sum, as plugin input
|
Chris@363
|
623 float cc = float(input->getChannelCount());
|
Chris@363
|
624 for (long i = 0; i < size; ++i) {
|
Chris@363
|
625 buffers[0][i + offset] /= cc;
|
Chris@363
|
626 }
|
Chris@363
|
627 }
|
Chris@363
|
628
|
Chris@363
|
629 } else {
|
Chris@363
|
630
|
Chris@363
|
631 float **writebuf = buffers;
|
Chris@363
|
632 if (offset > 0) {
|
Chris@363
|
633 writebuf = new float *[channelCount];
|
Chris@363
|
634 for (int i = 0; i < channelCount; ++i) {
|
Chris@363
|
635 writebuf[i] = buffers[i] + offset;
|
Chris@363
|
636 }
|
Chris@363
|
637 }
|
Chris@363
|
638
|
Chris@363
|
639 got = input->getData(0, channelCount-1, startFrame, size, writebuf);
|
Chris@363
|
640
|
Chris@363
|
641 if (writebuf != buffers) delete[] writebuf;
|
Chris@363
|
642 }
|
Chris@320
|
643
|
Chris@320
|
644 while (got < size) {
|
Chris@363
|
645 for (int c = 0; c < channelCount; ++c) {
|
Chris@363
|
646 buffers[c][got + offset] = 0.0;
|
Chris@363
|
647 }
|
Chris@320
|
648 ++got;
|
Chris@320
|
649 }
|
Chris@320
|
650 }
|
Chris@320
|
651
|
Chris@320
|
652 void
|
Chris@331
|
653 FeatureExtractionModelTransformer::addFeature(size_t blockFrame,
|
Chris@320
|
654 const Vamp::Plugin::Feature &feature)
|
Chris@320
|
655 {
|
Chris@350
|
656 size_t inputRate = m_input.getModel()->getSampleRate();
|
Chris@320
|
657
|
Chris@712
|
658 // std::cerr << "FeatureExtractionModelTransformer::addFeature: blockFrame = "
|
Chris@712
|
659 // << blockFrame << ", hasTimestamp = " << feature.hasTimestamp
|
Chris@712
|
660 // << ", timestamp = " << feature.timestamp << ", hasDuration = "
|
Chris@712
|
661 // << feature.hasDuration << ", duration = " << feature.duration
|
Chris@712
|
662 // << std::endl;
|
Chris@320
|
663
|
Chris@320
|
664 int binCount = 1;
|
Chris@320
|
665 if (m_descriptor->hasFixedBinCount) {
|
Chris@320
|
666 binCount = m_descriptor->binCount;
|
Chris@320
|
667 }
|
Chris@320
|
668
|
Chris@320
|
669 size_t frame = blockFrame;
|
Chris@320
|
670
|
Chris@320
|
671 if (m_descriptor->sampleType ==
|
Chris@320
|
672 Vamp::Plugin::OutputDescriptor::VariableSampleRate) {
|
Chris@320
|
673
|
Chris@320
|
674 if (!feature.hasTimestamp) {
|
Chris@320
|
675 std::cerr
|
Chris@331
|
676 << "WARNING: FeatureExtractionModelTransformer::addFeature: "
|
Chris@320
|
677 << "Feature has variable sample rate but no timestamp!"
|
Chris@320
|
678 << std::endl;
|
Chris@320
|
679 return;
|
Chris@320
|
680 } else {
|
Chris@320
|
681 frame = Vamp::RealTime::realTime2Frame(feature.timestamp, inputRate);
|
Chris@320
|
682 }
|
Chris@320
|
683
|
Chris@320
|
684 } else if (m_descriptor->sampleType ==
|
Chris@320
|
685 Vamp::Plugin::OutputDescriptor::FixedSampleRate) {
|
Chris@320
|
686
|
Chris@320
|
687 if (feature.hasTimestamp) {
|
Chris@320
|
688 //!!! warning: sampleRate may be non-integral
|
Chris@320
|
689 frame = Vamp::RealTime::realTime2Frame(feature.timestamp,
|
Chris@451
|
690 //!!! see comment above when setting up modelResolution and modelRate
|
Chris@451
|
691 // lrintf(m_descriptor->sampleRate));
|
Chris@451
|
692 inputRate);
|
Chris@320
|
693 } else {
|
Chris@320
|
694 frame = m_output->getEndFrame();
|
Chris@320
|
695 }
|
Chris@320
|
696 }
|
Chris@320
|
697
|
Chris@441
|
698 // Rather than repeat the complicated tests from the constructor
|
Chris@441
|
699 // to determine what sort of model we must be adding the features
|
Chris@441
|
700 // to, we instead test what sort of model the constructor decided
|
Chris@441
|
701 // to create.
|
Chris@320
|
702
|
Chris@441
|
703 if (isOutput<SparseOneDimensionalModel>()) {
|
Chris@441
|
704
|
Chris@441
|
705 SparseOneDimensionalModel *model =
|
Chris@350
|
706 getConformingOutput<SparseOneDimensionalModel>();
|
Chris@320
|
707 if (!model) return;
|
Chris@350
|
708
|
Chris@441
|
709 model->addPoint(SparseOneDimensionalModel::Point
|
Chris@441
|
710 (frame, feature.label.c_str()));
|
Chris@320
|
711
|
Chris@441
|
712 } else if (isOutput<SparseTimeValueModel>()) {
|
Chris@320
|
713
|
Chris@350
|
714 SparseTimeValueModel *model =
|
Chris@350
|
715 getConformingOutput<SparseTimeValueModel>();
|
Chris@320
|
716 if (!model) return;
|
Chris@350
|
717
|
Chris@454
|
718 for (int i = 0; i < feature.values.size(); ++i) {
|
Chris@454
|
719
|
Chris@454
|
720 float value = feature.values[i];
|
Chris@454
|
721
|
Chris@454
|
722 QString label = feature.label.c_str();
|
Chris@454
|
723 if (feature.values.size() > 1) {
|
Chris@454
|
724 label = QString("[%1] %2").arg(i+1).arg(label);
|
Chris@454
|
725 }
|
Chris@454
|
726
|
Chris@454
|
727 model->addPoint(SparseTimeValueModel::Point(frame, value, label));
|
Chris@454
|
728 }
|
Chris@320
|
729
|
gyorgyf@786
|
730 } else if (isOutput<FlexiNoteModel>() || isOutput<NoteModel>() || isOutput<RegionModel>()) { //GF: Added Note Model
|
Chris@320
|
731
|
Chris@441
|
732 int index = 0;
|
Chris@441
|
733
|
Chris@441
|
734 float value = 0.0;
|
Chris@441
|
735 if (feature.values.size() > index) {
|
Chris@441
|
736 value = feature.values[index++];
|
Chris@441
|
737 }
|
Chris@320
|
738
|
Chris@320
|
739 float duration = 1;
|
Chris@441
|
740 if (feature.hasDuration) {
|
Chris@441
|
741 duration = Vamp::RealTime::realTime2Frame(feature.duration, inputRate);
|
Chris@441
|
742 } else {
|
Chris@441
|
743 if (feature.values.size() > index) {
|
Chris@441
|
744 duration = feature.values[index++];
|
Chris@441
|
745 }
|
Chris@441
|
746 }
|
gyorgyf@786
|
747
|
gyorgyf@786
|
748 if (isOutput<FlexiNoteModel>()) { // GF: added for flexi note model
|
gyorgyf@786
|
749
|
gyorgyf@786
|
750 float velocity = 100;
|
gyorgyf@786
|
751 if (feature.values.size() > index) {
|
gyorgyf@786
|
752 velocity = feature.values[index++];
|
gyorgyf@786
|
753 }
|
gyorgyf@786
|
754 if (velocity < 0) velocity = 127;
|
gyorgyf@786
|
755 if (velocity > 127) velocity = 127;
|
gyorgyf@786
|
756
|
gyorgyf@786
|
757 FlexiNoteModel *model = getConformingOutput<FlexiNoteModel>();
|
gyorgyf@786
|
758 if (!model) return;
|
gyorgyf@786
|
759 model->addPoint(FlexiNoteModel::Point(frame, value, // value is pitch
|
gyorgyf@786
|
760 lrintf(duration),
|
gyorgyf@786
|
761 velocity / 127.f,
|
gyorgyf@786
|
762 feature.label.c_str()));
|
gyorgyf@786
|
763 // GF: end -- added for flexi note model
|
gyorgyf@786
|
764 } else if (isOutput<NoteModel>()) {
|
Chris@320
|
765
|
Chris@441
|
766 float velocity = 100;
|
Chris@441
|
767 if (feature.values.size() > index) {
|
Chris@441
|
768 velocity = feature.values[index++];
|
Chris@441
|
769 }
|
Chris@441
|
770 if (velocity < 0) velocity = 127;
|
Chris@441
|
771 if (velocity > 127) velocity = 127;
|
Chris@320
|
772
|
Chris@441
|
773 NoteModel *model = getConformingOutput<NoteModel>();
|
Chris@441
|
774 if (!model) return;
|
Chris@441
|
775 model->addPoint(NoteModel::Point(frame, value, // value is pitch
|
Chris@441
|
776 lrintf(duration),
|
Chris@441
|
777 velocity / 127.f,
|
Chris@441
|
778 feature.label.c_str()));
|
Chris@441
|
779 } else {
|
gyorgyf@786
|
780
|
Chris@441
|
781 RegionModel *model = getConformingOutput<RegionModel>();
|
Chris@454
|
782 if (!model) return;
|
Chris@454
|
783
|
Chris@474
|
784 if (feature.hasDuration && !feature.values.empty()) {
|
Chris@454
|
785
|
Chris@454
|
786 for (int i = 0; i < feature.values.size(); ++i) {
|
Chris@454
|
787
|
Chris@454
|
788 float value = feature.values[i];
|
Chris@454
|
789
|
Chris@454
|
790 QString label = feature.label.c_str();
|
Chris@454
|
791 if (feature.values.size() > 1) {
|
Chris@454
|
792 label = QString("[%1] %2").arg(i+1).arg(label);
|
Chris@454
|
793 }
|
Chris@454
|
794
|
Chris@454
|
795 model->addPoint(RegionModel::Point(frame, value,
|
Chris@454
|
796 lrintf(duration),
|
Chris@454
|
797 label));
|
Chris@454
|
798 }
|
Chris@454
|
799 } else {
|
Chris@454
|
800
|
Chris@441
|
801 model->addPoint(RegionModel::Point(frame, value,
|
Chris@441
|
802 lrintf(duration),
|
Chris@441
|
803 feature.label.c_str()));
|
Chris@454
|
804 }
|
Chris@441
|
805 }
|
Chris@320
|
806
|
Chris@441
|
807 } else if (isOutput<EditableDenseThreeDimensionalModel>()) {
|
Chris@320
|
808
|
Chris@533
|
809 DenseThreeDimensionalModel::Column values =
|
Chris@533
|
810 DenseThreeDimensionalModel::Column::fromStdVector(feature.values);
|
Chris@320
|
811
|
Chris@320
|
812 EditableDenseThreeDimensionalModel *model =
|
Chris@350
|
813 getConformingOutput<EditableDenseThreeDimensionalModel>();
|
Chris@320
|
814 if (!model) return;
|
Chris@320
|
815
|
Chris@320
|
816 model->setColumn(frame / model->getResolution(), values);
|
Chris@441
|
817
|
Chris@441
|
818 } else {
|
Chris@690
|
819 SVDEBUG << "FeatureExtractionModelTransformer::addFeature: Unknown output model type!" << endl;
|
Chris@320
|
820 }
|
Chris@320
|
821 }
|
Chris@320
|
822
|
Chris@320
|
823 void
|
Chris@331
|
824 FeatureExtractionModelTransformer::setCompletion(int completion)
|
Chris@320
|
825 {
|
Chris@320
|
826 int binCount = 1;
|
Chris@320
|
827 if (m_descriptor->hasFixedBinCount) {
|
Chris@320
|
828 binCount = m_descriptor->binCount;
|
Chris@320
|
829 }
|
Chris@320
|
830
|
Chris@690
|
831 // SVDEBUG << "FeatureExtractionModelTransformer::setCompletion("
|
Chris@687
|
832 // << completion << ")" << endl;
|
Chris@320
|
833
|
Chris@441
|
834 if (isOutput<SparseOneDimensionalModel>()) {
|
Chris@320
|
835
|
Chris@350
|
836 SparseOneDimensionalModel *model =
|
Chris@350
|
837 getConformingOutput<SparseOneDimensionalModel>();
|
Chris@320
|
838 if (!model) return;
|
Chris@441
|
839 model->setCompletion(completion, true);
|
Chris@320
|
840
|
Chris@441
|
841 } else if (isOutput<SparseTimeValueModel>()) {
|
Chris@320
|
842
|
Chris@350
|
843 SparseTimeValueModel *model =
|
Chris@350
|
844 getConformingOutput<SparseTimeValueModel>();
|
Chris@320
|
845 if (!model) return;
|
Chris@441
|
846 model->setCompletion(completion, true);
|
Chris@320
|
847
|
Chris@441
|
848 } else if (isOutput<NoteModel>()) {
|
Chris@320
|
849
|
Chris@441
|
850 NoteModel *model = getConformingOutput<NoteModel>();
|
Chris@320
|
851 if (!model) return;
|
Chris@441
|
852 model->setCompletion(completion, true);
|
gyorgyf@786
|
853
|
gyorgyf@786
|
854 } else if (isOutput<FlexiNoteModel>()) {
|
gyorgyf@786
|
855
|
gyorgyf@786
|
856 FlexiNoteModel *model = getConformingOutput<FlexiNoteModel>();
|
gyorgyf@786
|
857 if (!model) return;
|
gyorgyf@786
|
858 model->setCompletion(completion, true);
|
Chris@320
|
859
|
Chris@441
|
860 } else if (isOutput<RegionModel>()) {
|
Chris@441
|
861
|
Chris@441
|
862 RegionModel *model = getConformingOutput<RegionModel>();
|
Chris@441
|
863 if (!model) return;
|
Chris@441
|
864 model->setCompletion(completion, true);
|
Chris@441
|
865
|
Chris@441
|
866 } else if (isOutput<EditableDenseThreeDimensionalModel>()) {
|
Chris@320
|
867
|
Chris@320
|
868 EditableDenseThreeDimensionalModel *model =
|
Chris@350
|
869 getConformingOutput<EditableDenseThreeDimensionalModel>();
|
Chris@320
|
870 if (!model) return;
|
Chris@350
|
871 model->setCompletion(completion, true); //!!!m_context.updates);
|
Chris@320
|
872 }
|
Chris@320
|
873 }
|
Chris@320
|
874
|