comparison layer/FlexiNoteLayer.cpp @ 745:d50f91fe374e tonioni

Fix (to some extent) the "gross assumption about layer order" and thus #840 Note split adaptation broken
author Chris Cannam
date Tue, 25 Mar 2014 13:06:27 +0000
parents 137d3ff48f73
children 8d5df70b5ed7
comparison
equal deleted inserted replaced
741:56ba2b03508e 745:d50f91fe374e
1284 command->addPoint(newNote); 1284 command->addPoint(newNote);
1285 finish(command); 1285 finish(command);
1286 } 1286 }
1287 } 1287 }
1288 1288
1289 SparseTimeValueModel *
1290 FlexiNoteLayer::getAssociatedPitchModel(View *v) const
1291 {
1292 // Better than we used to do, but still not very satisfactory
1293
1294 for (int i = 0; i < v->getLayerCount(); ++i) {
1295 Layer *layer = v->getLayer(i);
1296 if (layer) {
1297 SparseTimeValueModel *model = qobject_cast<SparseTimeValueModel *>
1298 (layer->getModel());
1299 if (model && model->getScaleUnits() == "Hz") {
1300 return model;
1301 }
1302 }
1303 }
1304 return 0;
1305 }
1289 1306
1290 void 1307 void
1291 FlexiNoteLayer::updateNoteValue(View *v, FlexiNoteModel::Point &note) const 1308 FlexiNoteLayer::updateNoteValue(View *v, FlexiNoteModel::Point &note) const
1292 { 1309 {
1293 //GF: update the note value conforming the median of pitch values in the underlying note layer 1310 SparseTimeValueModel *model = getAssociatedPitchModel(v);
1294 Layer *layer = v->getLayer(1); // GF: !!! gross assumption about correct layer order
1295 SparseTimeValueModel *model = 0;
1296 if (layer && layer->getModel())
1297 model = dynamic_cast<SparseTimeValueModel *>(layer->getModel());
1298
1299 if (!model) return; 1311 if (!model) return;
1300 1312
1301 std::cerr << model->getTypeName() << std::endl; 1313 std::cerr << model->getTypeName() << std::endl;
1302 1314
1303 SparseModel<TimeValuePoint>::PointList dataPoints = model->getPoints(note.frame, note.frame + note.duration); 1315 SparseModel<TimeValuePoint>::PointList dataPoints = model->getPoints(note.frame, note.frame + note.duration);