Audacity 3.2.0
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
Scrubber Class Referencefinal

#include <Scrubbing.h>

Inheritance diagram for Scrubber:
[legend]
Collaboration diagram for Scrubber:
[legend]

Classes

class  ScrubPoller
 

Public Member Functions

 Scrubber (AudacityProject *project)
 
 Scrubber (const Scrubber &)=delete
 
Scrubberoperator= (const Scrubber &)=delete
 
 ~Scrubber ()
 
void MarkScrubStart (wxCoord xx, bool smoothScrolling, bool seek)
 
bool MaybeStartScrubbing (wxCoord xx)
 
bool StartKeyboardScrubbing (double time0, bool backwards)
 
double GetKeyboardScrubbingSpeed ()
 
void ContinueScrubbingUI ()
 
void ContinueScrubbingPoll ()
 
void StopScrubbing ()
 
wxCoord GetScrubStartPosition () const
 
bool WasSpeedPlaying () const
 
bool IsSpeedPlaying () const
 
bool WasKeyboardScrubbing () const
 
bool IsKeyboardScrubbing () const
 
void SetBackwards (bool backwards)
 
bool IsBackwards () const
 
bool HasMark () const
 
bool IsScrubbing () const
 
bool IsScrollScrubbing () const
 
void SetScrollScrubbing (bool value)
 
bool ChoseSeeking () const
 
void SetMayDragToSeek (bool value)
 
bool MayDragToSeek () const
 
bool TemporarilySeeks () const
 
bool Seeks () const
 
bool Scrubs () const
 
bool ShowsBar () const
 
void Cancel ()
 
bool ShouldDrawScrubSpeed ()
 
double FindScrubSpeed (bool seeking, double time) const
 
double GetMaxScrubSpeed () const
 
void HandleScrollWheel (int steps)
 
bool CanScrub () const
 
void PopulatePopupMenu (wxMenu &menu)
 
void OnScrubOrSeek (bool seek)
 
void OnScrub (const CommandContext &)
 
void OnSeek (const CommandContext &)
 
void OnToggleScrubRuler (const CommandContext &)
 
void OnKeyboardScrubBackwards (const CommandContext &)
 
void OnKeyboardScrubForwards (const CommandContext &)
 
void DoKeyboardScrub (bool backwards, bool keyUp)
 
template<void(Scrubber::*)(const CommandContext &) pfn>
void Thunk (wxCommandEvent &)
 
const TranslatableStringGetUntranslatedStateString () const
 
wxString StatusMessageForWave () const
 
void Pause (bool paused)
 
bool IsPaused () const
 
void CheckMenuItems ()
 
bool IsTransportingPinned () const
 
void SetSeekPress (bool value)
 
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()
 

Static Public Member Functions

static ScrubberGet (AudacityProject &project)
 
static const ScrubberGet (const AudacityProject &project)
 
static bool ShouldScrubPinned ()
 

Private Member Functions

void UpdatePrefs () override
 
void StartPolling ()
 
void StopPolling ()
 
void DoScrub (bool seek)
 
void OnActivateOrDeactivateApp (wxActivateEvent &event)
 
void ScrubPollerThread ()
 
void JoinThread ()
 
- Private Member Functions inherited from PrefsListener
 PrefsListener ()
 
virtual ~PrefsListener ()
 
virtual void UpdatePrefs ()=0
 
virtual void UpdateSelectedPrefs (int id)
 

Private Attributes

int mScrubToken
 
int mScrubSpeedDisplayCountdown
 
wxCoord mScrubStartPosition
 
wxCoord mLastScrubPosition {}
 
bool mScrubSeekPress {}
 
bool mSmoothScrollingScrub
 
bool mPaused {}
 
bool mSeeking {}
 
bool mSpeedPlaying {true}
 
bool mKeyboardScrubbing {}
 
bool mBackwards {}
 
bool mDragging {}
 
bool mCancelled {}
 
int mLogMaxScrubSpeed
 
AudacityProjectmProject
 
std::unique_ptr< ScrubPollermPoller
 
ScrubbingOptions mOptions
 
double mMaxSpeed { 1.0 }
 
bool mShowScrubbing { false }
 
bool mMayDragToSeek { false }
 

Additional Inherited Members

- Static Private Member Functions inherited from PrefsListener
static void Broadcast (int id=0)
 Call this static function to notify all PrefsListener objects. More...
 

Detailed Description

Definition at line 39 of file Scrubbing.h.

Constructor & Destructor Documentation

◆ Scrubber() [1/2]

Scrubber::Scrubber ( AudacityProject project)
explicit

Definition at line 196 of file Scrubbing.cpp.

