17 double trackEndTime,
double loopEndTime, std::optional<double> pStartTime,
18 bool loopEnabled,
bool variableSpeed )
20 , mTrackEndTime{ trackEndTime }
21 , mLoopEndTime{ loopEndTime }
22 , mpStartTime{ pStartTime }
23 , mLoopEnabled{ loopEnabled }
24 , mVariableSpeed{ variableSpeed }
59 using namespace std::chrono;
60 return { 0.05s, 0.05s, 0.25s };
90 if (time < schedule.
mT0)
93 time = std::clamp(time + offset, schedule.
mT0, schedule.
mT1);
114 auto frames = available;
115 auto toProduce = frames;
118 if (deltat > realTimeRemaining) {
120 auto realTime = realTimeRemaining;
125 const double extraRealTime =
127 extra =
std::min( extraRealTime, deltat - realTimeRemaining );
141 frames = available, toProduce = 0;
143 return { available, frames, toProduce };
156 return { schedule.
mT1, schedule.
mT0 };
159 if ( fabs(schedule.
mT0 - schedule.
mT1) < 1e-9 )
160 return {schedule.
mT0, schedule.
mT0};
164 realDuration *= -1.0;
170 trackTime += realDuration;
172 return { trackTime, trackTime };
177 size_t frames,
size_t available )
182 bool speedChange =
false;
188 bool empty = (data.mT0 >= data.mT1);
193 constexpr auto allowance = 0.5;
209 auto theirs = std::tie(data.mT0, data.mT1);
215 schedule.
mT1 = data.mT1;
226 newTime = std::clamp(newTime, schedule.
mT0, schedule.
mT1);
230 newTime = schedule.
mT0;
239 else if (speedChange)
255 for (
auto &pMixer : playbackMixers)
256 pMixer->SetTimesAndSpeed(
264 for (
auto &pMixer : playbackMixers) {
267 pMixer->Reposition(time,
true);
282 region.GetStart(), region.GetEnd(), region.Active()
constexpr size_t TimeQueueGrainSize
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
PlaybackSlice GetPlaybackSlice(PlaybackSchedule &schedule, size_t available) override
Choose length of one fetch of samples from tracks in a call to AudioIO::FillPlayBuffers.
BufferTimes SuggestedBufferTimes(PlaybackSchedule &schedule) override
Provide hints for construction of playback RingBuffer objects.
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...
const double mTrackEndTime
void Initialize(PlaybackSchedule &schedule, double rate) override
Called before starting an audio stream.
MessageBuffer< SlotData > mMessageChannel
Observer::Subscription mSpeedSubscription
bool RevertToOldDefault(const PlaybackSchedule &schedule) const
Mixer::WarpOptions MixerWarpOptions(PlaybackSchedule &schedule) override
Options to use when constructing mixers for each playback track.
AudacityProject & mProject
std::optional< double > mpStartTime
~DefaultPlaybackPolicy() override
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.
Observer::Subscription mRegionSubscription
double OffsetSequenceTime(PlaybackSchedule &schedule, double offset) override
Called when the play head needs to jump a certain distance.
bool Looping(const PlaybackSchedule &) const override
DefaultPlaybackPolicy(AudacityProject &project, double trackEndTime, double loopEndTime, std::optional< double > pStartTime, bool loopEnabled, bool variableSpeed)
bool Done(PlaybackSchedule &schedule, unsigned long) override
Returns true if schedule.GetSequenceTime() has reached the end of playback.
MixerOptions::Warp WarpOptions
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
virtual std::pair< double, double > AdvancedTrackTime(PlaybackSchedule &schedule, double trackTime, size_t nSamples)
Compute a new point in a track's timeline from an old point and a real duration.
std::vector< std::unique_ptr< Mixer > > Mixers
virtual Mixer::WarpOptions MixerWarpOptions(PlaybackSchedule &schedule)
Options to use when constructing mixers for each playback track.
virtual void Initialize(PlaybackSchedule &schedule, double rate)
Called before starting an audio stream.
virtual bool RepositionPlayback(PlaybackSchedule &schedule, const Mixers &playbackMixers, size_t frames, size_t available)
AudioIO::FillPlayBuffers calls this to update its cursors into tracks for changes of position or spee...
double GetLastTime() const
Return the last time saved by Producer.
void SetLastTime(double time)
double GetPlaySpeed() const
static ProjectAudioIO & Get(AudacityProject &project)
static ViewInfo & Get(AudacityProject &project)
Positions or offsets within audio files need a wide type.
Immutable structure is an argument to Mixer's constructor.
double RealTimeRemaining() const
double mT0
Playback starts at offset of mT0, which is measured in seconds.
double mT1
Playback ends at offset of mT1, which is measured in seconds. Note that mT1 may be less than mT0 duri...
double SolveWarpedLength(double t0, double length) const
Compute how much unwarped time must have elapsed if length seconds of warped time has elapsed,...
bool ReversedTime() const
True if the end time is before the start time.
const BoundedEnvelope * mEnvelope
double RealDuration(double trackTime1) const
void RealTimeInit(double trackTime)
void RealTimeAdvance(double increment)
class AUDIO_IO_API PlaybackSchedule::TimeQueue mTimeQueue
double GetSequenceTime() const
Get current track time value, unadjusted.
Describes an amount of contiguous (but maybe time-warped) data to be extracted from tracks to play.