comparison transform/FeatureExtractionModelTransformer.cpp @ 454:ba7aaacb7211

* Support transforms that output regions with more than one bin (by creating more than one region) * When model displayed in the spreadsheet dialog is deleted, close the dialog in preference to crashing
author Chris Cannam
date Thu, 09 Oct 2008 13:13:33 +0000
parents 3c5252e7cefd
children 6d45f77e63ee
comparison
equal deleted inserted replaced
453:1f15beefcd76 454:ba7aaacb7211
631 model->addPoint(SparseOneDimensionalModel::Point 631 model->addPoint(SparseOneDimensionalModel::Point
632 (frame, feature.label.c_str())); 632 (frame, feature.label.c_str()));
633 633
634 } else if (isOutput<SparseTimeValueModel>()) { 634 } else if (isOutput<SparseTimeValueModel>()) {
635 635
636 float value = 0.0;
637 if (feature.values.size() > 0) value = feature.values[0];
638
639 SparseTimeValueModel *model = 636 SparseTimeValueModel *model =
640 getConformingOutput<SparseTimeValueModel>(); 637 getConformingOutput<SparseTimeValueModel>();
641 if (!model) return; 638 if (!model) return;
642 639
643 model->addPoint(SparseTimeValueModel::Point 640 for (int i = 0; i < feature.values.size(); ++i) {
644 (frame, value, feature.label.c_str())); 641
642 float value = feature.values[i];
643
644 QString label = feature.label.c_str();
645 if (feature.values.size() > 1) {
646 label = QString("[%1] %2").arg(i+1).arg(label);
647 }
648
649 model->addPoint(SparseTimeValueModel::Point(frame, value, label));
650 }
645 651
646 } else if (isOutput<NoteModel>() || isOutput<RegionModel>()) { 652 } else if (isOutput<NoteModel>() || isOutput<RegionModel>()) {
647 653
648 int index = 0; 654 int index = 0;
649 655
676 lrintf(duration), 682 lrintf(duration),
677 velocity / 127.f, 683 velocity / 127.f,
678 feature.label.c_str())); 684 feature.label.c_str()));
679 } else { 685 } else {
680 RegionModel *model = getConformingOutput<RegionModel>(); 686 RegionModel *model = getConformingOutput<RegionModel>();
681 if (model) { 687 if (!model) return;
688
689 if (feature.hasDuration) {
690
691 for (int i = 0; i < feature.values.size(); ++i) {
692
693 float value = feature.values[i];
694
695 QString label = feature.label.c_str();
696 if (feature.values.size() > 1) {
697 label = QString("[%1] %2").arg(i+1).arg(label);
698 }
699
700 model->addPoint(RegionModel::Point(frame, value,
701 lrintf(duration),
702 label));
703 }
704 } else {
705
682 model->addPoint(RegionModel::Point(frame, value, 706 model->addPoint(RegionModel::Point(frame, value,
683 lrintf(duration), 707 lrintf(duration),
684 feature.label.c_str())); 708 feature.label.c_str()));
685 } else return; 709 }
686 } 710 }
687 711
688 } else if (isOutput<EditableDenseThreeDimensionalModel>()) { 712 } else if (isOutput<EditableDenseThreeDimensionalModel>()) {
689 713
690 DenseThreeDimensionalModel::Column values = feature.values; 714 DenseThreeDimensionalModel::Column values = feature.values;