1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-14 17:14:07 +01:00

Implement 2347 and 2348, Loop Play with next/previous Label

2347: Loop Play starts now at cursor position even if no time selection present
2348: Mode is preserved when using Next/Previous Label during Loop Play
This commit is contained in:
Robert Hänggi
2020-03-07 05:35:21 +01:00
committed by James Crook
parent 668bcfc82e
commit 2d46db2c5f
2 changed files with 19 additions and 9 deletions

View File

@@ -158,6 +158,7 @@ int ProjectAudioManager::PlayPlayRegion(const SelectedRegion &selectedRegion,
#if defined(EXPERIMENTAL_SEEK_BEHIND_CURSOR)
double init_seek = 0.0;
#endif
double loop_offset = 0.0;
if (t1 == t0) {
if (looped) {
@@ -172,6 +173,8 @@ int ProjectAudioManager::PlayPlayRegion(const SelectedRegion &selectedRegion,
}
else {
// loop the entire project
// Bug2347, loop playback from cursor position instead of project start
loop_offset = t0;
t0 = tracks.GetStartTime();
t1 = tracks.GetEndTime();
}
@@ -239,8 +242,12 @@ int ProjectAudioManager::PlayPlayRegion(const SelectedRegion &selectedRegion,
}
if (token != 0) {
success = true;
ProjectAudioIO::Get( *p ).SetAudioIOToken(token);
#if defined(EXPERIMENTAL_SEEK_BEHIND_CURSOR)
ProjectAudioIO::Get(*p).SetAudioIOToken(token);
if (loop_offset != t0) {
// Bug 2347
gAudioIO->SeekStream(loop_offset);
}
#if defined(EXPERIMENTAL_SEEK_BEHIND_CURSOR )
//AC: If init_seek was set, now's the time to make it happen.
gAudioIO->SeekStream(init_seek);
#endif
@@ -1011,7 +1018,8 @@ TransportTracks ProjectAudioManager::GetAllPlaybackTracks(
}
// Stop playing or recording, if paused.
void ProjectAudioManager::StopIfPaused()
void ProjectAudioManager::StopIfPaused
()
{
if( AudioIOBase::Get()->IsPaused() )
Stop();

View File

@@ -1,4 +1,5 @@
#include "../Audacity.h"
#include "../Experimental.h"
#include "../AdornedRulerPanel.h"
@@ -83,7 +84,7 @@ enum {
POST_TIMER_RECORD_SHUTDOWN
};
void DoPlayStop(const CommandContext &context)
void DoPlayStop(const CommandContext &context, bool looping = false )
{
auto &project = context.project;
auto &projectAudioManager = ProjectAudioManager::Get( project );
@@ -123,14 +124,14 @@ void DoPlayStop(const CommandContext &context)
//Otherwise, start playing (assuming audio I/O isn't busy)
// Will automatically set mLastPlayMode
projectAudioManager.PlayCurrentRegion(false);
projectAudioManager.PlayCurrentRegion(looping);
}
}
else if (!gAudioIO->IsBusy()) {
//Otherwise, start playing (assuming audio I/O isn't busy)
// Will automatically set mLastPlayMode
projectAudioManager.PlayCurrentRegion(false);
projectAudioManager.PlayCurrentRegion(looping);
}
}
@@ -139,6 +140,7 @@ void DoMoveToLabel(AudacityProject &project, bool next)
auto &tracks = TrackList::Get( project );
auto &trackFocus = TrackFocus::Get( project );
auto &window = ProjectWindow::Get( project );
auto &projectAudioManager = ProjectAudioManager::Get(project);
// Find the number of label tracks, and ptr to last track found
auto trackRange = tracks.Any<LabelTrack>();
@@ -169,20 +171,20 @@ void DoMoveToLabel(AudacityProject &project, bool next)
if (i >= 0) {
const LabelStruct* label = lt->GetLabel(i);
bool looping = projectAudioManager.Looping();
if (ProjectAudioIO::Get( project ).IsAudioActive()) {
DoPlayStop(project); // stop
selectedRegion = label->selectedRegion;
window.RedrawProject();
DoPlayStop(project); // play
DoPlayStop(project, looping); // play
}
else {
selectedRegion = label->selectedRegion;
window.ScrollIntoView(selectedRegion.t0());
window.RedrawProject();
}
auto message = XO("%s %d of %d")
.Format( label->title, i + 1, lt->GetNumLabels() );
.Format( label->title, i + 1, lt->GetNumLabels() );
trackFocus.MessageForScreenReader(message);
}
else {