Mercurial > hg > svgui
comparison view/ViewManager.cpp @ 1266:a34a2a25907c
Untabify
author | Chris Cannam |
---|---|
date | Thu, 01 Mar 2018 18:02:22 +0000 |
parents | d25f1f99c6fa |
children | 61418c112281 |
comparison
equal
deleted
inserted
replaced
1265:6e724c81f18f | 1266:a34a2a25907c |
---|---|
163 m_playbackFrame = m_recordTarget->getRecordDuration(); | 163 m_playbackFrame = m_recordTarget->getRecordDuration(); |
164 #ifdef DEBUG_VIEW_MANAGER | 164 #ifdef DEBUG_VIEW_MANAGER |
165 cout << "ViewManager::getPlaybackFrame(recording) -> " << m_playbackFrame << endl; | 165 cout << "ViewManager::getPlaybackFrame(recording) -> " << m_playbackFrame << endl; |
166 #endif | 166 #endif |
167 } else if (isPlaying()) { | 167 } else if (isPlaying()) { |
168 m_playbackFrame = m_playSource->getCurrentPlayingFrame(); | 168 m_playbackFrame = m_playSource->getCurrentPlayingFrame(); |
169 #ifdef DEBUG_VIEW_MANAGER | 169 #ifdef DEBUG_VIEW_MANAGER |
170 cout << "ViewManager::getPlaybackFrame(playing) -> " << m_playbackFrame << endl; | 170 cout << "ViewManager::getPlaybackFrame(playing) -> " << m_playbackFrame << endl; |
171 #endif | 171 #endif |
172 } else { | 172 } else { |
173 #ifdef DEBUG_VIEW_MANAGER | 173 #ifdef DEBUG_VIEW_MANAGER |
183 #ifdef DEBUG_VIEW_MANAGER | 183 #ifdef DEBUG_VIEW_MANAGER |
184 cerr << "ViewManager::setPlaybackFrame(" << f << ")" << endl; | 184 cerr << "ViewManager::setPlaybackFrame(" << f << ")" << endl; |
185 #endif | 185 #endif |
186 if (f < 0) f = 0; | 186 if (f < 0) f = 0; |
187 if (m_playbackFrame != f) { | 187 if (m_playbackFrame != f) { |
188 m_playbackFrame = f; | 188 m_playbackFrame = f; |
189 emit playbackFrameChanged(f); | 189 emit playbackFrameChanged(f); |
190 if (isPlaying()) { | 190 if (isPlaying()) { |
191 m_playSource->play(f); | 191 m_playSource->play(f); |
192 } | 192 } |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 Model * | 196 Model * |
197 ViewManager::getPlaybackModel() const | 197 ViewManager::getPlaybackModel() const |
357 { | 357 { |
358 emit selectionChanged(); | 358 emit selectionChanged(); |
359 } | 359 } |
360 | 360 |
361 ViewManager::SetSelectionCommand::SetSelectionCommand(ViewManager *vm, | 361 ViewManager::SetSelectionCommand::SetSelectionCommand(ViewManager *vm, |
362 const MultiSelection &ms) : | 362 const MultiSelection &ms) : |
363 m_vm(vm), | 363 m_vm(vm), |
364 m_oldSelection(vm->m_selections), | 364 m_oldSelection(vm->m_selections), |
365 m_newSelection(ms) | 365 m_newSelection(ms) |
366 { | 366 { |
367 } | 367 } |
507 | 507 |
508 sv_samplerate_t | 508 sv_samplerate_t |
509 ViewManager::getDeviceSampleRate() const | 509 ViewManager::getDeviceSampleRate() const |
510 { | 510 { |
511 if (m_playSource) { | 511 if (m_playSource) { |
512 return m_playSource->getDeviceSampleRate(); | 512 return m_playSource->getDeviceSampleRate(); |
513 } | 513 } |
514 return 0; | 514 return 0; |
515 } | 515 } |
516 | 516 |
517 void | 517 void |
518 ViewManager::setAudioPlaySource(AudioPlaySource *source) | 518 ViewManager::setAudioPlaySource(AudioPlaySource *source) |
519 { | 519 { |
520 if (!m_playSource) { | 520 if (!m_playSource) { |
521 QTimer::singleShot(100, this, SLOT(checkPlayStatus())); | 521 QTimer::singleShot(100, this, SLOT(checkPlayStatus())); |
522 } | 522 } |
523 m_playSource = source; | 523 m_playSource = source; |
524 } | 524 } |
525 | 525 |
526 void | 526 void |
527 ViewManager::setAudioRecordTarget(AudioRecordTarget *target) | 527 ViewManager::setAudioRecordTarget(AudioRecordTarget *target) |
528 { | 528 { |
529 if (!m_recordTarget) { | 529 if (!m_recordTarget) { |
530 QTimer::singleShot(100, this, SLOT(checkPlayStatus())); | 530 QTimer::singleShot(100, this, SLOT(checkPlayStatus())); |
531 } | 531 } |
532 m_recordTarget = target; | 532 m_recordTarget = target; |
533 } | 533 } |
534 | 534 |
535 void | 535 void |
553 void | 553 void |
554 ViewManager::checkPlayStatus() | 554 ViewManager::checkPlayStatus() |
555 { | 555 { |
556 if (isRecording()) { | 556 if (isRecording()) { |
557 | 557 |
558 float left = 0, right = 0; | 558 float left = 0, right = 0; |
559 if (m_recordTarget->getInputLevels(left, right)) { | 559 if (m_recordTarget->getInputLevels(left, right)) { |
560 if (left != m_lastLeft || right != m_lastRight) { | 560 if (left != m_lastLeft || right != m_lastRight) { |
561 emit monitoringLevelsChanged(left, right); | 561 emit monitoringLevelsChanged(left, right); |
562 m_lastLeft = left; | 562 m_lastLeft = left; |
563 m_lastRight = right; | 563 m_lastRight = right; |
564 } | 564 } |
565 } | 565 } |
566 | 566 |
567 m_playbackFrame = m_recordTarget->getRecordDuration(); | 567 m_playbackFrame = m_recordTarget->getRecordDuration(); |
568 | 568 |
569 #ifdef DEBUG_VIEW_MANAGER | 569 #ifdef DEBUG_VIEW_MANAGER |
570 cerr << "ViewManager::checkPlayStatus: Recording, frame " << m_playbackFrame << ", levels " << m_lastLeft << "," << m_lastRight << endl; | 570 cerr << "ViewManager::checkPlayStatus: Recording, frame " << m_playbackFrame << ", levels " << m_lastLeft << "," << m_lastRight << endl; |
571 #endif | 571 #endif |
572 | 572 |
573 emit playbackFrameChanged(m_playbackFrame); | 573 emit playbackFrameChanged(m_playbackFrame); |
574 | 574 |
575 QTimer::singleShot(500, this, SLOT(checkPlayStatus())); | 575 QTimer::singleShot(500, this, SLOT(checkPlayStatus())); |
576 | 576 |
577 } else if (isPlaying()) { | 577 } else if (isPlaying()) { |
578 | 578 |
579 float left = 0, right = 0; | 579 float left = 0, right = 0; |
580 if (m_playSource->getOutputLevels(left, right)) { | 580 if (m_playSource->getOutputLevels(left, right)) { |
581 if (left != m_lastLeft || right != m_lastRight) { | 581 if (left != m_lastLeft || right != m_lastRight) { |
582 emit monitoringLevelsChanged(left, right); | 582 emit monitoringLevelsChanged(left, right); |
583 m_lastLeft = left; | 583 m_lastLeft = left; |
584 m_lastRight = right; | 584 m_lastRight = right; |
585 } | 585 } |
586 } | 586 } |
587 | 587 |
588 m_playbackFrame = m_playSource->getCurrentPlayingFrame(); | 588 m_playbackFrame = m_playSource->getCurrentPlayingFrame(); |
589 | 589 |
590 #ifdef DEBUG_VIEW_MANAGER | 590 #ifdef DEBUG_VIEW_MANAGER |
591 cerr << "ViewManager::checkPlayStatus: Playing, frame " << m_playbackFrame << ", levels " << m_lastLeft << "," << m_lastRight << endl; | 591 cerr << "ViewManager::checkPlayStatus: Playing, frame " << m_playbackFrame << ", levels " << m_lastLeft << "," << m_lastRight << endl; |
592 #endif | 592 #endif |
593 | 593 |
594 emit playbackFrameChanged(m_playbackFrame); | 594 emit playbackFrameChanged(m_playbackFrame); |
595 | 595 |
596 QTimer::singleShot(20, this, SLOT(checkPlayStatus())); | 596 QTimer::singleShot(20, this, SLOT(checkPlayStatus())); |
597 | 597 |
598 } else { | 598 } else { |
599 | 599 |
600 if (m_lastLeft != 0.0 || m_lastRight != 0.0) { | 600 if (m_lastLeft != 0.0 || m_lastRight != 0.0) { |
601 emit monitoringLevelsChanged(0.0, 0.0); | 601 emit monitoringLevelsChanged(0.0, 0.0); |
602 m_lastLeft = 0.0; | 602 m_lastLeft = 0.0; |
603 m_lastRight = 0.0; | 603 m_lastRight = 0.0; |
604 } | 604 } |
605 | 605 |
606 #ifdef DEBUG_VIEW_MANAGER | 606 #ifdef DEBUG_VIEW_MANAGER |
607 cerr << "ViewManager::checkPlayStatus: Not playing or recording" << endl; | 607 cerr << "ViewManager::checkPlayStatus: Not playing or recording" << endl; |
608 #endif | 608 #endif |
609 } | 609 } |
610 } | 610 } |
611 | 611 |
612 bool | 612 bool |
666 #endif | 666 #endif |
667 return; | 667 return; |
668 } | 668 } |
669 | 669 |
670 if (isPlaying()) { | 670 if (isPlaying()) { |
671 sv_frame_t playFrame = m_playSource->getCurrentPlayingFrame(); | 671 sv_frame_t playFrame = m_playSource->getCurrentPlayingFrame(); |
672 sv_frame_t diff = std::max(f, playFrame) - std::min(f, playFrame); | 672 sv_frame_t diff = std::max(f, playFrame) - std::min(f, playFrame); |
673 if (diff > 20000) { | 673 if (diff > 20000) { |
674 m_playbackFrame = f; | 674 m_playbackFrame = f; |
675 m_playSource->play(f); | 675 m_playSource->play(f); |
676 #ifdef DEBUG_VIEW_MANAGER | 676 #ifdef DEBUG_VIEW_MANAGER |
677 cerr << "ViewManager::seek: reseeking from " << playFrame << " to " << f << endl; | 677 cerr << "ViewManager::seek: reseeking from " << playFrame << " to " << f << endl; |
678 #endif | 678 #endif |
679 emit playbackFrameChanged(f); | 679 emit playbackFrameChanged(f); |
680 } | 680 } |
681 } else { | 681 } else { |
682 if (m_playbackFrame != f) { | 682 if (m_playbackFrame != f) { |
683 m_playbackFrame = f; | 683 m_playbackFrame = f; |
684 emit playbackFrameChanged(f); | 684 emit playbackFrameChanged(f); |
685 } | 685 } |
697 } | 697 } |
698 | 698 |
699 //!!! emit zoomLevelChanged(); | 699 //!!! emit zoomLevelChanged(); |
700 | 700 |
701 if (locked) { | 701 if (locked) { |
702 m_globalZoom = z; | 702 m_globalZoom = z; |
703 } | 703 } |
704 | 704 |
705 #ifdef DEBUG_VIEW_MANAGER | 705 #ifdef DEBUG_VIEW_MANAGER |
706 cerr << "ViewManager::viewZoomLevelChanged(" << v << ", " << z << ", " << locked << ")" << endl; | 706 cerr << "ViewManager::viewZoomLevelChanged(" << v << ", " << z << ", " << locked << ")" << endl; |
707 #endif | 707 #endif |