197 : mScrubToken(-1)
200 , mSmoothScrollingScrub(false)
201 , mPaused(true)
203
205 , mPoller { std::make_unique<ScrubPoller>(*this) }
206 , mOptions {}
207
208{
209 if (wxTheApp)
210 wxTheApp->Bind
211 (wxEVT_ACTIVATE_APP,
213
214 UpdatePrefs();
215}
const auto project
int mScrubToken
Definition: Scrubbing.h:161
wxCoord mScrubStartPosition
Definition: Scrubbing.h:163
bool mSmoothScrollingScrub
Definition: Scrubbing.h:166
std::unique_ptr< ScrubPoller > mPoller
Definition: Scrubbing.h:192
void OnActivateOrDeactivateApp(wxActivateEvent &event)
Definition: Scrubbing.cpp:861
int mScrubSpeedDisplayCountdown
Definition: Scrubbing.h:162
AudacityProject * mProject
Definition: Scrubbing.h:179
void UpdatePrefs() override
Definition: Scrubbing.cpp:957
ScrubbingOptions mOptions
Definition: Scrubbing.h:195
int mLogMaxScrubSpeed
Definition: Scrubbing.h:177
bool mPaused
Definition: Scrubbing.h:168

References OnActivateOrDeactivateApp(), and UpdatePrefs().

Here is the call graph for this function:

◆ Scrubber() [2/2]

Scrubber::Scrubber ( const Scrubber )
delete

◆ ~Scrubber()

Scrubber::~Scrubber ( )

Definition at line 227 of file Scrubbing.cpp.

228{
229 JoinThread();
230}
void JoinThread()
Definition: Scrubbing.cpp:217

References JoinThread().

Here is the call graph for this function:

Member Function Documentation

◆ Cancel()

void Scrubber::Cancel ( )
inline

Definition at line 106 of file Scrubbing.h.

107 { mCancelled = true; }
bool mCancelled
Definition: Scrubbing.h:175

Referenced by OnActivateOrDeactivateApp().

Here is the caller graph for this function:

◆ CanScrub()

bool Scrubber::CanScrub ( ) const

Definition at line 1038 of file Scrubbing.cpp.

1039{
1040 // Recheck the same condition as enables the Scrub/Seek menu item.
1041 auto gAudioIO = AudioIO::Get();
1042 return !( gAudioIO->IsBusy() && gAudioIO->GetNumCaptureChannels() > 0 ) &&
1044}
static const auto HasWaveDataPred
Definition: Scrubbing.cpp:232
static AudioIO * Get()
Definition: AudioIO.cpp:126

References AudioIO::Get(), HasWaveDataPred, and mProject.

Referenced by DoScrub().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckMenuItems()

void Scrubber::CheckMenuItems ( )

Definition at line 1190 of file Scrubbing.cpp.

1191{
1192 auto &cm = CommandManager::Get( *mProject );
1193 for (const auto &item : menuItems()) {
1194 auto test = item.StatusTest;
1195 if (test)
1196 cm.Check(item.name, (this->*test)());
1197 }
1198}
static CommandManager & Get(AudacityProject &project)

References CommandManager::Get(), anonymous_namespace{Scrubbing.cpp}::menuItems(), and mProject.

Referenced by MarkScrubStart(), OnScrub(), OnScrubOrSeek(), OnSeek(), OnToggleScrubRuler(), and StopScrubbing().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ChoseSeeking()

bool Scrubber::ChoseSeeking ( ) const

Definition at line 784 of file Scrubbing.cpp.

785{
786 return
787#if !defined(DRAG_SCRUB)
788 // Drag always seeks
789 mDragging ||
790#endif
791 mSeeking;
792}
bool mDragging
Definition: Scrubbing.h:173
bool mSeeking
Definition: Scrubbing.h:169

References mDragging, and mSeeking.

Referenced by Scrubs(), and Seeks().

Here is the caller graph for this function:

◆ ContinueScrubbingPoll()

void Scrubber::ContinueScrubbingPoll ( )

Definition at line 573 of file Scrubbing.cpp.

574{
575 // Thus scrubbing relies mostly on periodic polling of mouse and keys,
576 // not event notifications. But there are a few event handlers that
577 // leave messages for this routine, in mScrubSeekPress and in mPaused.
578
579 // Decide whether to skip play, because either mouse is down now,
580 // or there was a left click event. (This is then a delayed reaction, in a
581 // timer callback, to a left click event detected elsewhere.)
582 const bool seek = TemporarilySeeks() || Seeks();
583
584 auto gAudioIO = AudioIO::Get();
585 if (mPaused) {
586 // When paused, make silent scrubs.
587 mOptions.minSpeed = 0.0;
589 mOptions.adjustStart = false;
590 mOptions.bySpeed = true;
592 }
593 else if (mSpeedPlaying) {
594 // default speed of 1.3 set, so that we can hear there is a problem
595 // when playAtSpeedTB not found.
596 double speed = 1.3;
597 const auto &projectAudioIO = ProjectAudioIO::Get( *mProject );
598 speed = projectAudioIO.GetPlaySpeed();
599 mOptions.minSpeed = speed -0.01;
600 mOptions.maxSpeed = speed +0.01;
601 mOptions.adjustStart = false;
602 mOptions.bySpeed = true;
604 }
605 else if (mKeyboardScrubbing) {
608 mOptions.adjustStart = false;
609 mOptions.bySpeed = true;
610 double speed = GetKeyboardScrubbingSpeed();
611 if (mBackwards)
612 speed *= -1.0;
614 } else {
615 const wxMouseState state(::wxGetMouseState());
616 auto &trackPanel = GetProjectPanel( *mProject );
617 const wxPoint position = trackPanel.ScreenToClient(state.GetPosition());
618 auto &viewInfo = ViewInfo::Get( *mProject );
619#ifdef DRAG_SCRUB
621 const auto lastTime = ScrubState::GetLastScrubTime();
622 const auto delta = mLastScrubPosition - position.x;
623 const double time = viewInfo.OffsetTimeByPixels(lastTime, delta);
624 mOptions.minSpeed = 0.0;
626 mOptions.adjustStart = true;
627 mOptions.bySpeed = false;
628 gAudioIO->UpdateScrub(time, mOptions);
629 mLastScrubPosition = position.x;
630 }
631 else
632#endif
633 {
634 const auto origin = viewInfo.GetLeftOffset();
635 auto xx = position.x;
636 if (!seek && !mSmoothScrollingScrub) {
637 // If mouse is out-of-bounds, so that we scrub at maximum speed
638 // toward the mouse position, then move the target time to a more
639 // extreme position to avoid catching-up and halting before the
640 // screen scrolls.
641 auto width = viewInfo.GetTracksUsableWidth();
642 auto delta = xx - origin;
643 if (delta < 0)
644 delta -= width;
645 else if (delta >= width)
646 delta += width;
647 xx = origin + delta;
648 }
649 const double time = viewInfo.PositionToTime(xx, origin);
650 mOptions.adjustStart = seek;
651 mOptions.minSpeed = seek ? 1.0 : 0.0;
652 mOptions.maxSpeed = seek ? 1.0 : mMaxSpeed;
653
655 const double speed = FindScrubSpeed(seek, time);
656 mOptions.bySpeed = true;
658 }
659 else {
660 mOptions.bySpeed = false;
662 }
663 }
664 }
665
666 mScrubSeekPress = false;
667
668 // else, if seek requested, try again at a later time when we might
669 // enqueue a long enough stutter
670}
AUDACITY_DLL_API wxWindow & GetProjectPanel(AudacityProject &project)
Get the main sub-window of the project frame that displays track data.
static ProjectAudioIO & Get(AudacityProject &project)
bool mBackwards
Definition: Scrubbing.h:172
bool Seeks() const
Definition: Scrubbing.cpp:800
double GetKeyboardScrubbingSpeed()
Definition: Scrubbing.cpp:559
bool mScrubSeekPress
Definition: Scrubbing.h:165
wxCoord mLastScrubPosition
Definition: Scrubbing.h:164
bool TemporarilySeeks() const
Definition: Scrubbing.cpp:794
double mMaxSpeed
Definition: Scrubbing.h:196
bool mSpeedPlaying
Definition: Scrubbing.h:170
bool mKeyboardScrubbing
Definition: Scrubbing.h:171
double FindScrubSpeed(bool seeking, double time) const
Definition: Scrubbing.cpp:823
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
static double GetLastScrubTime()
return the ending time of the last scrub interval.
Definition: ScrubState.cpp:476
static void UpdateScrub(double endTimeOrSpeed, const ScrubbingOptions &options)
Notify scrubbing engine of desired position or speed. If options.adjustStart is true,...
Definition: ScrubState.cpp:463
static double MinAllowedScrubSpeed()
Definition: ScrubState.h:44
static double MaxAllowedScrubSpeed()
Definition: ScrubState.h:42

References ScrubbingOptions::adjustStart, ScrubbingOptions::bySpeed, FindScrubSpeed(), AudioIO::Get(), ProjectAudioIO::Get(), ViewInfo::Get(), GetKeyboardScrubbingSpeed(), ScrubState::GetLastScrubTime(), GetProjectPanel(), ScrubbingOptions::MaxAllowedScrubSpeed(), ScrubbingOptions::maxSpeed, mBackwards, mDragging, ScrubbingOptions::MinAllowedScrubSpeed(), ScrubbingOptions::minSpeed, mKeyboardScrubbing, mLastScrubPosition, mMaxSpeed, mOptions, mPaused, mProject, mScrubSeekPress, mSmoothScrollingScrub, mSpeedPlaying, Seeks(), TemporarilySeeks(), and ScrubState::UpdateScrub().

Referenced by MaybeStartScrubbing(), Scrubber::ScrubPoller::Notify(), and StartKeyboardScrubbing().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ContinueScrubbingUI()

void Scrubber::ContinueScrubbingUI ( )

Definition at line 672 of file Scrubbing.cpp.

