comparison transform/FeatureExtractionModelTransformer.cpp @ 786:5295bdb58840 tonioni

fixed flexi note layer and propagated model selection to analyser
author gyorgyf
date Sat, 13 Apr 2013 13:39:17 +0100
parents 7f76499ef4f2
children 4faea021b5c1
comparison
equal deleted inserted replaced
776:cb587575bc0d 786:5295bdb58840
25 #include "data/model/SparseOneDimensionalModel.h" 25 #include "data/model/SparseOneDimensionalModel.h"
26 #include "data/model/SparseTimeValueModel.h" 26 #include "data/model/SparseTimeValueModel.h"
27 #include "data/model/EditableDenseThreeDimensionalModel.h" 27 #include "data/model/EditableDenseThreeDimensionalModel.h"
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/FlexiNoteModel.h"
30 #include "data/model/RegionModel.h" 31 #include "data/model/RegionModel.h"
31 #include "data/model/FFTModel.h" 32 #include "data/model/FFTModel.h"
32 #include "data/model/WaveFileModel.h" 33 #include "data/model/WaveFileModel.h"
33 #include "rdf/PluginRDFDescription.h" 34 #include "rdf/PluginRDFDescription.h"
34 35
35 #include "TransformFactory.h" 36 #include "TransformFactory.h"
36 37
37 #include <iostream> 38 #include <iostream>
38 39
39 FeatureExtractionModelTransformer::FeatureExtractionModelTransformer(Input in, 40 FeatureExtractionModelTransformer::FeatureExtractionModelTransformer(Input in,
40 const Transform &transform) : 41 const Transform &transform,
42 const PreferredOutputModel outputmodel) :
41 ModelTransformer(in, transform), 43 ModelTransformer(in, transform),
42 m_plugin(0), 44 m_plugin(0),
43 m_descriptor(0), 45 m_descriptor(0),
44 m_outputFeatureNo(0) 46 m_outputFeatureNo(0),
47 m_preferredOutputModel(outputmodel)
45 { 48 {
46 // SVDEBUG << "FeatureExtractionModelTransformer::FeatureExtractionModelTransformer: plugin " << pluginId << ", outputName " << m_transform.getOutput() << endl; 49 // SVDEBUG << "FeatureExtractionModelTransformer::FeatureExtractionModelTransformer: plugin " << pluginId << ", outputName " << m_transform.getOutput() << endl;
47 50
48 QString pluginId = transform.getPluginIdentifier(); 51 QString pluginId = transform.getPluginIdentifier();
49 52
284 287
285 // If we had a "sparse 3D model", we would have the additional 288 // If we had a "sparse 3D model", we would have the additional
286 // problem of determining whether to use that here (if bin 289 // problem of determining whether to use that here (if bin
287 // count > 1). But we don't. 290 // count > 1). But we don't.
288 291
289 if (isNoteModel) { 292 if (isNoteModel && m_preferredOutputModel == NoteOutputModel) {
290 293
291 NoteModel *model; 294 NoteModel *model;
295 // FlexiNoteModel *model;
292 if (haveExtents) { 296 if (haveExtents) {
293 model = new NoteModel 297 // GF: hard coding FlexiNoteModel
294 (modelRate, modelResolution, minValue, maxValue, false); 298 model = new NoteModel (modelRate, modelResolution, minValue, maxValue, false);
299 // model = new FlexiNoteModel (modelRate, modelResolution, minValue, maxValue, false);
295 } else { 300 } else {
296 model = new NoteModel 301 model = new NoteModel (modelRate, modelResolution, false);
297 (modelRate, modelResolution, false); 302 // model = new FlexiNoteModel (modelRate, modelResolution, false);
303 }
304 model->setScaleUnits(m_descriptor->unit.c_str());
305 m_output = model;
306
307 } else if (isNoteModel && m_preferredOutputModel == FlexiNoteOutputModel) {
308
309 // NoteModel *model;
310 FlexiNoteModel *model;
311 if (haveExtents) {
312 // GF: hard coding FlexiNoteModel
313 // model = new NoteModel (modelRate, modelResolution, minValue, maxValue, false);
314 model = new FlexiNoteModel (modelRate, modelResolution, minValue, maxValue, false);
315 } else {
316 // model = new NoteModel (modelRate, modelResolution, false);
317 model = new FlexiNoteModel (modelRate, modelResolution, false);
298 } 318 }
299 model->setScaleUnits(m_descriptor->unit.c_str()); 319 model->setScaleUnits(m_descriptor->unit.c_str());
300 m_output = model; 320 m_output = model;
301 321
302 } else { 322 } else {
705 } 725 }
706 726
707 model->addPoint(SparseTimeValueModel::Point(frame, value, label)); 727 model->addPoint(SparseTimeValueModel::Point(frame, value, label));
708 } 728 }
709 729
710 } else if (isOutput<NoteModel>() || isOutput<RegionModel>()) { 730 } else if (isOutput<FlexiNoteModel>() || isOutput<NoteModel>() || isOutput<RegionModel>()) { //GF: Added Note Model
711 731
712 int index = 0; 732 int index = 0;
713 733
714 float value = 0.0; 734 float value = 0.0;
715 if (feature.values.size() > index) { 735 if (feature.values.size() > index) {
722 } else { 742 } else {
723 if (feature.values.size() > index) { 743 if (feature.values.size() > index) {
724 duration = feature.values[index++]; 744 duration = feature.values[index++];
725 } 745 }
726 } 746 }
727 747
728 if (isOutput<NoteModel>()) { 748 if (isOutput<FlexiNoteModel>()) { // GF: added for flexi note model
749
750 float velocity = 100;
751 if (feature.values.size() > index) {
752 velocity = feature.values[index++];
753 }
754 if (velocity < 0) velocity = 127;
755 if (velocity > 127) velocity = 127;
756
757 FlexiNoteModel *model = getConformingOutput<FlexiNoteModel>();
758 if (!model) return;
759 model->addPoint(FlexiNoteModel::Point(frame, value, // value is pitch
760 lrintf(duration),
761 velocity / 127.f,
762 feature.label.c_str()));
763 // GF: end -- added for flexi note model
764 } else if (isOutput<NoteModel>()) {
729 765
730 float velocity = 100; 766 float velocity = 100;
731 if (feature.values.size() > index) { 767 if (feature.values.size() > index) {
732 velocity = feature.values[index++]; 768 velocity = feature.values[index++];
733 } 769 }
739 model->addPoint(NoteModel::Point(frame, value, // value is pitch 775 model->addPoint(NoteModel::Point(frame, value, // value is pitch
740 lrintf(duration), 776 lrintf(duration),
741 velocity / 127.f, 777 velocity / 127.f,
742 feature.label.c_str())); 778 feature.label.c_str()));
743 } else { 779 } else {
780
744 RegionModel *model = getConformingOutput<RegionModel>(); 781 RegionModel *model = getConformingOutput<RegionModel>();
745 if (!model) return; 782 if (!model) return;
746 783
747 if (feature.hasDuration && !feature.values.empty()) { 784 if (feature.hasDuration && !feature.values.empty()) {
748 785
811 } else if (isOutput<NoteModel>()) { 848 } else if (isOutput<NoteModel>()) {
812 849
813 NoteModel *model = getConformingOutput<NoteModel>(); 850 NoteModel *model = getConformingOutput<NoteModel>();
814 if (!model) return; 851 if (!model) return;
815 model->setCompletion(completion, true); 852 model->setCompletion(completion, true);
853
854 } else if (isOutput<FlexiNoteModel>()) {
855
856 FlexiNoteModel *model = getConformingOutput<FlexiNoteModel>();
857 if (!model) return;
858 model->setCompletion(completion, true);
816 859
817 } else if (isOutput<RegionModel>()) { 860 } else if (isOutput<RegionModel>()) {
818 861
819 RegionModel *model = getConformingOutput<RegionModel>(); 862 RegionModel *model = getConformingOutput<RegionModel>();
820 if (!model) return; 863 if (!model) return;