Audacity 3.2.0
ScrubState.h
Go to the documentation of this file.
1/*!********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file ScrubState.h
6
7 Paul Licameli split from AudioIO.cpp
8
9 **********************************************************************/
10
11#ifndef __AUDACITY_SCRUB_STATE__
12#define __AUDACITY_SCRUB_STATE__
13
14#include "PlaybackSchedule.h" // to inherit
15#include "SampleCount.h"
16
17// For putting an increment of work in the scrubbing queue
20
21 bool adjustStart {};
22
23 // usually from TrackList::GetEndTime()
24 double maxTime {};
25 double minTime {};
26
27 bool bySpeed {};
29
31
32 // Initial and limiting values for the speed of a scrub interval:
33 double initSpeed { 1.0 };
34 double minSpeed { 0.0 };
35 double maxSpeed { 1.0 };
36
37
38 // When maximum speed scrubbing skips to follow the mouse,
39 // this is the minimum amount of playback allowed at the maximum speed:
41
42 static double MaxAllowedScrubSpeed()
43 { return 32.0; } // Is five octaves enough for your amusement?
44 static double MinAllowedScrubSpeed()
45 { return 0.01; } // Mixer needs a lower bound speed. Scrub no slower than this.
46};
47
49public:
52
53 void Initialize( PlaybackSchedule &schedule, double rate ) override;
54 void Finalize( PlaybackSchedule &schedule ) override;
55
57
59
60 bool AllowSeek( PlaybackSchedule & ) override;
61
62 std::chrono::milliseconds
63 SleepInterval( PlaybackSchedule & ) override;
64
65 bool Done( PlaybackSchedule &schedule, unsigned long ) override;
66
68 PlaybackSchedule &schedule, size_t available) override;
69
70 std::pair<double, double>
72 double trackTime, size_t nSamples ) override;
73
75 PlaybackSchedule &schedule, const Mixers &playbackMixers,
76 size_t frames,
77 size_t available
78 ) override;
79
80private:
82 double mOldEndTime{ 0 }, mNewStartTime{ 0 };
83 double mScrubSpeed{ 0 };
84 bool mSilentScrub{ false };
85 bool mReplenish{ false };
87
89};
90
92{
93 static bool IsScrubbing();
94
100 static void UpdateScrub(double endTimeOrSpeed, const ScrubbingOptions &options);
101
102 static void StopScrub();
103
106 static double GetLastScrubTime();
107};
108
109static constexpr auto ScrubPollInterval = std::chrono::milliseconds{50};
110
111#endif
static constexpr auto ScrubPollInterval
Definition: ScrubState.h:109
Directs which parts of tracks to fetch for playback.
std::vector< std::unique_ptr< Mixer > > Mixers
std::chrono::duration< double > Duration
const ScrubbingOptions mOptions
Definition: ScrubState.h:88
std::chrono::milliseconds SleepInterval(PlaybackSchedule &) override
How long to wait between calls to AudioIO::SequenceBufferExchange.
Definition: ScrubState.cpp:359
BufferTimes SuggestedBufferTimes(PlaybackSchedule &schedule) override
Provide hints for construction of playback RingBuffer objects.
Definition: ScrubState.cpp:325
void Finalize(PlaybackSchedule &schedule) override
Called after stopping of an audio stream or an unsuccessful start.
Definition: ScrubState.cpp:312
bool Done(PlaybackSchedule &schedule, unsigned long) override
Returns true if schedule.GetSequenceTime() has reached the end of playback.
Definition: ScrubState.cpp:352
bool RepositionPlayback(PlaybackSchedule &schedule, const Mixers &playbackMixers, size_t frames, size_t available) override
AudioIO::FillPlayBuffers calls this to update its cursors into tracks for changes of position or spee...
Definition: ScrubState.cpp:416
sampleCount mEndSample
Definition: ScrubState.h:81
~ScrubbingPlaybackPolicy() override
sampleCount mStartSample
Definition: ScrubState.h:81
sampleCount mScrubDuration
Definition: ScrubState.h:81
PlaybackSlice GetPlaybackSlice(PlaybackSchedule &schedule, size_t available) override
Choose length of one fetch of samples from tracks in a call to AudioIO::FillPlayBuffers.
Definition: ScrubState.cpp:364
ScrubbingPlaybackPolicy(const ScrubbingOptions &)
Definition: ScrubState.cpp:293
Mixer::WarpOptions MixerWarpOptions(PlaybackSchedule &schedule) override
Options to use when constructing mixers for each playback track.
Definition: ScrubState.cpp:317
bool AllowSeek(PlaybackSchedule &) override
Whether repositioning commands are allowed during playback.
Definition: ScrubState.cpp:346
std::pair< double, double > AdvancedTrackTime(PlaybackSchedule &schedule, double trackTime, size_t nSamples) override
Compute a new point in a track's timeline from an old point and a real duration.
Definition: ScrubState.cpp:402
void Initialize(PlaybackSchedule &schedule, double rate) override
Called before starting an audio stream.
Definition: ScrubState.cpp:300
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
Immutable structure is an argument to Mixer's constructor.
Definition: MixerOptions.h:56
Times are in seconds.
Describes an amount of contiguous (but maybe time-warped) data to be extracted from tracks to play.
static void StopScrub()
Definition: ScrubState.cpp:469
static bool IsScrubbing()
Definition: ScrubState.cpp:482
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
PlaybackPolicy::Duration minStutterTime
Definition: ScrubState.h:40
bool isKeyboardScrubbing
Definition: ScrubState.h:28
PlaybackPolicy::Duration delay
Definition: ScrubState.h:30
static double MinAllowedScrubSpeed()
Definition: ScrubState.h:44
static double MaxAllowedScrubSpeed()
Definition: ScrubState.h:42
double initSpeed
Definition: ScrubState.h:33