1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-16 08:34:10 +02:00

Bug1342: Loop-play (and other things) before scrub (and other things)...

... should not disable auto-scrolling of the window during playback.
This commit is contained in:
Paul Licameli 2016-04-18 17:50:17 -04:00
parent a3a5a243c2
commit d5915491b3
10 changed files with 37 additions and 41 deletions

View File

@ -2076,9 +2076,9 @@ void AudacityProject::OnPlayOneSecond()
return; return;
double pos = mTrackPanel->GetMostRecentXPos(); double pos = mTrackPanel->GetMostRecentXPos();
mLastPlayMode = oneSecondPlay;
GetControlToolBar()->PlayPlayRegion GetControlToolBar()->PlayPlayRegion
(SelectedRegion(pos - 0.5, pos + 0.5), GetDefaultPlayOptions()); (SelectedRegion(pos - 0.5, pos + 0.5), GetDefaultPlayOptions(),
PlayMode::oneSecondPlay);
} }
@ -2115,14 +2115,13 @@ void AudacityProject::OnPlayToSelection()
// where the cursor is. // where the cursor is.
// TODO: have 'playing attributes' such as 'with_autoscroll' // TODO: have 'playing attributes' such as 'with_autoscroll'
// rather than modes, since that's how we're now using the modes. // rather than modes, since that's how we're now using the modes.
mLastPlayMode = oneSecondPlay;
// An alternative, commented out below, is to disable autoscroll // An alternative, commented out below, is to disable autoscroll
// only when playing a short region, less than or equal to a second. // only when playing a short region, less than or equal to a second.
// mLastPlayMode = ((t1-t0) > 1.0) ? normalPlay : oneSecondPlay; // mLastPlayMode = ((t1-t0) > 1.0) ? normalPlay : oneSecondPlay;
GetControlToolBar()->PlayPlayRegion GetControlToolBar()->PlayPlayRegion
(SelectedRegion(t0, t1), GetDefaultPlayOptions()); (SelectedRegion(t0, t1), GetDefaultPlayOptions(), PlayMode::oneSecondPlay);
} }
// The next 4 functions provide a limited version of the // The next 4 functions provide a limited version of the
@ -2137,9 +2136,7 @@ void AudacityProject::OnPlayBeforeSelectionStart()
double beforeLen; double beforeLen;
gPrefs->Read(wxT("/AudioIO/CutPreviewBeforeLen"), &beforeLen, 2.0); gPrefs->Read(wxT("/AudioIO/CutPreviewBeforeLen"), &beforeLen, 2.0);
mLastPlayMode = oneSecondPlay; // this disables auto scrolling, as in OnPlayToSelection() GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0 - beforeLen, t0), GetDefaultPlayOptions(), PlayMode::oneSecondPlay);
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0 - beforeLen, t0), GetDefaultPlayOptions());
} }
void AudacityProject::OnPlayAfterSelectionStart() void AudacityProject::OnPlayAfterSelectionStart()
@ -2152,12 +2149,11 @@ void AudacityProject::OnPlayAfterSelectionStart()
double afterLen; double afterLen;
gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0); gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
mLastPlayMode = oneSecondPlay; // this disables auto scrolling, as in OnPlayToSelection()
if ( t1 - t0 > 0.0 && t1 - t0 < afterLen ) if ( t1 - t0 > 0.0 && t1 - t0 < afterLen )
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0, t1), GetDefaultPlayOptions()); GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0, t1), GetDefaultPlayOptions(),
PlayMode::oneSecondPlay);
else else
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0, t0 + afterLen), GetDefaultPlayOptions()); GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0, t0 + afterLen), GetDefaultPlayOptions(), PlayMode::oneSecondPlay);
} }
void AudacityProject::OnPlayBeforeSelectionEnd() void AudacityProject::OnPlayBeforeSelectionEnd()
@ -2170,12 +2166,11 @@ void AudacityProject::OnPlayBeforeSelectionEnd()
double beforeLen; double beforeLen;
gPrefs->Read(wxT("/AudioIO/CutPreviewBeforeLen"), &beforeLen, 2.0); gPrefs->Read(wxT("/AudioIO/CutPreviewBeforeLen"), &beforeLen, 2.0);
mLastPlayMode = oneSecondPlay; // this disables auto scrolling, as in OnPlayToSelection()
if ( t1 - t0 > 0.0 && t1 - t0 < beforeLen ) if ( t1 - t0 > 0.0 && t1 - t0 < beforeLen )
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0, t1), GetDefaultPlayOptions()); GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0, t1), GetDefaultPlayOptions(),
PlayMode::oneSecondPlay);
else else
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t1 - beforeLen, t1), GetDefaultPlayOptions()); GetControlToolBar()->PlayPlayRegion(SelectedRegion(t1 - beforeLen, t1), GetDefaultPlayOptions(), PlayMode::oneSecondPlay);
} }
@ -2188,9 +2183,7 @@ void AudacityProject::OnPlayAfterSelectionEnd()
double afterLen; double afterLen;
gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0); gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
mLastPlayMode = oneSecondPlay; // this disables auto scrolling, as in OnPlayToSelection() GetControlToolBar()->PlayPlayRegion(SelectedRegion(t1, t1 + afterLen), GetDefaultPlayOptions(), PlayMode::oneSecondPlay);
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t1, t1 + afterLen), GetDefaultPlayOptions());
} }
void AudacityProject::OnPlayBeforeAndAfterSelectionStart() void AudacityProject::OnPlayBeforeAndAfterSelectionStart()
@ -2205,12 +2198,10 @@ void AudacityProject::OnPlayBeforeAndAfterSelectionStart()
double afterLen; double afterLen;
gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0); gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
mLastPlayMode = oneSecondPlay; // this disables auto scrolling, as in OnPlayToSelection()
if ( t1 - t0 > 0.0 && t1 - t0 < afterLen ) if ( t1 - t0 > 0.0 && t1 - t0 < afterLen )
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0 - beforeLen, t1), GetDefaultPlayOptions()); GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0 - beforeLen, t1), GetDefaultPlayOptions(), PlayMode::oneSecondPlay);
else else
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0 - beforeLen, t0 + afterLen), GetDefaultPlayOptions()); GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0 - beforeLen, t0 + afterLen), GetDefaultPlayOptions(), PlayMode::oneSecondPlay);
} }
void AudacityProject::OnPlayBeforeAndAfterSelectionEnd() void AudacityProject::OnPlayBeforeAndAfterSelectionEnd()
@ -2225,12 +2216,10 @@ void AudacityProject::OnPlayBeforeAndAfterSelectionEnd()
double afterLen; double afterLen;
gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0); gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
mLastPlayMode = oneSecondPlay; // this disables auto scrolling, as in OnPlayToSelection()
if ( t1 - t0 > 0.0 && t1 - t0 < beforeLen ) if ( t1 - t0 > 0.0 && t1 - t0 < beforeLen )
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0, t1 + afterLen), GetDefaultPlayOptions()); GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0, t1 + afterLen), GetDefaultPlayOptions(), PlayMode::oneSecondPlay);
else else
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t1 - beforeLen, t1 + afterLen), GetDefaultPlayOptions()); GetControlToolBar()->PlayPlayRegion(SelectedRegion(t1 - beforeLen, t1 + afterLen), GetDefaultPlayOptions(), PlayMode::oneSecondPlay);
} }

