Audacity 3.2.0
|
The PlaybackPolicy used by Audacity for most playback. More...
#include <DefaultPlaybackPolicy.h>
Classes | |
struct | SlotData |
Public Member Functions | |
DefaultPlaybackPolicy (AudacityProject &project, double trackEndTime, double loopEndTime, std::optional< double > pStartTime, bool loopEnabled, bool variableSpeed) | |
~DefaultPlaybackPolicy () override | |
void | Initialize (PlaybackSchedule &schedule, double rate) override |
Called before starting an audio stream. More... | |
Mixer::WarpOptions | MixerWarpOptions (PlaybackSchedule &schedule) override |
Options to use when constructing mixers for each playback track. More... | |
BufferTimes | SuggestedBufferTimes (PlaybackSchedule &schedule) override |
Provide hints for construction of playback RingBuffer objects. More... | |
bool | Done (PlaybackSchedule &schedule, unsigned long) override |
Returns true if schedule.GetSequenceTime() has reached the end of playback. More... | |
double | OffsetSequenceTime (PlaybackSchedule &schedule, double offset) override |
Called when the play head needs to jump a certain distance. More... | |
PlaybackSlice | GetPlaybackSlice (PlaybackSchedule &schedule, size_t available) override |
Choose length of one fetch of samples from tracks in a call to AudioIO::FillPlayBuffers. More... | |
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. More... | |
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 speed. More... | |
bool | Looping (const PlaybackSchedule &) const override |
Public Member Functions inherited from PlaybackPolicy | |
virtual | ~PlaybackPolicy ()=0 |
virtual void | Initialize (PlaybackSchedule &schedule, double rate) |
Called before starting an audio stream. More... | |
virtual void | Finalize (PlaybackSchedule &schedule) |
Called after stopping of an audio stream or an unsuccessful start. More... | |
virtual Mixer::WarpOptions | MixerWarpOptions (PlaybackSchedule &schedule) |
Options to use when constructing mixers for each playback track. More... | |
virtual BufferTimes | SuggestedBufferTimes (PlaybackSchedule &schedule) |
Provide hints for construction of playback RingBuffer objects. More... | |
virtual bool | AllowSeek (PlaybackSchedule &schedule) |
Whether repositioning commands are allowed during playback. More... | |
virtual bool | Done (PlaybackSchedule &schedule, unsigned long outputFrames) |
Returns true if schedule.GetSequenceTime() has reached the end of playback. More... | |
virtual double | OffsetSequenceTime (PlaybackSchedule &schedule, double offset) |
Called when the play head needs to jump a certain distance. More... | |
virtual std::chrono::milliseconds | SleepInterval (PlaybackSchedule &schedule) |
How long to wait between calls to AudioIO::SequenceBufferExchange. More... | |
virtual PlaybackSlice | GetPlaybackSlice (PlaybackSchedule &schedule, size_t available) |
Choose length of one fetch of samples from tracks in a call to AudioIO::FillPlayBuffers. More... | |
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. More... | |
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 speed. More... | |
virtual bool | Looping (const PlaybackSchedule &schedule) const |
Private Member Functions | |
bool | RevertToOldDefault (const PlaybackSchedule &schedule) const |
void | WriteMessage () |
double | GetPlaySpeed () |
Private Attributes | |
AudacityProject & | mProject |
MessageBuffer< SlotData > | mMessageChannel |
Observer::Subscription | mRegionSubscription |
Observer::Subscription | mSpeedSubscription |
double | mLastPlaySpeed { 1.0 } |
const double | mTrackEndTime |
double | mLoopEndTime |
std::optional< double > | mpStartTime |
size_t | mRemaining { 0 } |
bool | mProgress { true } |
bool | mLoopEnabled { true } |
bool | mVariableSpeed { false } |
Additional Inherited Members | |
Public Types inherited from PlaybackPolicy | |
using | Duration = std::chrono::duration< double > |
using | Mixers = std::vector< std::unique_ptr< Mixer > > |
Protected Attributes inherited from PlaybackPolicy | |
double | mRate = 0 |
The PlaybackPolicy used by Audacity for most playback.
It subscribes to messages from ViewInfo and PlayRegion for loop bounds adjustment. Therefore it is not a low-level class that can be defined with the playback engine.
Definition at line 20 of file DefaultPlaybackPolicy.h.
DefaultPlaybackPolicy::DefaultPlaybackPolicy | ( | AudacityProject & | project, |
double | trackEndTime, | ||
double | loopEndTime, | ||
std::optional< double > | pStartTime, | ||
bool | loopEnabled, | ||
bool | variableSpeed | ||
) |
Definition at line 16 of file DefaultPlaybackPolicy.cpp.
|
overridedefault |
|
overridevirtual |
Compute a new point in a track's timeline from an old point and a real duration.
Needed because playback might be at non-unit speed.
Called one or more times between GetPlaybackSlice and RepositionPlayback, until the sum of the nSamples values equals the most recent playback slice (including any trailing silence).
Reimplemented from PlaybackPolicy.
Definition at line 146 of file DefaultPlaybackPolicy.cpp.
References PlaybackPolicy::AdvancedTrackTime(), PlaybackSchedule::mEnvelope, min(), mLastPlaySpeed, PlaybackPolicy::mRate, mRemaining, PlaybackSchedule::mT0, PlaybackSchedule::mT1, mVariableSpeed, PlaybackSchedule::ReversedTime(), RevertToOldDefault(), and PlaybackSchedule::SolveWarpedLength().
|
overridevirtual |
Returns true if schedule.GetSequenceTime() has reached the end of playback.
outputFrames | how many playback frames were taken from RingBuffers |
Reimplemented from PlaybackPolicy.
Definition at line 70 of file DefaultPlaybackPolicy.cpp.
References PlaybackSchedule::GetSequenceTime(), PlaybackPolicy::mRate, PlaybackSchedule::mT1, PlaybackSchedule::ReversedTime(), and RevertToOldDefault().
|
overridevirtual |
Choose length of one fetch of samples from tracks in a call to AudioIO::FillPlayBuffers.
available | upper bound for the length of the fetch |
Reimplemented from PlaybackPolicy.
Definition at line 107 of file DefaultPlaybackPolicy.cpp.
References min(), mLastPlaySpeed, PlaybackPolicy::mRate, mRemaining, PlaybackSchedule::mWarpedTime, PlaybackSchedule::RealTimeAdvance(), PlaybackSchedule::RealTimeRemaining(), RevertToOldDefault(), and TimeQueueGrainSize.
|
private |
Definition at line 286 of file DefaultPlaybackPolicy.cpp.
References ProjectAudioIO::Get(), ProjectAudioIO::GetPlaySpeed(), mProject, and mVariableSpeed.
Referenced by Initialize(), MixerWarpOptions(), and WriteMessage().
|
overridevirtual |
Called before starting an audio stream.
Reimplemented from PlaybackPolicy.
Definition at line 29 of file DefaultPlaybackPolicy.cpp.
References ProjectAudioIO::Get(), ViewInfo::Get(), GetPlaySpeed(), PlaybackPolicy::Initialize(), mLastPlaySpeed, mLoopEnabled, mLoopEndTime, mMessageChannel, mProject, mRegionSubscription, mSpeedSubscription, PlaybackSchedule::mT0, mVariableSpeed, ViewInfo::playRegion, Observer::Publisher< Message, NotifyAll >::Subscribe(), and WriteMessage().
|
overridevirtual |
Reimplemented from PlaybackPolicy.
Definition at line 273 of file DefaultPlaybackPolicy.cpp.
References mLoopEnabled.
|
overridevirtual |
Options to use when constructing mixers for each playback track.
Reimplemented from PlaybackPolicy.
Definition at line 44 of file DefaultPlaybackPolicy.cpp.
References GetPlaySpeed(), PlaybackPolicy::MixerWarpOptions(), and mVariableSpeed.
|
overridevirtual |
Called when the play head needs to jump a certain distance.
offset | signed amount requested to be added to schedule::GetSequenceTime() |
Reimplemented from PlaybackPolicy.
Definition at line 82 of file DefaultPlaybackPolicy.cpp.
References PlaybackSchedule::GetSequenceTime(), mLoopEnabled, mpStartTime, PlaybackSchedule::mT0, PlaybackSchedule::mT1, and PlaybackSchedule::RealTimeInit().
|
overridevirtual |
AudioIO::FillPlayBuffers calls this to update its cursors into tracks for changes of position or speed.
frames | how many samples were just now buffered for play |
available | how many more samples may be buffered |
Reimplemented from PlaybackPolicy.
Definition at line 175 of file DefaultPlaybackPolicy.cpp.
References PlaybackSchedule::TimeQueue::GetLastTime(), mLastPlaySpeed, mLoopEnabled, mLoopEndTime, mMessageChannel, PlaybackPolicy::mRate, mRemaining, PlaybackSchedule::mT0, PlaybackSchedule::mT1, PlaybackSchedule::mTimeQueue, mTrackEndTime, mVariableSpeed, PlaybackSchedule::mWarpedLength, PlaybackSchedule::RealDuration(), PlaybackSchedule::RealTimeInit(), PlaybackSchedule::RealTimeRemaining(), PlaybackSchedule::RealTimeRestart(), PlaybackPolicy::RepositionPlayback(), RevertToOldDefault(), and PlaybackSchedule::TimeQueue::SetLastTime().
|
private |
Definition at line 63 of file DefaultPlaybackPolicy.cpp.
References PlaybackSchedule::TimeQueue::GetLastTime(), mLoopEnabled, mLoopEndTime, and PlaybackSchedule::mTimeQueue.
Referenced by AdvancedTrackTime(), Done(), GetPlaybackSlice(), and RepositionPlayback().
|
overridevirtual |
Provide hints for construction of playback RingBuffer objects.
Reimplemented from PlaybackPolicy.
Definition at line 55 of file DefaultPlaybackPolicy.cpp.
|
private |
Definition at line 278 of file DefaultPlaybackPolicy.cpp.
References ViewInfo::Get(), GetPlaySpeed(), mMessageChannel, mProject, and ViewInfo::playRegion.
Referenced by Initialize().
|
private |
Definition at line 73 of file DefaultPlaybackPolicy.h.
Referenced by AdvancedTrackTime(), GetPlaybackSlice(), Initialize(), and RepositionPlayback().
|
private |
Definition at line 79 of file DefaultPlaybackPolicy.h.
Referenced by Initialize(), Looping(), OffsetSequenceTime(), RepositionPlayback(), and RevertToOldDefault().
|
private |
Definition at line 75 of file DefaultPlaybackPolicy.h.
Referenced by Initialize(), RepositionPlayback(), and RevertToOldDefault().
|
private |
Definition at line 68 of file DefaultPlaybackPolicy.h.
Referenced by Initialize(), RepositionPlayback(), and WriteMessage().
|
private |
Definition at line 78 of file DefaultPlaybackPolicy.h.
|
private |
Definition at line 58 of file DefaultPlaybackPolicy.h.
Referenced by GetPlaySpeed(), Initialize(), and WriteMessage().
|
private |
Definition at line 76 of file DefaultPlaybackPolicy.h.
Referenced by OffsetSequenceTime().
|
private |
Definition at line 70 of file DefaultPlaybackPolicy.h.
Referenced by Initialize().
|
private |
Definition at line 77 of file DefaultPlaybackPolicy.h.
Referenced by AdvancedTrackTime(), GetPlaybackSlice(), and RepositionPlayback().
|
private |
Definition at line 71 of file DefaultPlaybackPolicy.h.
Referenced by Initialize().
|
private |
Definition at line 74 of file DefaultPlaybackPolicy.h.
Referenced by RepositionPlayback().
|
private |
Definition at line 80 of file DefaultPlaybackPolicy.h.
Referenced by AdvancedTrackTime(), GetPlaySpeed(), Initialize(), MixerWarpOptions(), and RepositionPlayback().