673{
674 const wxMouseState state(::wxGetMouseState());
675
676 if (mDragging && !state.LeftIsDown()) {
677 // Dragging scrub can stop with mouse up
678 // Stop and set cursor
679 bool bShift = state.ShiftDown();
680 auto &projectAudioManager = ProjectAudioManager::Get( *mProject );
681 projectAudioManager.DoPlayStopSelect( true, bShift );
682 projectAudioManager.Stop();
683 return;
684 }
685
686 const bool seek = Seeks() || TemporarilySeeks();
687
688 {
689 // Show the correct status for seeking.
690 bool backup = mSeeking;
691 mSeeking = seek;
692 mSeeking = backup;
693 }
694
695 if (seek)
697
699 ;
700 else {
703 }
704}
static ProjectAudioManager & Get(AudacityProject &project)

References ProjectAudioManager::Get(), mDragging, mProject, mScrubSpeedDisplayCountdown, mSeeking, mSmoothScrollingScrub, Seeks(), and TemporarilySeeks().

Referenced by Scrubber::ScrubPoller::Notify().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoKeyboardScrub()

void Scrubber::DoKeyboardScrub ( bool  backwards,
bool  keyUp 
)

Definition at line 1046 of file Scrubbing.cpp.

1047{
1048 auto &project = *mProject;
1049
1050 static double initT0 = 0;
1051 static double initT1 = 0;
1052
1053 if (keyUp) {
1054 auto &scrubber = Scrubber::Get(project);
1055 if (scrubber.IsKeyboardScrubbing() && scrubber.IsBackwards() == backwards) {
1056 auto gAudioIO = AudioIO::Get();
1057 auto time = gAudioIO->GetStreamTime();
1058 auto &viewInfo = ViewInfo::Get(project);
1059 auto &selection = viewInfo.selectedRegion;
1060
1061 // If the time selection has not changed during scrubbing
1062 // set the cursor position
1063 if (selection.t0() == initT0 && selection.t1() == initT1) {
1064 double endTime = TrackList::Get(project).GetEndTime();
1065 time = std::min(time, endTime);
1066 time = std::max(time, 0.0);
1067 selection.setTimes(time, time);
1069 }
1070
1071 scrubber.Cancel();
1073 }
1074 }
1075 else { // KeyDown
1076 auto gAudioIO = AudioIOBase::Get();
1077 auto &scrubber = Scrubber::Get(project);
1078 if (scrubber.IsKeyboardScrubbing() && scrubber.IsBackwards() != backwards) {
1079 // change direction
1080 scrubber.SetBackwards(backwards);
1081 }
1082 else if (!gAudioIO->IsBusy() && !scrubber.HasMark()) {
1083 auto &viewInfo = ViewInfo::Get(project);
1084 auto &selection = viewInfo.selectedRegion;
1085 double endTime = TrackList::Get(project).GetEndTime();
1086 double t0 = selection.t0();
1087
1088 if ((!backwards && t0 >= 0 && t0 < endTime) ||
1089 (backwards && t0 > 0 && t0 <= endTime)) {
1090 initT0 = t0;
1091 initT1 = selection.t1();
1092 scrubber.StartKeyboardScrubbing(t0, backwards);
1093 }
1094 }
1095 }
1096}
int min(int a, int b)
static AudioIOBase * Get()
Definition: AudioIOBase.cpp:94
void Stop(bool stopStream=true)
void ModifyState(bool bWantsAutoSave)
static ProjectHistory & Get(AudacityProject &project)
static Scrubber & Get(AudacityProject &project)
Definition: Scrubbing.cpp:186
double GetEndTime() const
Return the greatest end time of the tracks, or 0 when no tracks.
Definition: Track.cpp:784
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314

References AudioIOBase::Get(), AudioIO::Get(), ProjectHistory::Get(), ViewInfo::Get(), TrackList::Get(), ProjectAudioManager::Get(), Get(), TrackList::GetEndTime(), min(), ProjectHistory::ModifyState(), mProject, project, and ProjectAudioManager::Stop().

Referenced by OnKeyboardScrubBackwards(), and OnKeyboardScrubForwards().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoScrub()

void Scrubber::DoScrub ( bool  seek)
private

Definition at line 891 of file Scrubbing.cpp.

892{
893 if( !CanScrub() )
894 return;
895 const bool wasScrubbing = HasMark() || IsScrubbing();
896 const bool scroll = ShouldScrubPinned();
897 if (!wasScrubbing) {
898 auto &tp = GetProjectPanel( *mProject );
899 const auto &viewInfo = ViewInfo::Get( *mProject );
900 wxCoord xx = tp.ScreenToClient(::wxGetMouseState().GetPosition()).x;
901
902 // Limit x
903 auto width = viewInfo.GetTracksUsableWidth();
904 const auto offset = viewInfo.GetLeftOffset();
905 xx = (std::max(offset, std::min(offset + width - 1, xx)));
906
907 MarkScrubStart(xx, scroll, seek);
908 }
909 else if (mSeeking != seek) {
910 // just switching mode
911 }
912 else {
913 auto &projectAudioManager = ProjectAudioManager::Get( *mProject );
914 projectAudioManager.Stop();
915 }
916}
void MarkScrubStart(wxCoord xx, bool smoothScrolling, bool seek)
Definition: Scrubbing.cpp:303
static bool ShouldScrubPinned()
Definition: Scrubbing.cpp:149
bool IsScrubbing() const
Definition: Scrubbing.cpp:768
bool CanScrub() const
Definition: Scrubbing.cpp:1038
bool HasMark() const
Definition: Scrubbing.h:89

References CanScrub(), ViewInfo::Get(), ProjectAudioManager::Get(), GetProjectPanel(), HasMark(), IsScrubbing(), MarkScrubStart(), min(), mProject, mSeeking, and ShouldScrubPinned().

Referenced by OnScrubOrSeek().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindScrubSpeed()

double Scrubber::FindScrubSpeed ( bool  seeking,
double  time 
) const

Definition at line 823 of file Scrubbing.cpp.

824{
825 auto &viewInfo = ViewInfo::Get( *mProject );
826 const double screen =
827 viewInfo.GetScreenEndTime() - viewInfo.hpos;
828 return (seeking ? FindSeekSpeed : FindScrubbingSpeed)
829 (viewInfo, mMaxSpeed, screen, time);
830}
double FindSeekSpeed(const ViewInfo &viewInfo, double maxScrubSpeed, double screen, double timeAtMouse)
Definition: Scrubbing.cpp:103
double FindScrubbingSpeed(const ViewInfo &viewInfo, double maxScrubSpeed, double screen, double timeAtMouse)
Definition: Scrubbing.cpp:61

References anonymous_namespace{Scrubbing.cpp}::FindScrubbingSpeed(), anonymous_namespace{Scrubbing.cpp}::FindSeekSpeed(), ViewInfo::Get(), mMaxSpeed, and mProject.

Referenced by ContinueScrubbingPoll(), and ScrubbingOverlay::OnTimer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Get() [1/2]

Scrubber & Scrubber::Get ( AudacityProject project)
static

◆ Get() [2/2]

const Scrubber & Scrubber::Get ( const AudacityProject project)
static

Definition at line 191 of file Scrubbing.cpp.

192{
193 return Get( const_cast< AudacityProject & >( project ) );
194}
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90

References Get(), and project.

Here is the call graph for this function:

◆ GetKeyboardScrubbingSpeed()

double Scrubber::GetKeyboardScrubbingSpeed ( )

Definition at line 559 of file Scrubbing.cpp.