View File

@ -1723,7 +1723,7 @@ void MixerBoard::OnTimer(wxCommandEvent &event)
if (mProject->IsAudioActive()) if (mProject->IsAudioActive())
{ {
UpdateMeters(gAudioIO->GetStreamTime(), UpdateMeters(gAudioIO->GetStreamTime(),
(mProject->mLastPlayMode == loopedPlay)); (mProject->mLastPlayMode == PlayMode::loopedPlay));
} }
// Let other listeners get the notification // Let other listeners get the notification

View File

@ -117,10 +117,10 @@ extern AProjectArray gAudacityProjects;
WX_DEFINE_ARRAY(wxMenu *, MenuArray); WX_DEFINE_ARRAY(wxMenu *, MenuArray);
enum PlayMode { enum class PlayMode : int {
normalPlay, normalPlay,
oneSecondPlay, oneSecondPlay, // Disables auto-scrolling
loopedPlay loopedPlay // Disables auto-scrolling
}; };
enum StatusBarField { enum StatusBarField {
@ -494,7 +494,7 @@ public:
void WriteXMLHeader(XMLWriter &xmlFile); void WriteXMLHeader(XMLWriter &xmlFile);
PlayMode mLastPlayMode{ normalPlay }; PlayMode mLastPlayMode{ PlayMode::normalPlay };
ViewInfo mViewInfo; ViewInfo mViewInfo;
// Audio IO callback methods // Audio IO callback methods

View File

@ -3429,7 +3429,7 @@ void EffectUIHost::OnPlay(wxCommandEvent & WXUNUSED(evt))
mProject->GetControlToolBar()->PlayPlayRegion mProject->GetControlToolBar()->PlayPlayRegion
(SelectedRegion(mPlayPos, mRegion.t1()), (SelectedRegion(mPlayPos, mRegion.t1()),
mProject->GetDefaultPlayOptions()); mProject->GetDefaultPlayOptions(), PlayMode::normalPlay);
} }
} }

View File

