Mercurial > hg > svcore
comparison transform/FeatureExtractionModelTransformer.cpp @ 1647:29a20719796e single-point
Rework NoteModel commands (not entirely successfully); remove FlexiNoteModel as it has always been almost entirely identical to NoteModel (unlike its layer counterpart)
author | Chris Cannam |
---|---|
date | Thu, 14 Mar 2019 15:31:59 +0000 |
parents | 513192aa9b03 |
children | 1cc9a0d4b1b6 |
comparison
equal
deleted
inserted
replaced
1646:b429750e64a8 | 1647:29a20719796e |
---|---|
26 #include "data/model/SparseOneDimensionalModel.h" | 26 #include "data/model/SparseOneDimensionalModel.h" |
27 #include "data/model/SparseTimeValueModel.h" | 27 #include "data/model/SparseTimeValueModel.h" |
28 #include "data/model/EditableDenseThreeDimensionalModel.h" | 28 #include "data/model/EditableDenseThreeDimensionalModel.h" |
29 #include "data/model/DenseTimeValueModel.h" | 29 #include "data/model/DenseTimeValueModel.h" |
30 #include "data/model/NoteModel.h" | 30 #include "data/model/NoteModel.h" |
31 #include "data/model/FlexiNoteModel.h" | |
32 #include "data/model/RegionModel.h" | 31 #include "data/model/RegionModel.h" |
33 #include "data/model/FFTModel.h" | 32 #include "data/model/FFTModel.h" |
34 #include "data/model/WaveFileModel.h" | 33 #include "data/model/WaveFileModel.h" |
35 #include "rdf/PluginRDFDescription.h" | 34 #include "rdf/PluginRDFDescription.h" |
36 | 35 |
408 // If we had a "sparse 3D model", we would have the additional | 407 // If we had a "sparse 3D model", we would have the additional |
409 // problem of determining whether to use that here (if bin | 408 // problem of determining whether to use that here (if bin |
410 // count > 1). But we don't. | 409 // count > 1). But we don't. |
411 | 410 |
412 QSettings settings; | 411 QSettings settings; |
413 settings.beginGroup("Transformer"); | 412 |
414 bool flexi = settings.value("use-flexi-note-model", false).toBool(); | 413 if (isNoteModel) { |
415 settings.endGroup(); | |
416 | |
417 cerr << "flexi = " << flexi << endl; | |
418 | |
419 if (isNoteModel && !flexi) { | |
420 | 414 |
421 NoteModel *model; | 415 NoteModel *model; |
422 if (haveExtents) { | 416 if (haveExtents) { |
423 model = new NoteModel | 417 model = new NoteModel |
424 (modelRate, modelResolution, minValue, maxValue, false); | 418 (modelRate, modelResolution, minValue, maxValue, false); |
425 } else { | 419 } else { |
426 model = new NoteModel | 420 model = new NoteModel |
427 (modelRate, modelResolution, false); | |
428 } | |
429 model->setScaleUnits(m_descriptors[n]->unit.c_str()); | |
430 out = model; | |
431 | |
432 } else if (isNoteModel && flexi) { | |
433 | |
434 FlexiNoteModel *model; | |
435 if (haveExtents) { | |
436 model = new FlexiNoteModel | |
437 (modelRate, modelResolution, minValue, maxValue, false); | |
438 } else { | |
439 model = new FlexiNoteModel | |
440 (modelRate, modelResolution, false); | 421 (modelRate, modelResolution, false); |
441 } | 422 } |
442 model->setScaleUnits(m_descriptors[n]->unit.c_str()); | 423 model->setScaleUnits(m_descriptors[n]->unit.c_str()); |
443 out = model; | 424 out = model; |
444 | 425 |
1025 | 1006 |
1026 targetModel->addPoint | 1007 targetModel->addPoint |
1027 (SparseTimeValueModel::Point(frame, value, label)); | 1008 (SparseTimeValueModel::Point(frame, value, label)); |
1028 } | 1009 } |
1029 | 1010 |
1030 } else if (isOutput<FlexiNoteModel>(n) || isOutput<NoteModel>(n) || isOutput<RegionModel>(n)) { //GF: Added Note Model | 1011 } else if (isOutput<NoteModel>(n) || isOutput<RegionModel>(n)) { |
1031 | 1012 |
1032 int index = 0; | 1013 int index = 0; |
1033 | 1014 |
1034 float value = 0.0; | 1015 float value = 0.0; |
1035 if ((int)feature.values.size() > index) { | 1016 if ((int)feature.values.size() > index) { |
1043 if (in_range_for(feature.values, index)) { | 1024 if (in_range_for(feature.values, index)) { |
1044 duration = lrintf(feature.values[index++]); | 1025 duration = lrintf(feature.values[index++]); |
1045 } | 1026 } |
1046 } | 1027 } |
1047 | 1028 |
1048 if (isOutput<FlexiNoteModel>(n)) { // GF: added for flexi note model | 1029 if (isOutput<NoteModel>(n)) { |
1049 | |
1050 float velocity = 100; | |
1051 if ((int)feature.values.size() > index) { | |
1052 velocity = feature.values[index++]; | |
1053 } | |
1054 if (velocity < 0) velocity = 127; | |
1055 if (velocity > 127) velocity = 127; | |
1056 | |
1057 FlexiNoteModel *model = getConformingOutput<FlexiNoteModel>(n); | |
1058 if (!model) return; | |
1059 model->addPoint(FlexiNoteModel::Point(frame, | |
1060 value, // value is pitch | |
1061 duration, | |
1062 velocity / 127.f, | |
1063 feature.label.c_str())); | |
1064 // GF: end -- added for flexi note model | |
1065 } else if (isOutput<NoteModel>(n)) { | |
1066 | 1030 |
1067 float velocity = 100; | 1031 float velocity = 100; |
1068 if ((int)feature.values.size() > index) { | 1032 if ((int)feature.values.size() > index) { |
1069 velocity = feature.values[index++]; | 1033 velocity = feature.values[index++]; |
1070 } | 1034 } |
1158 NoteModel *model = getConformingOutput<NoteModel>(n); | 1122 NoteModel *model = getConformingOutput<NoteModel>(n); |
1159 if (!model) return; | 1123 if (!model) return; |
1160 if (model->isAbandoning()) abandon(); | 1124 if (model->isAbandoning()) abandon(); |
1161 model->setCompletion(completion, true); | 1125 model->setCompletion(completion, true); |
1162 | 1126 |
1163 } else if (isOutput<FlexiNoteModel>(n)) { | |
1164 | |
1165 FlexiNoteModel *model = getConformingOutput<FlexiNoteModel>(n); | |
1166 if (!model) return; | |
1167 if (model->isAbandoning()) abandon(); | |
1168 model->setCompletion(completion, true); | |
1169 | |
1170 } else if (isOutput<RegionModel>(n)) { | 1127 } else if (isOutput<RegionModel>(n)) { |
1171 | 1128 |
1172 RegionModel *model = getConformingOutput<RegionModel>(n); | 1129 RegionModel *model = getConformingOutput<RegionModel>(n); |
1173 if (!model) return; | 1130 if (!model) return; |
1174 if (model->isAbandoning()) abandon(); | 1131 if (model->isAbandoning()) abandon(); |