Mercurial > hg > svapp
comparison framework/MainWindowBase.cpp @ 708:721eb532840d
Fix to avoid ffwd/rwd getting stuck at a single point if it translates to the playback frame again on alignment
author | Chris Cannam |
---|---|
date | Mon, 16 Sep 2019 13:28:40 +0100 |
parents | b5000a78249a |
children | 8e9702c0b9c7 |
comparison
equal
deleted
inserted
replaced
707:94ca0ade69b6 | 708:721eb532840d |
---|---|
3348 void | 3348 void |
3349 MainWindowBase::ffwd() | 3349 MainWindowBase::ffwd() |
3350 { | 3350 { |
3351 if (!getMainModel()) return; | 3351 if (!getMainModel()) return; |
3352 | 3352 |
3353 sv_frame_t frame = m_viewManager->getPlaybackFrame(); | 3353 sv_frame_t playbackFrame = m_viewManager->getPlaybackFrame(); |
3354 ++frame; | 3354 sv_frame_t frame = playbackFrame + 1; |
3355 | 3355 |
3356 Pane *pane = m_paneStack->getCurrentPane(); | 3356 Pane *pane = m_paneStack->getCurrentPane(); |
3357 Layer *layer = getSnapLayer(); | 3357 Layer *layer = getSnapLayer(); |
3358 sv_samplerate_t sr = getMainModel()->getSampleRate(); | 3358 sv_samplerate_t sr = getMainModel()->getSampleRate(); |
3359 | 3359 |
3360 if (!layer) { | 3360 if (!pane || !layer) { |
3361 | 3361 |
3362 frame = RealTime::realTime2Frame | 3362 frame = RealTime::realTime2Frame |
3363 (RealTime::frame2RealTime(frame, sr) + m_defaultFfwdRwdStep, sr); | 3363 (RealTime::frame2RealTime(frame, sr) + m_defaultFfwdRwdStep, sr); |
3364 if (frame > getMainModel()->getEndFrame()) { | 3364 if (frame > getMainModel()->getEndFrame()) { |
3365 frame = getMainModel()->getEndFrame(); | 3365 frame = getMainModel()->getEndFrame(); |
3366 } | 3366 } |
3367 | 3367 |
3368 } else { | 3368 } else { |
3369 | 3369 |
3370 sv_frame_t pframe = pane->alignFromReference(frame); | |
3370 int resolution = 0; | 3371 int resolution = 0; |
3371 if (pane) frame = pane->alignFromReference(frame); | 3372 bool success = false; |
3372 if (layer->snapToFeatureFrame(m_paneStack->getCurrentPane(), | 3373 |
3373 frame, resolution, Layer::SnapRight)) { | 3374 while (layer->snapToFeatureFrame(pane, pframe, resolution, |
3374 if (pane) frame = pane->alignToReference(frame); | 3375 Layer::SnapRight)) { |
3376 if (pane->alignToReference(pframe) > playbackFrame) { | |
3377 success = true; | |
3378 break; | |
3379 } else { | |
3380 ++pframe; | |
3381 } | |
3382 } | |
3383 | |
3384 if (success) { | |
3385 frame = pane->alignToReference(pframe); | |
3375 } else { | 3386 } else { |
3376 frame = getMainModel()->getEndFrame(); | 3387 frame = getMainModel()->getEndFrame(); |
3377 } | 3388 } |
3378 } | 3389 } |
3379 | 3390 |
3383 frame = m_viewManager->constrainFrameToSelection(frame); | 3394 frame = m_viewManager->constrainFrameToSelection(frame); |
3384 } | 3395 } |
3385 | 3396 |
3386 m_viewManager->setPlaybackFrame(frame); | 3397 m_viewManager->setPlaybackFrame(frame); |
3387 | 3398 |
3388 if (frame == getMainModel()->getEndFrame() && | 3399 if (frame >= getMainModel()->getEndFrame() && |
3389 m_playSource && | 3400 m_playSource && |
3390 m_playSource->isPlaying() && | 3401 m_playSource->isPlaying() && |
3391 !m_viewManager->getPlayLoopMode()) { | 3402 !m_viewManager->getPlayLoopMode()) { |
3392 stop(); | 3403 stop(); |
3393 } | 3404 } |
3452 void | 3463 void |
3453 MainWindowBase::rewind() | 3464 MainWindowBase::rewind() |
3454 { | 3465 { |
3455 if (!getMainModel()) return; | 3466 if (!getMainModel()) return; |
3456 | 3467 |
3457 sv_frame_t frame = m_viewManager->getPlaybackFrame(); | 3468 sv_frame_t playbackFrame = m_viewManager->getPlaybackFrame(); |
3469 sv_frame_t frame = playbackFrame; | |
3458 if (frame > 0) --frame; | 3470 if (frame > 0) --frame; |
3459 | 3471 |
3460 Pane *pane = m_paneStack->getCurrentPane(); | 3472 Pane *pane = m_paneStack->getCurrentPane(); |
3461 Layer *layer = getSnapLayer(); | 3473 Layer *layer = getSnapLayer(); |
3462 sv_samplerate_t sr = getMainModel()->getSampleRate(); | 3474 sv_samplerate_t sr = getMainModel()->getSampleRate(); |
3469 ct = ct - RealTime::fromSeconds(0.15); | 3481 ct = ct - RealTime::fromSeconds(0.15); |
3470 if (ct < RealTime::zeroTime) ct = RealTime::zeroTime; | 3482 if (ct < RealTime::zeroTime) ct = RealTime::zeroTime; |
3471 frame = RealTime::realTime2Frame(ct, sr); | 3483 frame = RealTime::realTime2Frame(ct, sr); |
3472 } | 3484 } |
3473 | 3485 |
3474 if (!layer) { | 3486 if (!pane || !layer) { |
3475 | 3487 |
3476 frame = RealTime::realTime2Frame | 3488 frame = RealTime::realTime2Frame |
3477 (RealTime::frame2RealTime(frame, sr) - m_defaultFfwdRwdStep, sr); | 3489 (RealTime::frame2RealTime(frame, sr) - m_defaultFfwdRwdStep, sr); |
3478 if (frame < getMainModel()->getStartFrame()) { | 3490 if (frame < getMainModel()->getStartFrame()) { |
3479 frame = getMainModel()->getStartFrame(); | 3491 frame = getMainModel()->getStartFrame(); |
3480 } | 3492 } |
3481 | 3493 |
3482 } else { | 3494 } else { |
3483 | 3495 |
3496 sv_frame_t pframe = pane->alignFromReference(frame); | |
3484 int resolution = 0; | 3497 int resolution = 0; |
3485 if (pane) frame = pane->alignFromReference(frame); | 3498 bool success = false; |
3486 if (layer->snapToFeatureFrame(m_paneStack->getCurrentPane(), | 3499 |
3487 frame, resolution, Layer::SnapLeft)) { | 3500 while (layer->snapToFeatureFrame(pane, pframe, resolution, |
3488 if (pane) frame = pane->alignToReference(frame); | 3501 Layer::SnapLeft)) { |
3502 if (pane->alignToReference(pframe) < playbackFrame || | |
3503 pframe <= 0) { | |
3504 success = true; | |
3505 break; | |
3506 } else { | |
3507 --pframe; | |
3508 } | |
3509 } | |
3510 | |
3511 if (success) { | |
3512 frame = pane->alignToReference(pframe); | |
3489 } else { | 3513 } else { |
3490 frame = getMainModel()->getStartFrame(); | 3514 frame = getMainModel()->getStartFrame(); |
3491 } | 3515 } |
3492 } | 3516 } |
3493 | 3517 |