@ -475,6 +475,7 @@ bool ControlToolBar::IsRecordDown()
int ControlToolBar::PlayPlayRegion(const SelectedRegion &selectedRegion, int ControlToolBar::PlayPlayRegion(const SelectedRegion &selectedRegion,
const AudioIOStartStreamOptions &options, const AudioIOStartStreamOptions &options,
PlayMode mode,
bool cutpreview, /* = false */ bool cutpreview, /* = false */
bool backwards, /* = false */ bool backwards, /* = false */
bool playWhiteSpace /* = false */) bool playWhiteSpace /* = false */)
@ -518,6 +519,8 @@ int ControlToolBar::PlayPlayRegion(const SelectedRegion &selectedRegion,
return -1; // Should never happen, but... return -1; // Should never happen, but...
} }
p->mLastPlayMode = mode;
bool hasaudio = false; bool hasaudio = false;
TrackListIterator iter(t); TrackListIterator iter(t);
for (Track *trk = iter.First(); trk; trk = iter.Next()) { for (Track *trk = iter.First(); trk; trk = iter.Next()) {
@ -673,10 +676,6 @@ void ControlToolBar::PlayCurrentRegion(bool looped /* = false */,
if (p) if (p)
{ {
if (looped)
p->mLastPlayMode = loopedPlay;
else
p->mLastPlayMode = normalPlay;
double playRegionStart, playRegionEnd; double playRegionStart, playRegionEnd;
p->GetPlayRegion(&playRegionStart, &playRegionEnd); p->GetPlayRegion(&playRegionStart, &playRegionEnd);
@ -686,7 +685,9 @@ void ControlToolBar::PlayCurrentRegion(bool looped /* = false */,
if (cutpreview) if (cutpreview)
options.timeTrack = NULL; options.timeTrack = NULL;
PlayPlayRegion(SelectedRegion(playRegionStart, playRegionEnd), PlayPlayRegion(SelectedRegion(playRegionStart, playRegionEnd),
options, cutpreview); options,
(looped ? PlayMode::loopedPlay : PlayMode::normalPlay),
cutpreview);
} }
} }

View File

@ -34,6 +34,9 @@ class TimeTrack;
struct AudioIOStartStreamOptions; struct AudioIOStartStreamOptions;
class SelectedRegion; class SelectedRegion;
// Defined in Project.h
enum class PlayMode : int;
// In the GUI, ControlToolBar appears as the "Transport Toolbar". "Control Toolbar" is historic. // In the GUI, ControlToolBar appears as the "Transport Toolbar". "Control Toolbar" is historic.
class ControlToolBar final : public ToolBar { class ControlToolBar final : public ToolBar {
@ -74,6 +77,7 @@ class ControlToolBar final : public ToolBar {
// Return the Audio IO token or -1 for failure // Return the Audio IO token or -1 for failure
int PlayPlayRegion(const SelectedRegion &selectedRegion, int PlayPlayRegion(const SelectedRegion &selectedRegion,
const AudioIOStartStreamOptions &options, const AudioIOStartStreamOptions &options,
PlayMode playMode,
bool cutpreview = false, bool backwards = false, bool cutpreview = false, bool backwards = false,
// Allow t0 and t1 to be beyond end of tracks // Allow t0 and t1 to be beyond end of tracks
bool playWhiteSpace = false); bool playWhiteSpace = false);

View File

@ -462,6 +462,7 @@ void TranscriptionToolBar::PlayAtSpeed(bool looped, bool cutPreview)
p->GetControlToolBar()->PlayPlayRegion p->GetControlToolBar()->PlayPlayRegion
(SelectedRegion(playRegionStart, playRegionEnd), (SelectedRegion(playRegionStart, playRegionEnd),
options, options,
PlayMode::normalPlay,
cutPreview); cutPreview);
} }
} }

View File

@ -132,8 +132,8 @@ void PlayIndicatorOverlay::OnTimer(wxCommandEvent &event)
// BG: Scroll screen if option is set // BG: Scroll screen if option is set
// msmeyer: But only if not playing looped or in one-second mode // msmeyer: But only if not playing looped or in one-second mode
if (viewInfo.bUpdateTrackIndicator && if (viewInfo.bUpdateTrackIndicator &&
mProject->mLastPlayMode != loopedPlay && mProject->mLastPlayMode != PlayMode::loopedPlay &&
mProject->mLastPlayMode != oneSecondPlay && mProject->mLastPlayMode != PlayMode::oneSecondPlay &&
playPos >= 0 && playPos >= 0 &&
!onScreen && !onScreen &&
!gAudioIO->IsPaused()) !gAudioIO->IsPaused())

View File

@ -216,7 +216,8 @@ bool Scrubber::MaybeStartScrubbing(const wxMouseEvent &event)
#endif #endif
mScrubSpeedDisplayCountdown = 0; mScrubSpeedDisplayCountdown = 0;
mScrubToken = mScrubToken =
ctb->PlayPlayRegion(SelectedRegion(time0, time1), options, cutPreview, backwards); ctb->PlayPlayRegion(SelectedRegion(time0, time1), options,
PlayMode::normalPlay, cutPreview, backwards);
} }
} }
else else

View File

@ -2288,7 +2288,7 @@ void AdornedRulerPanel::OnMouseEvents(wxMouseEvent &evt)
options.timeTrack = NULL; options.timeTrack = NULL;
ctb->PlayPlayRegion((SelectedRegion(start, end)), ctb->PlayPlayRegion((SelectedRegion(start, end)),
options, options, PlayMode::normalPlay,
evt.ControlDown(), evt.ControlDown(),
false, false,
true); true);