mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-15 15:49:36 +02:00
Construction of default play options moved out of AudacityProject
This commit is contained in:
parent
0a109d2432
commit
ae18f2f220
@ -1620,7 +1620,7 @@ void AdornedRulerPanel::StartQPPlay(bool looped, bool cutPreview)
|
||||
// Looping a tiny selection may freeze, so just play it once.
|
||||
loopEnabled = ((end - start) > 0.001)? true : false;
|
||||
|
||||
AudioIOStartStreamOptions options(mProject->GetDefaultPlayOptions());
|
||||
auto options = DefaultPlayOptions( *mProject );
|
||||
options.playLooped = (loopEnabled && looped);
|
||||
|
||||
auto oldStart = mPlayRegionStart;
|
||||
|
@ -1348,31 +1348,29 @@ void AudacityProject::ApplyUpdatedTheme()
|
||||
trackPanel.ApplyUpdatedTheme();
|
||||
}
|
||||
|
||||
|
||||
AudioIOStartStreamOptions AudacityProject::GetDefaultPlayOptions()
|
||||
AudioIOStartStreamOptions
|
||||
DefaultPlayOptions( AudacityProject &project )
|
||||
{
|
||||
auto &project = *this;
|
||||
AudioIOStartStreamOptions options { GetRate() };
|
||||
AudioIOStartStreamOptions options { project.GetRate() };
|
||||
options.timeTrack = TrackList::Get( project ).GetTimeTrack();
|
||||
options.listener = this;
|
||||
options.listener = &project;
|
||||
return options;
|
||||
}
|
||||
|
||||
AudioIOStartStreamOptions AudacityProject::GetSpeedPlayOptions()
|
||||
AudioIOStartStreamOptions
|
||||
DefaultSpeedPlayOptions( AudacityProject &project )
|
||||
{
|
||||
auto &project = *this;
|
||||
auto PlayAtSpeedRate = gAudioIO->GetBestRate(
|
||||
false, //not capturing
|
||||
true, //is playing
|
||||
GetRate() //suggested rate
|
||||
project.GetRate() //suggested rate
|
||||
);
|
||||
AudioIOStartStreamOptions options{ PlayAtSpeedRate };
|
||||
options.timeTrack = TrackList::Get( project ).GetTimeTrack();
|
||||
options.listener = this;
|
||||
options.listener = &project;
|
||||
return options;
|
||||
}
|
||||
|
||||
|
||||
void AudacityProject::UpdatePrefsVariables()
|
||||
{
|
||||
gPrefs->Read(wxT("/AudioFiles/ShowId3Dialog"), &mShowId3Dialog, true);
|
||||
|
@ -185,9 +185,6 @@ class AUDACITY_DLL_API AudacityProject final : public wxFrame,
|
||||
|
||||
virtual void ApplyUpdatedTheme();
|
||||
|
||||
AudioIOStartStreamOptions GetDefaultPlayOptions();
|
||||
AudioIOStartStreamOptions GetSpeedPlayOptions();
|
||||
|
||||
sampleFormat GetDefaultFormat() { return mDefaultFormat; }
|
||||
|
||||
double GetRate() const { return mRate; }
|
||||
@ -644,5 +641,8 @@ public:
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
AudioIOStartStreamOptions DefaultPlayOptions( AudacityProject &project );
|
||||
AudioIOStartStreamOptions DefaultSpeedPlayOptions( AudacityProject &project );
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -3532,7 +3532,7 @@ void EffectUIHost::OnPlay(wxCommandEvent & WXUNUSED(evt))
|
||||
auto &bar = ControlToolBar::Get( *mProject );
|
||||
bar.PlayPlayRegion(
|
||||
SelectedRegion(mPlayPos, mRegion.t1()),
|
||||
mProject->GetDefaultPlayOptions(),
|
||||
DefaultPlayOptions( *mProject ),
|
||||
PlayMode::normalPlay );
|
||||
}
|
||||
}
|
||||
|
@ -601,7 +601,7 @@ void OnPunchAndRoll(const CommandContext &context)
|
||||
transportTracks.captureTracks = std::move(tracks);
|
||||
|
||||
// Try to start recording
|
||||
AudioIOStartStreamOptions options(project.GetDefaultPlayOptions());
|
||||
auto options = DefaultPlayOptions( project );
|
||||
options.preRoll = std::max(0L,
|
||||
gPrefs->Read(AUDIO_PRE_ROLL_KEY, DEFAULT_PRE_ROLL_SECONDS));
|
||||
options.pCrossfadeData = &crossfadeData;
|
||||
@ -705,7 +705,7 @@ void OnPlayOneSecond(const CommandContext &context)
|
||||
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
auto &controlToolBar = ControlToolBar::Get( project );
|
||||
auto options = project.GetDefaultPlayOptions();
|
||||
auto options = DefaultPlayOptions( project );
|
||||
|
||||
double pos = trackPanel.GetMostRecentXPos();
|
||||
controlToolBar.PlayPlayRegion(
|
||||
@ -758,7 +758,7 @@ void OnPlayToSelection(const CommandContext &context)
|
||||
// mLastPlayMode = ((t1-t0) > 1.0) ? normalPlay : oneSecondPlay;
|
||||
|
||||
auto &controlToolBar = ControlToolBar::Get( project );
|
||||
auto playOptions = project.GetDefaultPlayOptions();
|
||||
auto playOptions = DefaultPlayOptions( project );
|
||||
|
||||
controlToolBar.PlayPlayRegion(
|
||||
SelectedRegion(t0, t1), playOptions, PlayMode::oneSecondPlay);
|
||||
@ -782,7 +782,7 @@ void OnPlayBeforeSelectionStart(const CommandContext &context)
|
||||
gPrefs->Read(wxT("/AudioIO/CutPreviewBeforeLen"), &beforeLen, 2.0);
|
||||
|
||||
auto &controlToolBar = ControlToolBar::Get( project );
|
||||
auto playOptions = project.GetDefaultPlayOptions();
|
||||
auto playOptions = DefaultPlayOptions( project );
|
||||
|
||||
controlToolBar.PlayPlayRegion(
|
||||
SelectedRegion(t0 - beforeLen, t0), playOptions, PlayMode::oneSecondPlay);
|
||||
@ -804,7 +804,7 @@ void OnPlayAfterSelectionStart(const CommandContext &context)
|
||||
gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
|
||||
|
||||
auto &controlToolBar = ControlToolBar::Get( project );
|
||||
auto playOptions = project.GetDefaultPlayOptions();
|
||||
auto playOptions = DefaultPlayOptions( project );
|
||||
|
||||
if ( t1 - t0 > 0.0 && t1 - t0 < afterLen )
|
||||
controlToolBar.PlayPlayRegion(
|
||||
@ -831,7 +831,7 @@ void OnPlayBeforeSelectionEnd(const CommandContext &context)
|
||||
gPrefs->Read(wxT("/AudioIO/CutPreviewBeforeLen"), &beforeLen, 2.0);
|
||||
|
||||
auto &controlToolBar = ControlToolBar::Get( project );
|
||||
auto playOptions = project.GetDefaultPlayOptions();
|
||||
auto playOptions = DefaultPlayOptions( project );
|
||||
|
||||
if ( t1 - t0 > 0.0 && t1 - t0 < beforeLen )
|
||||
controlToolBar.PlayPlayRegion(
|
||||
@ -858,7 +858,7 @@ void OnPlayAfterSelectionEnd(const CommandContext &context)
|
||||
gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
|
||||
|
||||
auto &controlToolBar = ControlToolBar::Get( project );
|
||||
auto playOptions = project.GetDefaultPlayOptions();
|
||||
auto playOptions = DefaultPlayOptions( project );
|
||||
|
||||
controlToolBar.PlayPlayRegion(
|
||||
SelectedRegion(t1, t1 + afterLen), playOptions, PlayMode::oneSecondPlay);
|
||||
@ -883,7 +883,7 @@ void OnPlayBeforeAndAfterSelectionStart
|
||||
gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
|
||||
|
||||
auto &controlToolBar = ControlToolBar::Get( project );
|
||||
auto playOptions = project.GetDefaultPlayOptions();
|
||||
auto playOptions = DefaultPlayOptions( project );
|
||||
|
||||
if ( t1 - t0 > 0.0 && t1 - t0 < afterLen )
|
||||
controlToolBar.PlayPlayRegion(
|
||||
@ -914,7 +914,7 @@ void OnPlayBeforeAndAfterSelectionEnd
|
||||
gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
|
||||
|
||||
auto &controlToolBar = ControlToolBar::Get( project );
|
||||
auto playOptions = project.GetDefaultPlayOptions();
|
||||
auto playOptions = DefaultPlayOptions( project );
|
||||
|
||||
if ( t1 - t0 > 0.0 && t1 - t0 < beforeLen )
|
||||
controlToolBar.PlayPlayRegion(
|
||||
|
@ -769,7 +769,7 @@ void ControlToolBar::PlayCurrentRegion(bool looped /* = false */,
|
||||
double playRegionStart, playRegionEnd;
|
||||
p->GetPlayRegion(&playRegionStart, &playRegionEnd);
|
||||
|
||||
AudioIOStartStreamOptions options(p->GetDefaultPlayOptions());
|
||||
auto options = DefaultPlayOptions( *p );
|
||||
options.playLooped = looped;
|
||||
if (cutpreview)
|
||||
options.timeTrack = NULL;
|
||||
@ -1059,7 +1059,7 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
|
||||
}
|
||||
|
||||
transportTracks.captureTracks = existingTracks;
|
||||
AudioIOStartStreamOptions options(p->GetDefaultPlayOptions());
|
||||
auto options = DefaultPlayOptions( *p );
|
||||
DoRecord(*p, transportTracks, t0, t1, altAppearance, options);
|
||||
}
|
||||
}
|
||||
|
@ -494,7 +494,7 @@ void TranscriptionToolBar::PlayAtSpeed(bool looped, bool cutPreview)
|
||||
return;
|
||||
if (bFixedSpeedPlay)
|
||||
{
|
||||
AudioIOStartStreamOptions options(p->GetDefaultPlayOptions());
|
||||
auto options = DefaultPlayOptions( *p );
|
||||
options.playLooped = looped;
|
||||
// No need to set cutPreview options.
|
||||
options.timeTrack = mTimeTrack.get();
|
||||
|
@ -379,7 +379,8 @@ bool Scrubber::MaybeStartScrubbing(wxCoord xx)
|
||||
}
|
||||
#endif
|
||||
mSpeedPlaying = false;
|
||||
AudioIOStartStreamOptions options(mProject->GetDefaultPlayOptions());
|
||||
auto options =
|
||||
DefaultPlayOptions( *mProject );
|
||||
options.pScrubbingOptions = &mOptions;
|
||||
options.timeTrack = NULL;
|
||||
mOptions.delay = (ScrubPollInterval_ms / 1000.0);
|
||||
@ -479,7 +480,7 @@ bool Scrubber::StartSpeedPlay(double speed, double time0, double time1)
|
||||
mMaxSpeed = speed;
|
||||
mDragging = false;
|
||||
|
||||
AudioIOStartStreamOptions options(mProject->GetSpeedPlayOptions());
|
||||
auto options = DefaultSpeedPlayOptions( *mProject );
|
||||
options.pScrubbingOptions = &mOptions;
|
||||
options.timeTrack = NULL;
|
||||
mOptions.delay = (ScrubPollInterval_ms / 1000.0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user