560{
561 const double speedAtDefaultZoom = 0.5;
562 const double maxSpeed = 3.0;
563 const double minSpeed = 0.0625;
564
565 auto &viewInfo = ViewInfo::Get(*mProject);
566 double speed = speedAtDefaultZoom*viewInfo.GetDefaultZoom() / viewInfo.GetZoom();
567 speed = std::min(speed, maxSpeed);
568 speed = std::max(speed, minSpeed);
569 return speed;
570}

References ViewInfo::Get(), min(), and mProject.

Referenced by ContinueScrubbingPoll(), and StartKeyboardScrubbing().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMaxScrubSpeed()

double Scrubber::GetMaxScrubSpeed ( ) const
inline

Definition at line 111 of file Scrubbing.h.

111{ return mOptions.maxSpeed; }

Referenced by ScrubbingOverlay::OnTimer().

Here is the caller graph for this function:

◆ GetScrubStartPosition()

wxCoord Scrubber::GetScrubStartPosition ( ) const
inline

Definition at line 72 of file Scrubbing.h.

73 { return mScrubStartPosition; }

◆ GetUntranslatedStateString()

const TranslatableString & Scrubber::GetUntranslatedStateString ( ) const

Definition at line 987 of file Scrubbing.cpp.

988{
989 static TranslatableString empty;
990
991 if (IsSpeedPlaying()) {
992 return sPlayAtSpeedStatus;
993 }
994 else if (IsKeyboardScrubbing()) {
996 }
997 else if (HasMark()) {
998 auto &item = FindMenuItem(Seeks() || TemporarilySeeks());
999 return item.status;
1000 }
1001 else
1002 return empty;
1003}
static auto sPlayAtSpeedStatus
Definition: Scrubbing.cpp:982
static auto sKeyboardScrubbingStatus
Definition: Scrubbing.cpp:984
bool IsKeyboardScrubbing() const
Definition: Scrubbing.h:81
bool IsSpeedPlaying() const
Definition: Scrubbing.h:77
Holds a msgid for the translation catalog; may also bind format arguments.
const MenuItem & FindMenuItem(bool seek)
Definition: Scrubbing.cpp:292

References anonymous_namespace{Scrubbing.cpp}::FindMenuItem(), sKeyboardScrubbingStatus, and sPlayAtSpeedStatus.

Referenced by ControlToolBar::StateForStatusBar().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleScrollWheel()

void Scrubber::HandleScrollWheel ( int  steps)

Definition at line 832 of file Scrubbing.cpp.

833{
834 if (steps == 0)
835 return;
836
837 const int newLogMaxScrubSpeed = mLogMaxScrubSpeed + steps;
838 static const double maxScrubSpeedBase =
839 pow(2.0, 1.0 / ScrubSpeedStepsPerOctave);
840 double newSpeed = pow(maxScrubSpeedBase, newLogMaxScrubSpeed);
841 if (newSpeed >= ScrubbingOptions::MinAllowedScrubSpeed() &&
843 mLogMaxScrubSpeed = newLogMaxScrubSpeed;
844 mMaxSpeed = newSpeed;
846 // Show the speed for one second
848 }
849}
@ ScrubSpeedStepsPerOctave
Definition: Scrubbing.cpp:51
@ kOneSecondCountdown
Definition: Scrubbing.cpp:53

References kOneSecondCountdown, ScrubbingOptions::MaxAllowedScrubSpeed(), ScrubbingOptions::MinAllowedScrubSpeed(), mLogMaxScrubSpeed, mMaxSpeed, mScrubSpeedDisplayCountdown, mSmoothScrollingScrub, and ScrubSpeedStepsPerOctave.

Here is the call graph for this function:

◆ HasMark()

bool Scrubber::HasMark ( ) const
inline

Definition at line 89 of file Scrubbing.h.

90 { return GetScrubStartPosition() >= 0; }
wxCoord GetScrubStartPosition() const
Definition: Scrubbing.h:72

Referenced by DoScrub(), IsTransportingPinned(), ScrubbingOverlay::OnTimer(), anonymous_namespace{AdornedRulerPanel.cpp}::ScrubbingMessage(), Scrubs(), Seeks(), StartKeyboardScrubbing(), and StopScrubbing().

Here is the caller graph for this function:

◆ IsBackwards()

bool Scrubber::IsBackwards ( ) const
inline

Definition at line 85 of file Scrubbing.h.

86 { return mBackwards;}

◆ IsKeyboardScrubbing()

bool Scrubber::IsKeyboardScrubbing ( ) const
inline

Definition at line 81 of file Scrubbing.h.

82 { return IsScrubbing() && mKeyboardScrubbing; }

Referenced by ScrubbingOverlay::OnTimer().

Here is the caller graph for this function:

◆ IsPaused()

bool Scrubber::IsPaused ( ) const

Definition at line 856 of file Scrubbing.cpp.

857{
858 return mPaused;
859}

References mPaused.

◆ IsScrollScrubbing()

bool Scrubber::IsScrollScrubbing ( ) const
inline

Definition at line 93 of file Scrubbing.h.

94 { return mSmoothScrollingScrub; }

Referenced by ScrubbingOverlay::Draw(), and ScrubbingOverlay::OnTimer().

Here is the caller graph for this function:

◆ IsScrubbing()

bool Scrubber::IsScrubbing ( ) const

Definition at line 768 of file Scrubbing.cpp.

769{
770 if (mScrubToken <= 0)
771 return false;
772 auto &projectAudioIO = ProjectAudioIO::Get( *mProject );
773 if (mScrubToken == projectAudioIO.GetAudioIOToken() &&
774 projectAudioIO.IsAudioActive())
775 return true;
776 else {
777 const_cast<Scrubber&>(*this).mScrubToken = -1;
778 const_cast<Scrubber&>(*this).mScrubStartPosition = -1;
779 const_cast<Scrubber&>(*this).mSmoothScrollingScrub = false;
780 return false;
781 }
782}

References ProjectAudioIO::Get(), mProject, mScrubStartPosition, mScrubToken, and mSmoothScrollingScrub.

Referenced by anonymous_namespace{AdornedRulerPanel.cpp}::ContinueScrubbingMessage(), DoScrub(), MaybeStartScrubbing(), OnActivateOrDeactivateApp(), ScrubbingOverlay::OnTimer(), Scrubs(), Seeks(), and ShouldDrawScrubSpeed().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsSpeedPlaying()

bool Scrubber::IsSpeedPlaying ( ) const
inline

Definition at line 77 of file Scrubbing.h.

78 { return IsScrubbing() && mSpeedPlaying; }

Referenced by ScrubbingOverlay::OnTimer().

Here is the caller graph for this function:

◆ IsTransportingPinned()

bool Scrubber::IsTransportingPinned ( ) const

Definition at line 706 of file Scrubbing.cpp.

