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