comparison transform/FeatureExtractionModelTransformer.cpp @ 558:1d7ebc05157e

* Some fairly simplistic code to set up layer type properties based on RDF data about feature types (both when running transforms and when importing features from RDF files).
author Chris Cannam
date Thu, 12 Feb 2009 15:26:43 +0000
parents a40023bebd15
children 3bbac921b70a
comparison
equal deleted inserted replaced
557:a40023bebd15 558:1d7ebc05157e
28 #include "data/model/DenseTimeValueModel.h" 28 #include "data/model/DenseTimeValueModel.h"
29 #include "data/model/NoteModel.h" 29 #include "data/model/NoteModel.h"
30 #include "data/model/RegionModel.h" 30 #include "data/model/RegionModel.h"
31 #include "data/model/FFTModel.h" 31 #include "data/model/FFTModel.h"
32 #include "data/model/WaveFileModel.h" 32 #include "data/model/WaveFileModel.h"
33 #include "rdf/PluginRDFDescription.h"
33 34
34 #include "TransformFactory.h" 35 #include "TransformFactory.h"
35 36
36 #include <iostream> 37 #include <iostream>
37 38
165 .arg(pluginId) 166 .arg(pluginId)
166 .arg(m_transform.getOutput()); 167 .arg(m_transform.getOutput());
167 return; 168 return;
168 } 169 }
169 170
171 createOutputModel();
172 }
173
174 void
175 FeatureExtractionModelTransformer::createOutputModel()
176 {
177 DenseTimeValueModel *input = getConformingInput();
178
170 // std::cerr << "FeatureExtractionModelTransformer: output sample type " 179 // std::cerr << "FeatureExtractionModelTransformer: output sample type "
171 // << m_descriptor->sampleType << std::endl; 180 // << m_descriptor->sampleType << std::endl;
181
182 PluginRDFDescription description(m_transform.getPluginIdentifier());
183 QString outputId = m_transform.getOutput();
172 184
173 int binCount = 1; 185 int binCount = 1;
174 float minValue = 0.0, maxValue = 0.0; 186 float minValue = 0.0, maxValue = 0.0;
175 bool haveExtents = false; 187 bool haveExtents = false;
176 188
226 // Anything with no value and no duration is an instant 238 // Anything with no value and no duration is an instant
227 239
228 m_output = new SparseOneDimensionalModel(modelRate, modelResolution, 240 m_output = new SparseOneDimensionalModel(modelRate, modelResolution,
229 false); 241 false);
230 242
243 QString outputEventTypeURI = description.getOutputEventTypeURI(outputId);
244 m_output->setRDFTypeURI(outputEventTypeURI);
245
231 } else if ((preDurationPlugin && binCount > 1 && 246 } else if ((preDurationPlugin && binCount > 1 &&
232 (m_descriptor->sampleType == 247 (m_descriptor->sampleType ==
233 Vamp::Plugin::OutputDescriptor::VariableSampleRate)) || 248 Vamp::Plugin::OutputDescriptor::VariableSampleRate)) ||
234 (!preDurationPlugin && m_descriptor->hasDuration)) { 249 (!preDurationPlugin && m_descriptor->hasDuration)) {
235 250
292 } 307 }
293 model->setScaleUnits(m_descriptor->unit.c_str()); 308 model->setScaleUnits(m_descriptor->unit.c_str());
294 m_output = model; 309 m_output = model;
295 } 310 }
296 311
312 QString outputEventTypeURI = description.getOutputEventTypeURI(outputId);
313 m_output->setRDFTypeURI(outputEventTypeURI);
314
297 } else if (binCount == 1 || 315 } else if (binCount == 1 ||
298 (m_descriptor->sampleType == 316 (m_descriptor->sampleType ==
299 Vamp::Plugin::OutputDescriptor::VariableSampleRate)) { 317 Vamp::Plugin::OutputDescriptor::VariableSampleRate)) {
300 318
301 // Anything that is not a 1D, note, or interval model and that 319 // Anything that is not a 1D, note, or interval model and that
313 (modelRate, modelResolution, minValue, maxValue, false); 331 (modelRate, modelResolution, minValue, maxValue, false);
314 } else { 332 } else {
315 model = new SparseTimeValueModel 333 model = new SparseTimeValueModel
316 (modelRate, modelResolution, false); 334 (modelRate, modelResolution, false);
317 } 335 }
336
337 Vamp::Plugin::OutputList outputs = m_plugin->getOutputDescriptors();
318 model->setScaleUnits(outputs[m_outputFeatureNo].unit.c_str()); 338 model->setScaleUnits(outputs[m_outputFeatureNo].unit.c_str());
319 339
320 m_output = model; 340 m_output = model;
341
342 QString outputEventTypeURI = description.getOutputEventTypeURI(outputId);
343 m_output->setRDFTypeURI(outputEventTypeURI);
321 344
322 } else { 345 } else {
323 346
324 // Anything that is not a 1D, note, or interval model and that 347 // Anything that is not a 1D, note, or interval model and that
325 // has a fixed sample rate and more than one value per result 348 // has a fixed sample rate and more than one value per result
338 } 361 }
339 model->setBinNames(names); 362 model->setBinNames(names);
340 } 363 }
341 364
342 m_output = model; 365 m_output = model;
366
367 QString outputSignalTypeURI = description.getOutputSignalTypeURI(outputId);
368 m_output->setRDFTypeURI(outputSignalTypeURI);
343 } 369 }
344 370
345 if (m_output) m_output->setSourceModel(input); 371 if (m_output) m_output->setSourceModel(input);
346 } 372 }
347 373