707{
709 return false;
710 return
711 !(HasMark() &&
712 !WasSpeedPlaying() &&
714}
bool WasSpeedPlaying() const
Definition: Scrubbing.h:75
static bool GetPinnedHeadPreference()

References TracksPrefs::GetPinnedHeadPreference(), HasMark(), ShouldScrubPinned(), and WasSpeedPlaying().

Here is the call graph for this function:

◆ JoinThread()

void Scrubber::JoinThread ( )
private

Definition at line 217 of file Scrubbing.cpp.

218{
219#ifdef USE_SCRUB_THREAD
220 if (mThread.joinable()) {
221 mFinishThread.store(true, std::memory_order_release);
222 mThread.join();
223 }
224#endif
225}

Referenced by StopPolling(), and ~Scrubber().

Here is the caller graph for this function:

◆ MarkScrubStart()

void Scrubber::MarkScrubStart ( wxCoord  xx,
bool  smoothScrolling,
bool  seek 
)

Definition at line 303 of file Scrubbing.cpp.

307{
308 // Don't actually start scrubbing, but collect some information
309 // needed for the decision to start scrubbing later when handling
310 // drag events.
311 mSmoothScrollingScrub = smoothScrolling;
312
313 auto &projectAudioManager = ProjectAudioManager::Get( *mProject );
314
315 // Stop any play in progress
316 // Bug 1492: mCancelled to stop us collapsing the selected region.
317 mCancelled = true;
318 projectAudioManager.Stop();
319 mCancelled = false;
320
321 // Usually the timer handler of TrackPanel does this, but we do this now,
322 // so that same timer does not StopPlaying() again after this function and destroy
323 // scrubber state
324 ProjectAudioIO::Get( *mProject ).SetAudioIOToken(0);
325
326 mSeeking = seek;
328
329 // Commented out for Bug 1421
330 // mSeeking
331 // ? ControlToolBar::PlayAppearance::Seek
332 // : ControlToolBar::PlayAppearance::Scrub);
333
335 mCancelled = false;
336}
void SetAudioIOToken(int token)
void CheckMenuItems()
Definition: Scrubbing.cpp:1190

References CheckMenuItems(), ProjectAudioIO::Get(), ProjectAudioManager::Get(), mCancelled, mProject, mScrubStartPosition, mSeeking, mSmoothScrollingScrub, and ProjectAudioIO::SetAudioIOToken().

Referenced by DoScrub().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MaybeStartScrubbing()

bool Scrubber::MaybeStartScrubbing ( wxCoord  xx)

Definition at line 349 of file Scrubbing.cpp.

350{
351 if (mScrubStartPosition < 0)
352 return false;
353 if (IsScrubbing())
354 return false;
355#ifdef USE_SCRUB_THREAD
356 if (mThread.joinable())
357 return false;
358#endif
359 else {
360 const auto state = ::wxGetMouseState();
361 mDragging = state.LeftIsDown();
362
363 auto gAudioIO = AudioIO::Get();
364 const bool busy = gAudioIO->IsBusy();
365 if (busy && gAudioIO->GetNumCaptureChannels() > 0) {
366 // Do not stop recording, and don't try to start scrubbing after
367 // recording stops
369 return false;
370 }
371
372 wxCoord position = xx;
373 if (abs(mScrubStartPosition - position) >= SCRUBBING_PIXEL_TOLERANCE) {
374 auto &viewInfo = ViewInfo::Get(*mProject);
375 auto &projectAudioManager = ProjectAudioManager::Get(*mProject);
376 double maxTime = TrackList::Get(*mProject).GetEndTime();
377 const int leftOffset = viewInfo.GetLeftOffset();
378 double time0 = std::min(maxTime,
379 viewInfo.PositionToTime(mScrubStartPosition, leftOffset)
380 );
381 double time1 = std::min(maxTime,
382 viewInfo.PositionToTime(position, leftOffset)
383 );
384 if (time1 != time0) {
385 if (busy) {
386 position = mScrubStartPosition;
387 projectAudioManager.Stop();
388 mScrubStartPosition = position;
389 }
390
391#ifdef DRAG_SCRUB
393 auto delta = time0 - time1;
394 time0 = std::max(0.0, std::min(maxTime,
395 viewInfo.h +
396 (viewInfo.GetScreenEndTime() - viewInfo.h)
398 ));
399 time1 = time0 + delta;
400 }
401#endif
402 mSpeedPlaying = false;
403 mKeyboardScrubbing = false;
404 auto options =
406
407#ifndef USE_SCRUB_THREAD
408 // Yuck, we either have to poll "by hand" when scrub polling doesn't
409 // work with a thread, or else yield to timer messages, but that would
410 // execute too much else
411 options.playbackStreamPrimer = [this](){
413 return ScrubPollInterval;
414 };
415#endif
416 options.playNonWaveTracks = false;
417 options.envelope = nullptr;
421 mOptions.minSpeed = 0.0;
422#ifdef USE_TRANSCRIPTION_TOOLBAR
423 if (!mAlwaysSeeking) {
424 // Take the starting speed limit from the transcription toolbar,
425 // but it may be varied during the scrub.
427 ProjectSettings::Get( *mProject ).GetPlaySpeed();
428 }
429#else
430 // That idea seems unpopular... just make it one for move-scrub,
431 // but big for drag-scrub
432#ifdef DRAG_SCRUB
433 mMaxSpeed = mOptions.maxSpeed = mDragging ? MaxDragSpeed : 1.0;
434#else
436#endif
437
438#endif
439 mOptions.minTime = 0;
441 std::max(0.0, TrackList::Get(*mProject).GetEndTime());
443#ifdef DRAG_SCRUB
445#endif
447
448 const bool backwards = time1 < time0;
449 static const double maxScrubSpeedBase =
450 pow(2.0, 1.0 / ScrubSpeedStepsPerOctave);
451 mLogMaxScrubSpeed = floor(0.5 +
452 log(mMaxSpeed) / log(maxScrubSpeedBase)
453 );
455
456 // Must start the thread and poller first or else PlayPlayRegion
457 // will insert some silence
458 StartPolling();
459 auto cleanup = finally([this]{
460 if (mScrubToken < 0)
461 StopPolling();
462 });
463
464 options.policyFactory = ScrubbingPlaybackPolicyFactory(mOptions);
466 projectAudioManager.PlayPlayRegion(
467 SelectedRegion(time0, time1), options,
468 PlayMode::normalPlay, backwards);
469 if (mScrubToken <= 0) {
470 // Bug1627 (part of it):
471 // infinite error spew when trying to start scrub:
472 // If failed for reasons of audio device problems, do not try
473 // again with repeated timer ticks.
475 return false;
476 }
477 }
478 }
479 else
480 // Wait to test again
481 ;
482
483 if (IsScrubbing()) {
485 }
486
487 // Return true whether we started scrub, or are still waiting to decide.
488 return true;
489 }
490}
static constexpr auto ScrubPollInterval
Definition: ScrubState.h:109
@ SCRUBBING_PIXEL_TOLERANCE
Definition: Scrubbing.cpp:49
static constexpr PlaybackPolicy::Duration MinStutter
Definition: Scrubbing.cpp:57
static AudioIOStartStreamOptions::PolicyFactory ScrubbingPlaybackPolicyFactory(const ScrubbingOptions &options)
Definition: Scrubbing.cpp:339
std::chrono::duration< double > Duration
static AudioIOStartStreamOptions GetDefaultOptions(AudacityProject &project, bool newDefaults=false)
Invoke the global hook, supplying a default argument.
static ProjectSettings & Get(AudacityProject &project)
void StopPolling()
Definition: Scrubbing.cpp:731
void StartPolling()
Definition: Scrubbing.cpp:716
void ContinueScrubbingPoll()
Definition: Scrubbing.cpp:573
Defines a selected portion of a project.
static double GetPinnedHeadPositionPreference()
PlaybackPolicy::Duration minStutterTime
Definition: ScrubState.h:40
bool isKeyboardScrubbing
Definition: ScrubState.h:28
PlaybackPolicy::Duration delay
Definition: ScrubState.h:30
double initSpeed
Definition: ScrubState.h:33

