From 671f60492dbc16659d4384793aea4b972f610acb Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Thu, 19 May 2016 19:16:13 -0400 Subject: [PATCH] Move some static functions into ScrubbingOptions --- src/AudioIO.cpp | 13 +++++++++---- src/AudioIO.h | 2 -- src/tracks/ui/Scrubbing.cpp | 6 +++--- src/tracks/ui/Scrubbing.h | 5 +++++ 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/AudioIO.cpp b/src/AudioIO.cpp index 293bde53e..d7f7347b3 100644 --- a/src/AudioIO.cpp +++ b/src/AudioIO.cpp @@ -571,7 +571,7 @@ private: maxed = true; } - if (speed < GetMinScrubSpeed()) + if (speed < ScrubbingOptions::MinAllowedScrubSpeed()) // Mixers were set up to go only so slowly, not slower. // This will put a request for some silence in the work queue. speed = 0.0; @@ -1604,7 +1604,8 @@ int AudioIO::StartStream(const WaveTrackArray &playbackTracks, if (mCaptureTracks->size() > 0 || mPlayMode == PLAY_LOOPED || mTimeTrack != NULL || - options.maxScrubSpeed < GetMinScrubSpeed()) + options.maxScrubSpeed < + ScrubbingOptions::MinAllowedScrubSpeed()) { wxASSERT(false); scrubbing = false; @@ -1750,9 +1751,13 @@ int AudioIO::StartStream(const WaveTrackArray &playbackTracks, const Mixer::WarpOptions &warpOptions = #ifdef EXPERIMENTAL_SCRUBBING_SUPPORT - scrubbing ? Mixer::WarpOptions(GetMinScrubSpeed(), GetMaxScrubSpeed()) : + scrubbing + ? Mixer::WarpOptions + (ScrubbingOptions::MinAllowedScrubSpeed(), + ScrubbingOptions::MaxAllowedScrubSpeed()) + : #endif - Mixer::WarpOptions(mTimeTrack); + Mixer::WarpOptions(mTimeTrack); for (unsigned int i = 0; i < mPlaybackTracks->size(); i++) { diff --git a/src/AudioIO.h b/src/AudioIO.h index ac48cab12..2d20dc17b 100644 --- a/src/AudioIO.h +++ b/src/AudioIO.h @@ -186,8 +186,6 @@ class AUDACITY_DLL_API AudioIO final { #ifdef EXPERIMENTAL_SCRUBBING_SUPPORT bool IsScrubbing() { return IsBusy() && mScrubQueue != 0; } - static double GetMaxScrubSpeed() { return 32.0; } // Is five octaves enough for your amusement? - static double GetMinScrubSpeed() { return 0.01; } /** \brief enqueue a NEW scrub play interval, using the last end as the new start, * to be played over the same duration, as between this and the last * enqueuing (or the starting of the stream). Except, we do not exceed maximum diff --git a/src/tracks/ui/Scrubbing.cpp b/src/tracks/ui/Scrubbing.cpp index 779b7a6b0..eac5ab689 100644 --- a/src/tracks/ui/Scrubbing.cpp +++ b/src/tracks/ui/Scrubbing.cpp @@ -314,7 +314,7 @@ bool Scrubber::MaybeStartScrubbing(wxCoord xx) // That idea seems unpopular... just make it one for move-scrub, // but big for drag-scrub mMaxScrubSpeed = options.maxScrubSpeed = - mDragging ? AudioIO::GetMaxScrubSpeed() : 1.0; + mDragging ? ScrubbingOptions::MaxAllowedScrubSpeed() : 1.0; #endif options.maxScrubTime = mProject->GetTracks()->GetEndTime(); ControlToolBar::PlayAppearance appearance = @@ -502,8 +502,8 @@ void Scrubber::HandleScrollWheel(int steps) static const double maxScrubSpeedBase = pow(2.0, 1.0 / ScrubSpeedStepsPerOctave); double newSpeed = pow(maxScrubSpeedBase, newLogMaxScrubSpeed); - if (newSpeed >= AudioIO::GetMinScrubSpeed() && - newSpeed <= AudioIO::GetMaxScrubSpeed()) { + if (newSpeed >= ScrubbingOptions::MinAllowedScrubSpeed() && + newSpeed <= ScrubbingOptions::MaxAllowedScrubSpeed()) { mLogMaxScrubSpeed = newLogMaxScrubSpeed; mMaxScrubSpeed = newSpeed; if (!mSmoothScrollingScrub) diff --git a/src/tracks/ui/Scrubbing.h b/src/tracks/ui/Scrubbing.h index 2da1fbf69..cd2e09926 100644 --- a/src/tracks/ui/Scrubbing.h +++ b/src/tracks/ui/Scrubbing.h @@ -28,6 +28,11 @@ struct ScrubbingOptions { bool adjustStart {}; bool enqueueBySpeed {}; + + static double MaxAllowedScrubSpeed() + { return 32.0; } // Is five octaves enough for your amusement? + static double MinAllowedScrubSpeed() + { return 0.01; } // Mixer needs a lower bound speed. Scrub no slower than this. }; // Scrub state object