comparison data/model/AlignmentModel.cpp @ 1075:c1b522cfd1ff

More optional debug out
author Chris Cannam
date Fri, 05 Jun 2015 10:00:26 +0100
parents 0fd3661bcfff
children 48e9f538e6e9
comparison
equal deleted inserted replaced
1074:b792ea8243be 1075:c1b522cfd1ff
137 137
138 sv_frame_t 138 sv_frame_t
139 AlignmentModel::toReference(sv_frame_t frame) const 139 AlignmentModel::toReference(sv_frame_t frame) const
140 { 140 {
141 #ifdef DEBUG_ALIGNMENT_MODEL 141 #ifdef DEBUG_ALIGNMENT_MODEL
142 SVDEBUG << "AlignmentModel::toReference(" << frame << ")" << endl; 142 cerr << "AlignmentModel::toReference(" << frame << ")" << endl;
143 #endif 143 #endif
144 if (!m_path) { 144 if (!m_path) {
145 if (!m_rawPath) return frame; 145 if (!m_rawPath) return frame;
146 constructPath(); 146 constructPath();
147 } 147 }
150 150
151 sv_frame_t 151 sv_frame_t
152 AlignmentModel::fromReference(sv_frame_t frame) const 152 AlignmentModel::fromReference(sv_frame_t frame) const
153 { 153 {
154 #ifdef DEBUG_ALIGNMENT_MODEL 154 #ifdef DEBUG_ALIGNMENT_MODEL
155 SVDEBUG << "AlignmentModel::fromReference(" << frame << ")" << endl; 155 cerr << "AlignmentModel::fromReference(" << frame << ")" << endl;
156 #endif 156 #endif
157 if (!m_reversePath) { 157 if (!m_reversePath) {
158 if (!m_rawPath) return frame; 158 if (!m_rawPath) return frame;
159 constructReversePath(); 159 constructReversePath();
160 } 160 }
190 190
191 int completion = 0; 191 int completion = 0;
192 m_rawPath->isReady(&completion); 192 m_rawPath->isReady(&completion);
193 193
194 #ifdef DEBUG_ALIGNMENT_MODEL 194 #ifdef DEBUG_ALIGNMENT_MODEL
195 SVDEBUG << "AlignmentModel::pathCompletionChanged: completion = " 195 cerr << "AlignmentModel::pathCompletionChanged: completion = "
196 << completion << endl; 196 << completion << endl;
197 #endif 197 #endif
198 198
199 m_pathComplete = (completion == 100); 199 m_pathComplete = (completion == 100);
200 200
238 sv_frame_t rframe = lrint(value * m_aligned->getSampleRate()); 238 sv_frame_t rframe = lrint(value * m_aligned->getSampleRate());
239 m_path->addPoint(PathPoint(frame, rframe)); 239 m_path->addPoint(PathPoint(frame, rframe));
240 } 240 }
241 241
242 #ifdef DEBUG_ALIGNMENT_MODEL 242 #ifdef DEBUG_ALIGNMENT_MODEL
243 SVDEBUG << "AlignmentModel::constructPath: " << m_path->getPointCount() << " points, at least " << (2 * m_path->getPointCount() * (3 * sizeof(void *) + sizeof(int) + sizeof(PathPoint))) << " bytes" << endl; 243 cerr << "AlignmentModel::constructPath: " << m_path->getPointCount() << " points, at least " << (2 * m_path->getPointCount() * (3 * sizeof(void *) + sizeof(int) + sizeof(PathPoint))) << " bytes" << endl;
244 #endif 244 #endif
245 } 245 }
246 246
247 void 247 void
248 AlignmentModel::constructReversePath() const 248 AlignmentModel::constructReversePath() const
269 sv_frame_t rframe = i->mapframe; 269 sv_frame_t rframe = i->mapframe;
270 m_reversePath->addPoint(PathPoint(rframe, frame)); 270 m_reversePath->addPoint(PathPoint(rframe, frame));
271 } 271 }
272 272
273 #ifdef DEBUG_ALIGNMENT_MODEL 273 #ifdef DEBUG_ALIGNMENT_MODEL
274 SVDEBUG << "AlignmentModel::constructReversePath: " << m_reversePath->getPointCount() << " points, at least " << (2 * m_reversePath->getPointCount() * (3 * sizeof(void *) + sizeof(int) + sizeof(PathPoint))) << " bytes" << endl; 274 cerr << "AlignmentModel::constructReversePath: " << m_reversePath->getPointCount() << " points, at least " << (2 * m_reversePath->getPointCount() * (3 * sizeof(void *) + sizeof(int) + sizeof(PathPoint))) << " bytes" << endl;
275 #endif 275 #endif
276 } 276 }
277 277
278 sv_frame_t 278 sv_frame_t
279 AlignmentModel::align(PathModel *path, sv_frame_t frame) const 279 AlignmentModel::align(PathModel *path, sv_frame_t frame) const
287 287
288 const PathModel::PointList &points = path->getPoints(); 288 const PathModel::PointList &points = path->getPoints();
289 289
290 if (points.empty()) { 290 if (points.empty()) {
291 #ifdef DEBUG_ALIGNMENT_MODEL 291 #ifdef DEBUG_ALIGNMENT_MODEL
292 SVDEBUG << "AlignmentModel::align: No points" << endl; 292 cerr << "AlignmentModel::align: No points" << endl;
293 #endif 293 #endif
294 return frame; 294 return frame;
295 } 295 }
296 296
297 #ifdef DEBUG_ALIGNMENT_MODEL 297 #ifdef DEBUG_ALIGNMENT_MODEL
298 SVDEBUG << "AlignmentModel::align: frame " << frame << " requested" << endl; 298 cerr << "AlignmentModel::align: frame " << frame << " requested" << endl;
299 #endif 299 #endif
300 300
301 PathModel::Point point(frame); 301 PathModel::Point point(frame);
302 PathModel::PointList::const_iterator i = points.lower_bound(point); 302 PathModel::PointList::const_iterator i = points.lower_bound(point);
303 if (i == points.end()) { 303 if (i == points.end()) {
324 #ifdef DEBUG_ALIGNMENT_MODEL 324 #ifdef DEBUG_ALIGNMENT_MODEL
325 cerr << "no other point available" << endl; 325 cerr << "no other point available" << endl;
326 #endif 326 #endif
327 } 327 }
328 328
329 #ifdef DEBUG_ALIGNMENT_MODEL
330 cerr << "foundFrame = " << foundFrame << ", foundMapFrame = " << foundMapFrame
331 << ", followingFrame = " << followingFrame << ", followingMapFrame = "
332 << followingMapFrame << endl;
333 #endif
334
329 if (foundMapFrame < 0) return 0; 335 if (foundMapFrame < 0) return 0;
330 336
331 sv_frame_t resultFrame = foundMapFrame; 337 sv_frame_t resultFrame = foundMapFrame;
332 338
333 if (followingFrame != foundFrame && frame > foundFrame) { 339 if (followingFrame != foundFrame && frame > foundFrame) {
336 double(followingFrame - foundFrame); 342 double(followingFrame - foundFrame);
337 resultFrame += lrint(double(followingMapFrame - foundMapFrame) * interp); 343 resultFrame += lrint(double(followingMapFrame - foundMapFrame) * interp);
338 } 344 }
339 345
340 #ifdef DEBUG_ALIGNMENT_MODEL 346 #ifdef DEBUG_ALIGNMENT_MODEL
341 SVDEBUG << "AlignmentModel::align: resultFrame = " << resultFrame << endl; 347 cerr << "AlignmentModel::align: resultFrame = " << resultFrame << endl;
342 #endif 348 #endif
343 349
344 return resultFrame; 350 return resultFrame;
345 } 351 }
346 352
374 { 380 {
375 if (m_path) m_path->aboutToDelete(); 381 if (m_path) m_path->aboutToDelete();
376 delete m_path; 382 delete m_path;
377 m_path = path; 383 m_path = path;
378 #ifdef DEBUG_ALIGNMENT_MODEL 384 #ifdef DEBUG_ALIGNMENT_MODEL
379 SVDEBUG << "AlignmentModel::setPath: path = " << m_path << endl; 385 cerr << "AlignmentModel::setPath: path = " << m_path << endl;
380 #endif 386 #endif
381 constructReversePath(); 387 constructReversePath();
382 #ifdef DEBUG_ALIGNMENT_MODEL 388 #ifdef DEBUG_ALIGNMENT_MODEL
383 SVDEBUG << "AlignmentModel::setPath: after construction path = " 389 cerr << "AlignmentModel::setPath: after construction path = "
384 << m_path << ", rpath = " << m_reversePath << endl; 390 << m_path << ", rpath = " << m_reversePath << endl;
385 #endif 391 #endif
386 } 392 }
387 393
388 void 394 void