References ContinueScrubbingPoll(), ScrubbingOptions::delay, AudioIO::Get(), ViewInfo::Get(), TrackList::Get(), ProjectAudioManager::Get(), ProjectSettings::Get(), ProjectAudioIO::GetDefaultOptions(), TrackList::GetEndTime(), TracksPrefs::GetPinnedHeadPositionPreference(), ScrubbingOptions::initSpeed, ScrubbingOptions::isKeyboardScrubbing, IsScrubbing(), ScrubbingOptions::maxSpeed, ScrubbingOptions::maxTime, mDragging, min(), ScrubbingOptions::minSpeed, MinStutter, ScrubbingOptions::minStutterTime, ScrubbingOptions::minTime, mKeyboardScrubbing, mLastScrubPosition, mLogMaxScrubSpeed, mMaxSpeed, mOptions, mProject, mScrubSpeedDisplayCountdown, mScrubStartPosition, mScrubToken, mSmoothScrollingScrub, mSpeedPlaying, normalPlay, SCRUBBING_PIXEL_TOLERANCE, ScrubbingPlaybackPolicyFactory(), ScrubPollInterval, ScrubSpeedStepsPerOctave, StartPolling(), and StopPolling().

Referenced by ScrubbingOverlay::OnTimer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MayDragToSeek()

bool Scrubber::MayDragToSeek ( ) const
inline

Definition at line 100 of file Scrubbing.h.

100{ return mMayDragToSeek; }
bool mMayDragToSeek
Definition: Scrubbing.h:199

Referenced by TemporarilySeeks().

Here is the caller graph for this function:

◆ OnActivateOrDeactivateApp()

void Scrubber::OnActivateOrDeactivateApp ( wxActivateEvent &  event)
private

Definition at line 861 of file Scrubbing.cpp.

862{
863 // First match priority logic...
864 // Pause if Pause down, or not scrubbing.
865 if (!mProject)
866 Pause(true);
867 else if (ProjectAudioManager::Get( *mProject ).Paused())
868 Pause( true );
869 else if (!IsScrubbing())
870 Pause( true );
871
872 // Stop keyboard scrubbing if losing focus
873 else if (mKeyboardScrubbing && !event.GetActive()) {
874 Cancel();
875 ProjectAudioManager::Get(*mProject).Stop();
876 }
877
878 // Speed playing does not pause if losing focus.
879 else if (mSpeedPlaying)
880 Pause( false );
881
882 // But scrub and seek do.
883 else if (!event.GetActive())
884 Pause( true );
885 else
886 Pause(false);
887
888 event.Skip();
889}
void Pause(bool paused)
Definition: Scrubbing.cpp:851
void Cancel()
Definition: Scrubbing.h:106

References Cancel(), ProjectAudioManager::Get(), IsScrubbing(), mKeyboardScrubbing, mProject, mSpeedPlaying, Pause(), ProjectAudioManager::Paused(), and ProjectAudioManager::Stop().

Referenced by Scrubber().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnKeyboardScrubBackwards()

void Scrubber::OnKeyboardScrubBackwards ( const CommandContext context)

Definition at line 1098 of file Scrubbing.cpp.

1099{
1100 auto evt = context.pEvt;
1101 if (evt)
1102 DoKeyboardScrub(true, evt->GetEventType() == wxEVT_KEY_UP);
1103 else { // called from menu, so simulate keydown and keyup
1104 DoKeyboardScrub(true, false);
1105 DoKeyboardScrub(true, true);
1106 }
1107}
const wxEvent * pEvt
void DoKeyboardScrub(bool backwards, bool keyUp)
Definition: Scrubbing.cpp:1046

References DoKeyboardScrub(), and CommandContext::pEvt.

Referenced by anonymous_namespace{Scrubbing.cpp}::KeyboardScrubbingItems().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnKeyboardScrubForwards()

void Scrubber::OnKeyboardScrubForwards ( const CommandContext context)

Definition at line 1109 of file Scrubbing.cpp.

1110{
1111 auto evt = context.pEvt;
1112 if (evt)
1113 DoKeyboardScrub(false, evt->GetEventType() == wxEVT_KEY_UP);
1114 else { // called from menu, so simulate keydown and keyup
1115 DoKeyboardScrub(false, false);
1116 DoKeyboardScrub(false, true);
1117 }
1118}

References DoKeyboardScrub(), and CommandContext::pEvt.

Referenced by anonymous_namespace{Scrubbing.cpp}::KeyboardScrubbingItems().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnScrub()

void Scrubber::OnScrub ( const CommandContext )

Definition at line 926 of file Scrubbing.cpp.

927{
928 OnScrubOrSeek(false);
930}
void OnScrubOrSeek(bool seek)
Definition: Scrubbing.cpp:918

References CheckMenuItems(), and OnScrubOrSeek().

Referenced by anonymous_namespace{Scrubbing.cpp}::menuItems().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnScrubOrSeek()

void Scrubber::OnScrubOrSeek ( bool  seek)

Definition at line 918 of file Scrubbing.cpp.

919{
920 DoScrub(seek);
921
922 mSeeking = seek;
924}
void DoScrub(bool seek)
Definition: Scrubbing.cpp:891

References CheckMenuItems(), DoScrub(), and mSeeking.

Referenced by OnScrub(), and OnSeek().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnSeek()

void Scrubber::OnSeek ( const CommandContext )

Definition at line 932 of file Scrubbing.cpp.

933{
934 OnScrubOrSeek(true);
936}

References CheckMenuItems(), and OnScrubOrSeek().

Referenced by anonymous_namespace{Scrubbing.cpp}::menuItems().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnToggleScrubRuler()

void Scrubber::OnToggleScrubRuler ( const CommandContext )

Definition at line 962 of file Scrubbing.cpp.

963{
966 gPrefs->Flush();
968}
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
bool mShowScrubbing
Definition: Scrubbing.h:198
virtual bool Flush() noexcept=0
void WriteScrubEnabledPref(bool value)
Definition: Scrubbing.cpp:950

References CheckMenuItems(), audacity::BasicSettings::Flush(), gPrefs, mShowScrubbing, and anonymous_namespace{Scrubbing.cpp}::WriteScrubEnabledPref().

Referenced by anonymous_namespace{Scrubbing.cpp}::menuItems().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

Scrubber & Scrubber::operator= ( const Scrubber )
delete

◆ Pause()

void Scrubber::Pause ( bool  paused)

Definition at line 851 of file Scrubbing.cpp.

852{
853 mPaused = paused;
854}

References mPaused.

Referenced by OnActivateOrDeactivateApp().

Here is the caller graph for this function:

◆ PopulatePopupMenu()

void Scrubber::PopulatePopupMenu ( wxMenu &  menu)

Definition at line 1174 of file Scrubbing.cpp.

1175{
1176 int id = CMD_ID;
1177 auto &cm = CommandManager::Get( *mProject );
1178 for (const auto &item : menuItems()) {
1179 if (cm.GetEnabled(item.name)) {
1180 auto test = item.StatusTest;
1181 menu.Append(id, item.label.Translation(), wxString{},
1182 test ? wxITEM_CHECK : wxITEM_NORMAL);
1183 if(test && (this->*test)())
1184 menu.FindItem(id)->Check();
1185 }
1186 ++id;
1187 }
1188}
@ CMD_ID
Definition: Scrubbing.cpp:970
int id

