mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-01 08:09:41 +02:00
Fixes for the "bounce" at start of scrub
This commit is contained in:
commit
de88c98a4b
@ -524,11 +524,10 @@ constexpr size_t TimeQueueGrainSize = 2000;
|
||||
|
||||
struct AudioIO::ScrubState
|
||||
{
|
||||
ScrubState(double t0, wxLongLong startClockMillis,
|
||||
ScrubState(double t0,
|
||||
double rate,
|
||||
const ScrubbingOptions &options)
|
||||
: mRate(rate)
|
||||
, mLastScrubTimeMillis(startClockMillis)
|
||||
, mStartTime( t0 )
|
||||
{
|
||||
const double t1 = options.bySpeed ? 1.0 : t0;
|
||||
@ -778,7 +777,17 @@ private:
|
||||
};
|
||||
|
||||
struct Duration {
|
||||
Duration (ScrubState &queue_) : queue(queue_) {}
|
||||
Duration (ScrubState &queue_) : queue(queue_)
|
||||
{
|
||||
do {
|
||||
clockTime = ::wxGetLocalTimeMillis();
|
||||
duration = static_cast<long long>(
|
||||
queue.mRate *
|
||||
(clockTime - queue.mLastScrubTimeMillis).ToDouble()
|
||||
/ 1000.0
|
||||
);
|
||||
} while( duration <= 0 && (::wxMilliSleep(1), true) );
|
||||
}
|
||||
~Duration ()
|
||||
{
|
||||
if(!cancelled)
|
||||
@ -788,10 +797,8 @@ private:
|
||||
void Cancel() { cancelled = true; }
|
||||
|
||||
ScrubState &queue;
|
||||
const wxLongLong clockTime { ::wxGetLocalTimeMillis() };
|
||||
const sampleCount duration { static_cast<long long>
|
||||
(queue.mRate * (clockTime - queue.mLastScrubTimeMillis).ToDouble() / 1000.0)
|
||||
};
|
||||
wxLongLong clockTime;
|
||||
sampleCount duration;
|
||||
bool cancelled { false };
|
||||
};
|
||||
|
||||
@ -800,7 +807,7 @@ private:
|
||||
std::atomic<bool> mStopped { false };
|
||||
Data mData;
|
||||
const double mRate;
|
||||
wxLongLong mLastScrubTimeMillis;
|
||||
wxLongLong mLastScrubTimeMillis{ ::wxGetLocalTimeMillis() };
|
||||
struct Message {
|
||||
double end;
|
||||
ScrubbingOptions options;
|
||||
@ -1958,7 +1965,6 @@ int AudioIO::StartStream(const TransportTracks &tracks,
|
||||
mScrubState =
|
||||
std::make_unique<ScrubState>(
|
||||
mPlaybackSchedule.mT0,
|
||||
scrubOptions.startClockTimeMillis,
|
||||
mRate,
|
||||
scrubOptions);
|
||||
mScrubDuration = 0;
|
||||
@ -1981,7 +1987,7 @@ int AudioIO::StartStream(const TransportTracks &tracks,
|
||||
// execute too much else
|
||||
if (mScrubState) {
|
||||
mOwningProject->GetScrubber().ContinueScrubbingPoll();
|
||||
wxMilliSleep( Scrubber::ScrubPollInterval_ms );
|
||||
wxMilliSleep( Scrubber::ScrubPollInterval_ms * 0.9 );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
@ -51,7 +51,9 @@ enum {
|
||||
ScrubSpeedStepsPerOctave = 4,
|
||||
#endif
|
||||
|
||||
kOneSecondCountdown = 1000 / Scrubber::ScrubPollInterval_ms,
|
||||
ScrubPollInterval_ms = 50,
|
||||
|
||||
kOneSecondCountdown = 1000 / ScrubPollInterval_ms,
|
||||
};
|
||||
|
||||
static const double MinStutter = 0.2;
|
||||
@ -297,7 +299,6 @@ void Scrubber::MarkScrubStart(
|
||||
|
||||
mScrubStartPosition = xx;
|
||||
ctb->UpdateStatusBar(mProject);
|
||||
mOptions.startClockTimeMillis = ::wxGetLocalTimeMillis();
|
||||
mCancelled = false;
|
||||
}
|
||||
|
||||
@ -424,7 +425,7 @@ bool Scrubber::MaybeStartScrubbing(wxCoord xx)
|
||||
}
|
||||
else
|
||||
// Wait to test again
|
||||
mOptions.startClockTimeMillis = ::wxGetLocalTimeMillis();
|
||||
;
|
||||
|
||||
if (IsScrubbing()) {
|
||||
mLastScrubPosition = xx;
|
||||
@ -462,7 +463,6 @@ bool Scrubber::StartSpeedPlay(double speed, double time0, double time1)
|
||||
AudioIOStartStreamOptions options(mProject->GetSpeedPlayOptions());
|
||||
options.pScrubbingOptions = &mOptions;
|
||||
options.timeTrack = NULL;
|
||||
mOptions.startClockTimeMillis = ::wxGetLocalTimeMillis();
|
||||
mOptions.delay = (ScrubPollInterval_ms * 0.9 / 1000.0);
|
||||
mOptions.minSpeed = speed -0.01;
|
||||
mOptions.maxSpeed = speed +0.01;
|
||||
@ -634,7 +634,7 @@ void Scrubber::StartPolling()
|
||||
mpThread->Run();
|
||||
#endif
|
||||
|
||||
mPoller->Start(ScrubPollInterval_ms);
|
||||
mPoller->Start(ScrubPollInterval_ms * 0.9);
|
||||
}
|
||||
|
||||
void Scrubber::StopPolling()
|
||||
|
@ -58,10 +58,6 @@ struct ScrubbingOptions {
|
||||
// this is the minimum amount of playback allowed at the maximum speed:
|
||||
double minStutterTime {};
|
||||
|
||||
// Scrubbing needs the time of start of the mouse movement that began
|
||||
// the scrub:
|
||||
wxLongLong startClockTimeMillis { -1 };
|
||||
|
||||
static double MaxAllowedScrubSpeed()
|
||||
{ return 32.0; } // Is five octaves enough for your amusement?
|
||||
static double MinAllowedScrubSpeed()
|
||||
|
Loading…
x
Reference in New Issue
Block a user