References CMD_ID, CommandManager::Get(), id, anonymous_namespace{Scrubbing.cpp}::menuItems(), and mProject.

Here is the call graph for this function:

◆ ScrubPollerThread()

void Scrubber::ScrubPollerThread ( )
private

Referenced by StartPolling().

Here is the caller graph for this function:

◆ Scrubs()

bool Scrubber::Scrubs ( ) const

Definition at line 805 of file Scrubbing.cpp.

806{
807 if( Seeks() )
808 return false;
809 return (HasMark() || IsScrubbing()) && !ChoseSeeking();
810}
bool ChoseSeeking() const
Definition: Scrubbing.cpp:784

References ChoseSeeking(), HasMark(), IsScrubbing(), and Seeks().

Referenced by anonymous_namespace{Scrubbing.cpp}::menuItems(), and StatusMessageForWave().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Seeks()

bool Scrubber::Seeks ( ) const

Definition at line 800 of file Scrubbing.cpp.

801{
802 return (HasMark() || IsScrubbing()) && ChoseSeeking();
803}

References ChoseSeeking(), HasMark(), and IsScrubbing().

Referenced by anonymous_namespace{AdornedRulerPanel.cpp}::ContinueScrubbingMessage(), ContinueScrubbingPoll(), ContinueScrubbingUI(), anonymous_namespace{Scrubbing.cpp}::menuItems(), ScrubbingOverlay::OnTimer(), Scrubs(), ShouldDrawScrubSpeed(), and StatusMessageForWave().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetBackwards()

void Scrubber::SetBackwards ( bool  backwards)
inline

Definition at line 83 of file Scrubbing.h.

84 { mBackwards = backwards;}

◆ SetMayDragToSeek()

void Scrubber::SetMayDragToSeek ( bool  value)
inline

Definition at line 99 of file Scrubbing.h.

99{ mMayDragToSeek = value; }

◆ SetScrollScrubbing()

void Scrubber::SetScrollScrubbing ( bool  value)
inline

Definition at line 95 of file Scrubbing.h.

96 { mSmoothScrollingScrub = value; }

◆ SetSeekPress()

void Scrubber::SetSeekPress ( bool  value)
inline

Definition at line 146 of file Scrubbing.h.

146{ mScrubSeekPress = value; }

◆ ShouldDrawScrubSpeed()

bool Scrubber::ShouldDrawScrubSpeed ( )

Definition at line 812 of file Scrubbing.cpp.

813{
814 return IsScrubbing() &&
815 !mPaused && (
816 // Draw for (non-scroll) scrub, sometimes, but never for seek
818 // Draw always for scroll-scrub and for scroll-seek
820 );
821}

References IsScrubbing(), mPaused, mScrubSpeedDisplayCountdown, mSmoothScrollingScrub, Seeks(), and TemporarilySeeks().

Referenced by ScrubbingOverlay::DoGetRectangle(), ScrubbingOverlay::Draw(), and ScrubbingOverlay::OnTimer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ShouldScrubPinned()

bool Scrubber::ShouldScrubPinned ( )
static

Definition at line 149 of file Scrubbing.cpp.

References TracksPrefs::GetPinnedHeadPreference(), and PlaybackPrefs::GetUnpinnedScrubbingPreference().

Referenced by AdornedRulerPanel::ScrubbingHandle::Click(), DoScrub(), and IsTransportingPinned().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ShowsBar()

bool Scrubber::ShowsBar ( ) const

Definition at line 763 of file Scrubbing.cpp.

764{
765 return mShowScrubbing;
766}

References mShowScrubbing.

Referenced by anonymous_namespace{Scrubbing.cpp}::menuItems().

Here is the caller graph for this function:

◆ StartKeyboardScrubbing()

bool Scrubber::StartKeyboardScrubbing ( double  time0,
bool  backwards 
)

Definition at line 492 of file Scrubbing.cpp.

493{
494 if (HasMark() || AudioIO::Get()->IsBusy())
495 return false;
496#ifdef USE_SCRUB_THREAD
497 if (mThread.joinable())
498 return false;
499#endif
500
501 mScrubStartPosition = 0; // so that HasMark() is true
502 mSpeedPlaying = false;
503 mKeyboardScrubbing = true;
504 mBackwards = backwards;
506 mDragging = false;
507
508 auto options = DefaultSpeedPlayOptions(*mProject);
509
510#ifndef USE_SCRUB_THREAD
511 // Yuck, we either have to poll "by hand" when scrub polling doesn't
512 // work with a thread, or else yield to timer messages, but that would
513 // execute too much else
514 options.playbackStreamPrimer = [this]() {
516 return ScrubPollInterval;
517 };
518#endif
519
520 options.playNonWaveTracks = false;
521 options.envelope = nullptr;
522
523 // delay and minStutterTime are used in AudioIO::AllocateBuffers() for setting the
524 // values of mPlaybackQueueMinimum and mPlaybackSamplesToCopy respectively.
527
529 if (backwards)
530 mOptions.initSpeed *= -1.0;
533 mOptions.minTime = 0;
534 mOptions.maxTime = std::max(0.0, TrackList::Get(*mProject).GetEndTime());
535 mOptions.bySpeed = true;
536 mOptions.adjustStart = false;
538
539 // Must start the thread and poller first or else PlayPlayRegion
540 // will insert some silence
541 StartPolling();
542 auto cleanup = finally([this] {
543 if (mScrubToken < 0)
544 StopPolling();
545 });
546
547 options.policyFactory = ScrubbingPlaybackPolicyFactory(mOptions);
550 SelectedRegion(time0, backwards ? mOptions.minTime : mOptions.maxTime),
551 options,
553 backwards);
554
555 return true;
556}
AudioIOStartStreamOptions DefaultSpeedPlayOptions(AudacityProject &project)
int PlayPlayRegion(const SelectedRegion &selectedRegion, const AudioIOStartStreamOptions &options, PlayMode playMode, bool backwards=false)

References ScrubbingOptions::adjustStart, ScrubbingOptions::bySpeed, ContinueScrubbingPoll(), DefaultSpeedPlayOptions(), ScrubbingOptions::delay, AudioIO::Get(), TrackList::Get(), ProjectAudioManager::Get(), TrackList::GetEndTime(), GetKeyboardScrubbingSpeed(), HasMark(), ScrubbingOptions::initSpeed, ScrubbingOptions::isKeyboardScrubbing, ScrubbingOptions::MaxAllowedScrubSpeed(), ScrubbingOptions::maxSpeed, ScrubbingOptions::maxTime, mBackwards, mDragging, ScrubbingOptions::MinAllowedScrubSpeed(), ScrubbingOptions::minSpeed, ScrubbingOptions::minStutterTime, ScrubbingOptions::minTime, mKeyboardScrubbing, mMaxSpeed, mOptions, mProject, mScrubStartPosition, mScrubToken, mSpeedPlaying, normalPlay, ProjectAudioManager::PlayPlayRegion(), ScrubbingPlaybackPolicyFactory(), ScrubPollInterval, StartPolling(), and StopPolling().

Here is the call graph for this function:

◆ StartPolling()

void Scrubber::StartPolling ( )
private
Precondition
!mThread.joinable() (when defined(USE_SCRUB_THREAD))

Definition at line 716 of file Scrubbing.cpp.

717{
718 mPaused = false;
719
720#ifdef USE_SCRUB_THREAD
721 assert(!mThread.joinable());
722 mFinishThread.store(false, std::memory_order_relaxed);
723 mThread = std::thread{
724 std::mem_fn( &Scrubber::ScrubPollerThread ), std::ref(*this) };
725#endif
726
727 mPoller->Start( 0.9 *
728 std::chrono::duration<double, std::milli>{ScrubPollInterval}.count());
729}
void ScrubPollerThread()

References mPaused, mPoller, ScrubPollerThread(), and ScrubPollInterval.

Referenced by MaybeStartScrubbing(), and StartKeyboardScrubbing().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StatusMessageForWave()

wxString Scrubber::StatusMessageForWave ( ) const

Definition at line 1005 of file Scrubbing.cpp.

1006{
1007 wxString result;
1008
1009 if( Seeks() )
1010 result = _("Move mouse pointer to Seek");
1011 else if( Scrubs() )
1012 result = _("Move mouse pointer to Scrub");
1013 return result;
1014}
#define _(s)
Definition: Internat.h:73
bool Scrubs() const
Definition: Scrubbing.cpp:805

References _, Scrubs(), and Seeks().

Here is the call graph for this function:

◆ StopPolling()

void Scrubber::StopPolling ( )
private

Definition at line 731 of file Scrubbing.cpp.

732{
733 mPaused = true;
734
735#ifdef USE_SCRUB_THREAD
736 JoinThread();
737#endif
738
739 mPoller->Stop();
740}

References JoinThread(), mPaused, and mPoller.

Referenced by MaybeStartScrubbing(), StartKeyboardScrubbing(), and StopScrubbing().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StopScrubbing()

void Scrubber::StopScrubbing ( )

Definition at line 742 of file Scrubbing.cpp.

743{
744 auto gAudioIO = AudioIO::Get();
746 StopPolling();
747
748 if (HasMark() && !mCancelled) {
749 const wxMouseState state(::wxGetMouseState());
750 // Stop and set cursor
751 bool bShift = state.ShiftDown();
752 auto &projectAudioManager = ProjectAudioManager::Get( *mProject );
753 projectAudioManager.DoPlayStopSelect(true, bShift);
754 }
755
757 mDragging = false;
758 mSeeking = false;
759
761}
static void StopScrub()
Definition: ScrubState.cpp:469

References CheckMenuItems(), AudioIO::Get(), ProjectAudioManager::Get(), HasMark(), mCancelled, mDragging, mProject, mScrubStartPosition, mSeeking, StopPolling(), and ScrubState::StopScrub().

Here is the call graph for this function:

◆ TemporarilySeeks()

bool Scrubber::TemporarilySeeks ( ) const

Definition at line 794 of file Scrubbing.cpp.

795{
796 return mScrubSeekPress ||
797 (::wxGetMouseState().LeftIsDown() && MayDragToSeek());
798}
bool MayDragToSeek() const
Definition: Scrubbing.h:100

References MayDragToSeek(), and mScrubSeekPress.

Referenced by ContinueScrubbingPoll(), ContinueScrubbingUI(), ScrubbingOverlay::OnTimer(), and ShouldDrawScrubSpeed().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Thunk()

template<void(Scrubber::*)(const CommandContext &) pfn>
void Scrubber::Thunk ( wxCommandEvent &  )
inline

Definition at line 132 of file Scrubbing.h.

133 { (this->*pfn)(*mProject); }

◆ UpdatePrefs()

void Scrubber::UpdatePrefs ( )
overrideprivatevirtual

Implements PrefsListener.

Definition at line 957 of file Scrubbing.cpp.

References mShowScrubbing, and anonymous_namespace{Scrubbing.cpp}::ReadScrubEnabledPref().

Referenced by Scrubber().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WasKeyboardScrubbing()

bool Scrubber::WasKeyboardScrubbing ( ) const
inline

Definition at line 79 of file Scrubbing.h.

80 { return mKeyboardScrubbing; }

◆ WasSpeedPlaying()

bool Scrubber::WasSpeedPlaying ( ) const
inline

Definition at line 75 of file Scrubbing.h.

76 { return mSpeedPlaying;}

Referenced by IsTransportingPinned().

Here is the caller graph for this function:

Member Data Documentation

◆ mBackwards

bool Scrubber::mBackwards {}
private

Definition at line 172 of file Scrubbing.h.

Referenced by ContinueScrubbingPoll(), and StartKeyboardScrubbing().

◆ mCancelled

bool Scrubber::mCancelled {}
private

Definition at line 175 of file Scrubbing.h.

Referenced by MarkScrubStart(), and StopScrubbing().

◆ mDragging

bool Scrubber::mDragging {}
private

◆ mKeyboardScrubbing

bool Scrubber::mKeyboardScrubbing {}
private

◆ mLastScrubPosition

wxCoord Scrubber::mLastScrubPosition {}
private

Definition at line 164 of file Scrubbing.h.

Referenced by ContinueScrubbingPoll(), and MaybeStartScrubbing().

◆ mLogMaxScrubSpeed

int Scrubber::mLogMaxScrubSpeed
private

Definition at line 177 of file Scrubbing.h.

Referenced by HandleScrollWheel(), and MaybeStartScrubbing().

◆ mMaxSpeed

double Scrubber::mMaxSpeed { 1.0 }
private

◆ mMayDragToSeek

bool Scrubber::mMayDragToSeek { false }
private

Definition at line 199 of file Scrubbing.h.

◆ mOptions

ScrubbingOptions Scrubber::mOptions
private

Definition at line 195 of file Scrubbing.h.

Referenced by ContinueScrubbingPoll(), MaybeStartScrubbing(), and StartKeyboardScrubbing().

◆ mPaused

bool Scrubber::mPaused {}
private

◆ mPoller

std::unique_ptr<ScrubPoller> Scrubber::mPoller
private

Definition at line 193 of file Scrubbing.h.

Referenced by StartPolling(), and StopPolling().

◆ mProject

AudacityProject* Scrubber::mProject
private

◆ mScrubSeekPress

bool Scrubber::mScrubSeekPress {}
private

Definition at line 165 of file Scrubbing.h.

Referenced by ContinueScrubbingPoll(), and TemporarilySeeks().

◆ mScrubSpeedDisplayCountdown

int Scrubber::mScrubSpeedDisplayCountdown
private

◆ mScrubStartPosition

wxCoord Scrubber::mScrubStartPosition
private

◆ mScrubToken

int Scrubber::mScrubToken
private

Definition at line 161 of file Scrubbing.h.

Referenced by IsScrubbing(), MaybeStartScrubbing(), and StartKeyboardScrubbing().

◆ mSeeking

bool Scrubber::mSeeking {}
private

◆ mShowScrubbing

bool Scrubber::mShowScrubbing { false }
private

Definition at line 198 of file Scrubbing.h.

Referenced by OnToggleScrubRuler(), ShowsBar(), and UpdatePrefs().

◆ mSmoothScrollingScrub

bool Scrubber::mSmoothScrollingScrub
private

◆ mSpeedPlaying

bool Scrubber::mSpeedPlaying {true}
private

The documentation for this class was generated from the following files: