Audacity 3.2.0
Functions | Variables
anonymous_namespace{TransportMenus.cpp} Namespace Reference

Functions

bool MakeReadyToPlay (AudacityProject &project)
 
void DoMoveToLabel (AudacityProject &project, bool next)
 
bool IsLoopingEnabled (const AudacityProject &project)
 
void OnPlayOnceOrStop (const CommandContext &context)
 
void OnPlayStopSelect (const CommandContext &context)
 
void OnPlayDefaultOrStop (const CommandContext &context)
 
void OnPause (const CommandContext &context)
 
void OnRecord (const CommandContext &context)
 
void OnRecord2ndChoice (const CommandContext &context)
 
void OnTogglePlayRegion (const CommandContext &context)
 
void OnClearPlayRegion (const CommandContext &context)
 
void OnSetPlayRegionIn (const CommandContext &context)
 
void OnSetPlayRegionOut (const CommandContext &context)
 
void OnSetPlayRegionToSelection (const CommandContext &context)
 
void OnRescanDevices (const CommandContext &WXUNUSED(context))
 
void OnSoundActivated (const CommandContext &context)
 
void OnToggleSoundActivated (const CommandContext &WXUNUSED(context))
 
void OnTogglePlayRecording (const CommandContext &WXUNUSED(context))
 
void OnToggleSWPlaythrough (const CommandContext &WXUNUSED(context))
 
void OnStop (const CommandContext &context)
 
void OnPlayOneSecond (const CommandContext &context)
 
void OnPlayToSelection (const CommandContext &context)
 
void OnPlayBeforeSelectionStart (const CommandContext &context)
 
void OnPlayAfterSelectionStart (const CommandContext &context)
 
void OnPlayBeforeSelectionEnd (const CommandContext &context)
 
void OnPlayAfterSelectionEnd (const CommandContext &context)
 
void OnPlayBeforeAndAfterSelectionStart (const CommandContext &context)
 
void OnPlayBeforeAndAfterSelectionEnd (const CommandContext &context)
 
void OnPlayCutPreview (const CommandContext &context)
 
void OnMoveToPrevLabel (const CommandContext &context)
 
void OnMoveToNextLabel (const CommandContext &context)
 
auto TransportMenu ()
 
auto ExtraTransportMenu ()
 
auto ExtraSelectionItems ()
 

Variables

AttachedItem sAttachment1 { Indirect(TransportMenu()) }
 
AttachedItem sAttachment2
 
AttachedItem sAttachment4
 

Function Documentation

◆ DoMoveToLabel()

void anonymous_namespace{TransportMenus.cpp}::DoMoveToLabel ( AudacityProject project,
bool  next 
)

Definition at line 70 of file TransportMenus.cpp.

71{
72 auto &tracks = TrackList::Get( project );
73 auto &trackFocus = TrackFocus::Get( project );
74 auto &viewport = Viewport::Get(project);
75 auto &projectAudioManager = ProjectAudioManager::Get(project);
76
77 // Find the number of label tracks, and ptr to last track found
78 auto trackRange = tracks.Any<LabelTrack>();
79 auto lt = *trackRange.rbegin();
80 auto nLabelTrack = trackRange.size();
81
82 if (nLabelTrack == 0 ) {
83 trackFocus.MessageForScreenReader(XO("no label track"));
84 }
85 else if (nLabelTrack > 1) {
86 // find first label track, if any, starting at the focused track
87 lt =
88 *tracks.Find(trackFocus.Get()).Filter<LabelTrack>();
89 if (!lt)
90 trackFocus.MessageForScreenReader(
91 XO("no label track at or below focused track"));
92 }
93
94 // If there is a single label track, or there is a label track at or below
95 // the focused track
96 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
97 if (lt) {
98 int i;
99 if (next)
100 i = lt->FindNextLabel(selectedRegion);
101 else
102 i = lt->FindPrevLabel(selectedRegion);
103
104 if (i >= 0) {
105 const LabelStruct* label = lt->GetLabel(i);
106 bool newDefault = projectAudioManager.Looping();
107 if (ProjectAudioIO::Get( project ).IsAudioActive()) {
109 selectedRegion = label->selectedRegion;
110 viewport.Redraw();
112 }
113 else {
114 selectedRegion = label->selectedRegion;
115 viewport.ScrollIntoView(selectedRegion.t0());
116 viewport.Redraw();
117 }
118 /* i18n-hint:
119 String is replaced by the name of a label,
120 first number gives the position of that label in a sequence
121 of labels,
122 and the last number is the total number of labels in the sequence.
123 */
124 auto message = XO("%s %d of %d")
125 .Format( label->title, i + 1, lt->GetNumLabels() );
126 trackFocus.MessageForScreenReader(message);
127 }
128 else {
129 trackFocus.MessageForScreenReader(XO("no labels in label track"));
130 }
131 }
132}
XO("Cut/Copy/Paste")
TranslatableString label
Definition: TagsEditor.cpp:165
const auto tracks
const auto project
size_t size() const
How many attachment pointers are in the Site.
Definition: ClientData.h:259
A LabelStruct holds information for ONE label in a LabelTrack.
Definition: LabelTrack.h:29
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:87
int GetNumLabels() const
Definition: LabelTrack.cpp:965
int FindPrevLabel(const SelectedRegion &currentSelection)
const LabelStruct * GetLabel(int index) const
Definition: LabelTrack.cpp:970
int FindNextLabel(const SelectedRegion &currentSelection)
static ProjectAudioIO & Get(AudacityProject &project)
static ProjectAudioManager & Get(AudacityProject &project)
Track * Get()
Definition: TrackFocus.cpp:156
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:347
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:215
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
static Viewport & Get(AudacityProject &project)
Definition: Viewport.cpp:32
static bool DoStopPlaying(const CommandContext &context)
static void DoStartPlaying(const CommandContext &context, bool newDefault=false)

References TransportUtilities::DoStartPlaying(), TransportUtilities::DoStopPlaying(), LabelTrack::FindNextLabel(), LabelTrack::FindPrevLabel(), TrackFocus::Get(), ProjectAudioIO::Get(), ViewInfo::Get(), TrackList::Get(), Viewport::Get(), ProjectAudioManager::Get(), LabelTrack::GetLabel(), LabelTrack::GetNumLabels(), label, project, ViewInfo::selectedRegion, ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::size(), tracks, and XO().

Referenced by OnMoveToNextLabel(), and OnMoveToPrevLabel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExtraSelectionItems()

auto anonymous_namespace{TransportMenus.cpp}::ExtraSelectionItems ( )

Definition at line 902 of file TransportMenus.cpp.

903{
904 static auto items = std::shared_ptr{
905 Items(wxT("MoveToLabel"),
906 Command(wxT("MoveToPrevLabel"), XXO("Move to Pre&vious Label"),
908 CaptureNotBusyFlag() | TrackPanelHasFocus(), wxT("Alt+Left")),
909 Command(wxT("MoveToNextLabel"), XXO("Move to Ne&xt Label"),
911 CaptureNotBusyFlag() | TrackPanelHasFocus(), wxT("Alt+Right"))
912 ) };
913 return items;
914}
wxT("CloseDown"))
const ReservedCommandFlag & CaptureNotBusyFlag()
const ReservedCommandFlag & TrackPanelHasFocus()
XXO("&Cut/Copy/Paste Toolbar")
constexpr auto Items
Definition: MenuRegistry.h:427
constexpr auto Command
Definition: MenuRegistry.h:456
void OnMoveToNextLabel(const CommandContext &context)
void OnMoveToPrevLabel(const CommandContext &context)

References CaptureNotBusyFlag(), MenuRegistry::Command, MenuRegistry::Items, OnMoveToNextLabel(), OnMoveToPrevLabel(), TrackPanelHasFocus(), wxT(), and XXO().

Here is the call graph for this function:

◆ ExtraTransportMenu()

auto anonymous_namespace{TransportMenus.cpp}::ExtraTransportMenu ( )

Definition at line 855 of file TransportMenus.cpp.

856{
857 static auto menu = std::shared_ptr{
858 Menu( wxT("Transport"), XXO("T&ransport"),
859 // PlayStop is already in the menus.
860 /* i18n-hint: (verb) Start playing audio*/
861 Command( wxT("Play"), XXO("Pl&ay Once"), OnPlayOnceOrStop,
863 /* i18n-hint: (verb) Stop playing audio*/
864 Command( wxT("Stop"), XXO("Sto&p"), OnStop,
866 Command( wxT("PlayOneSec"), XXO("Play &One Second"), OnPlayOneSecond,
867 CaptureNotBusyFlag(), wxT("1") ),
868 Command( wxT("PlayToSelection"), XXO("Play to &Selection"),
870 CaptureNotBusyFlag(), wxT("B") ),
871 Command( wxT("PlayBeforeSelectionStart"),
872 XXO("Play &Before Selection Start"), OnPlayBeforeSelectionStart,
873 CaptureNotBusyFlag(), wxT("Shift+F5") ),
874 Command( wxT("PlayAfterSelectionStart"),
875 XXO("Play Af&ter Selection Start"), OnPlayAfterSelectionStart,
876 CaptureNotBusyFlag(), wxT("Shift+F6") ),
877 Command( wxT("PlayBeforeSelectionEnd"),
878 XXO("Play Be&fore Selection End"), OnPlayBeforeSelectionEnd,
879 CaptureNotBusyFlag(), wxT("Shift+F7") ),
880 Command( wxT("PlayAfterSelectionEnd"),
881 XXO("Play Aft&er Selection End"), OnPlayAfterSelectionEnd,
882 CaptureNotBusyFlag(), wxT("Shift+F8") ),
883 Command( wxT("PlayBeforeAndAfterSelectionStart"),
884 XXO("Play Before a&nd After Selection Start"),
886 wxT("Ctrl+Shift+F5") ),
887 Command( wxT("PlayBeforeAndAfterSelectionEnd"),
888 XXO("Play Before an&d After Selection End"),
890 wxT("Ctrl+Shift+F7") ),
891 Command( wxT("PlayCutPreview"), XXO("Play C&ut Preview"),
893 CaptureNotBusyFlag(), wxT("C") )
894 ) };
895 return menu;
896}
const ReservedCommandFlag & AudioIOBusyFlag()
const ReservedCommandFlag & AudioIONotBusyFlag()
const ReservedCommandFlag & WaveTracksExistFlag()
const ReservedCommandFlag & CanStopAudioStreamFlag()
constexpr auto Menu
Items will appear in a main toolbar menu or in a sub-menu.
Definition: MenuRegistry.h:445
void OnPlayToSelection(const CommandContext &context)
void OnPlayBeforeAndAfterSelectionEnd(const CommandContext &context)
void OnPlayAfterSelectionStart(const CommandContext &context)
void OnPlayBeforeSelectionEnd(const CommandContext &context)
void OnPlayAfterSelectionEnd(const CommandContext &context)
void OnPlayBeforeAndAfterSelectionStart(const CommandContext &context)
void OnPlayCutPreview(const CommandContext &context)
void OnStop(const CommandContext &context)
void OnPlayOneSecond(const CommandContext &context)
void OnPlayOnceOrStop(const CommandContext &context)
void OnPlayBeforeSelectionStart(const CommandContext &context)

References AudioIOBusyFlag(), AudioIONotBusyFlag(), CanStopAudioStreamFlag(), CaptureNotBusyFlag(), MenuRegistry::Command, MenuRegistry::Menu, OnPlayAfterSelectionEnd(), OnPlayAfterSelectionStart(), OnPlayBeforeAndAfterSelectionEnd(), OnPlayBeforeAndAfterSelectionStart(), OnPlayBeforeSelectionEnd(), OnPlayBeforeSelectionStart(), OnPlayCutPreview(), OnPlayOnceOrStop(), OnPlayOneSecond(), OnPlayToSelection(), OnStop(), WaveTracksExistFlag(), wxT(), and XXO().

Here is the call graph for this function:

◆ IsLoopingEnabled()

bool anonymous_namespace{TransportMenus.cpp}::IsLoopingEnabled ( const AudacityProject project)

Definition at line 134 of file TransportMenus.cpp.

135{
136 auto &playRegion = ViewInfo::Get(project).playRegion;
137 return playRegion.Active();
138}
bool Active() const
Definition: ViewInfo.h:124
PlayRegion playRegion
Definition: ViewInfo.h:216

References PlayRegion::Active(), ViewInfo::Get(), ViewInfo::playRegion, and project.

Referenced by TransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MakeReadyToPlay()

bool anonymous_namespace{TransportMenus.cpp}::MakeReadyToPlay ( AudacityProject project)

MakeReadyToPlay stops whatever is currently playing and pops the play button up. Then, if nothing is now playing, it pushes the play button down and enables the stop button.

Definition at line 43 of file TransportMenus.cpp.

44{
45 auto &toolbar = ControlToolBar::Get( project );
46 wxCommandEvent evt;
47
48 // If this project is playing, stop playing
49 auto gAudioIO = AudioIOBase::Get();
50 if (gAudioIO->IsStreamActive(
52 )) {
53 // Make momentary changes of button appearances
54 toolbar.SetPlay(false); //Pops
55 toolbar.SetStop(); //Pushes stop down
56 toolbar.OnStop(evt);
57
58 using namespace std::chrono;
59 std::this_thread::sleep_for(100ms);
60 }
61
62 // If it didn't stop playing quickly, or if some other
63 // project is playing, return
64 if (gAudioIO->IsBusy())
65 return false;
66
67 return true;
68}
static AudioIOBase * Get()
Definition: AudioIOBase.cpp:94
static ControlToolBar & Get(AudacityProject &project)
int GetAudioIOToken() const

References AudioIOBase::Get(), ProjectAudioIO::Get(), ControlToolBar::Get(), ProjectAudioIO::GetAudioIOToken(), and project.

Referenced by OnPlayAfterSelectionEnd(), OnPlayAfterSelectionStart(), OnPlayBeforeAndAfterSelectionEnd(), OnPlayBeforeAndAfterSelectionStart(), OnPlayBeforeSelectionEnd(), OnPlayBeforeSelectionStart(), OnPlayCutPreview(), OnPlayDefaultOrStop(), OnPlayOneSecond(), and OnPlayToSelection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnClearPlayRegion()

void anonymous_namespace{TransportMenus.cpp}::OnClearPlayRegion ( const CommandContext context)

Definition at line 373 of file TransportMenus.cpp.

374{
376}
AudacityProject & project
void ClearPlayRegion(AudacityProject &project)

References SelectUtilities::ClearPlayRegion(), and CommandContext::project.

Referenced by TransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnMoveToNextLabel()

void anonymous_namespace{TransportMenus.cpp}::OnMoveToNextLabel ( const CommandContext context)

Definition at line 702 of file TransportMenus.cpp.

703{
704 auto &project = context.project;
705 DoMoveToLabel(project, true);
706}
void DoMoveToLabel(AudacityProject &project, bool next)

References DoMoveToLabel(), CommandContext::project, and project.

Referenced by ExtraSelectionItems().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnMoveToPrevLabel()

void anonymous_namespace{TransportMenus.cpp}::OnMoveToPrevLabel ( const CommandContext context)

Definition at line 696 of file TransportMenus.cpp.

697{
698 auto &project = context.project;
699 DoMoveToLabel(project, false);
700}

References DoMoveToLabel(), CommandContext::project, and project.

Referenced by ExtraSelectionItems().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnPause()

void anonymous_namespace{TransportMenus.cpp}::OnPause ( const CommandContext context)

Definition at line 182 of file TransportMenus.cpp.

References ProjectAudioManager::Get(), ProjectAudioManager::OnPause(), and CommandContext::project.

Referenced by TransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnPlayAfterSelectionEnd()

void anonymous_namespace{TransportMenus.cpp}::OnPlayAfterSelectionEnd ( const CommandContext context)

Definition at line 604 of file TransportMenus.cpp.

605{
606 auto &project = context.project;
607
609 return;
610
611 auto &viewInfo = ViewInfo::Get( project );
612 const auto &selectedRegion = viewInfo.selectedRegion;
613
614 double t1 = selectedRegion.t1();
615 double afterLen;
616 gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
617
618 auto playOptions = ProjectAudioIO::GetDefaultOptions(project);
619
621 context, SelectedRegion(t1, t1 + afterLen),
622 playOptions, PlayMode::oneSecondPlay);
623}
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
static AudioIOStartStreamOptions GetDefaultOptions(AudacityProject &project, bool newDefaults=false)
Invoke the global hook, supplying a default argument.
Defines a selected portion of a project.
virtual bool Read(const wxString &key, bool *value) const =0
bool MakeReadyToPlay(AudacityProject &project)
static void PlayPlayRegionAndWait(const CommandContext &context, const SelectedRegion &selectedRegion, const AudioIOStartStreamOptions &options, PlayMode mode)

References ViewInfo::Get(), ProjectAudioIO::GetDefaultOptions(), gPrefs, MakeReadyToPlay(), oneSecondPlay, TransportUtilities::PlayPlayRegionAndWait(), CommandContext::project, project, audacity::BasicSettings::Read(), and wxT().

Referenced by ExtraTransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnPlayAfterSelectionStart()

void anonymous_namespace{TransportMenus.cpp}::OnPlayAfterSelectionStart ( const CommandContext context)

Definition at line 550 of file TransportMenus.cpp.

551{
552 auto &project = context.project;
553
555 return;
556
557 auto &viewInfo = ViewInfo::Get( project );
558 const auto &selectedRegion = viewInfo.selectedRegion;
559
560 double t0 = selectedRegion.t0();
561 double t1 = selectedRegion.t1();
562 double afterLen;
563 gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
564
565 auto playOptions = ProjectAudioIO::GetDefaultOptions(project);
566
567 if ( t1 - t0 > 0.0 && t1 - t0 < afterLen )
569 context, SelectedRegion(t0, t1),
570 playOptions, PlayMode::oneSecondPlay);
571 else
573 context, SelectedRegion(t0, t0 + afterLen),
574 playOptions, PlayMode::oneSecondPlay);
575}

References ViewInfo::Get(), ProjectAudioIO::GetDefaultOptions(), gPrefs, MakeReadyToPlay(), oneSecondPlay, TransportUtilities::PlayPlayRegionAndWait(), CommandContext::project, project, audacity::BasicSettings::Read(), and wxT().

Referenced by ExtraTransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnPlayBeforeAndAfterSelectionEnd()

void anonymous_namespace{TransportMenus.cpp}::OnPlayBeforeAndAfterSelectionEnd ( const CommandContext context)

Definition at line 655 of file TransportMenus.cpp.

657{
658 auto &project = context.project;
659
661 return;
662
663 auto &viewInfo = ViewInfo::Get( project );
664 const auto &selectedRegion = viewInfo.selectedRegion;
665
666 double t0 = selectedRegion.t0();
667 double t1 = selectedRegion.t1();
668 double beforeLen;
669 gPrefs->Read(wxT("/AudioIO/CutPreviewBeforeLen"), &beforeLen, 2.0);
670 double afterLen;
671 gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
672
673 auto playOptions = ProjectAudioIO::GetDefaultOptions(project);
674
675 if ( t1 - t0 > 0.0 && t1 - t0 < beforeLen )
677 context, SelectedRegion(t0, t1 + afterLen),
678 playOptions, PlayMode::oneSecondPlay);
679 else
681 context, SelectedRegion(t1 - beforeLen, t1 + afterLen),
682 playOptions, PlayMode::oneSecondPlay);
683}

References ViewInfo::Get(), ProjectAudioIO::GetDefaultOptions(), gPrefs, MakeReadyToPlay(), oneSecondPlay, TransportUtilities::PlayPlayRegionAndWait(), CommandContext::project, project, audacity::BasicSettings::Read(), and wxT().

Referenced by ExtraTransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnPlayBeforeAndAfterSelectionStart()

void anonymous_namespace{TransportMenus.cpp}::OnPlayBeforeAndAfterSelectionStart ( const CommandContext context)

Definition at line 625 of file TransportMenus.cpp.

627{
628 auto &project = context.project;
629
631 return;
632
633 auto &viewInfo = ViewInfo::Get( project );
634 const auto &selectedRegion = viewInfo.selectedRegion;
635
636 double t0 = selectedRegion.t0();
637 double t1 = selectedRegion.t1();
638 double beforeLen;
639 gPrefs->Read(wxT("/AudioIO/CutPreviewBeforeLen"), &beforeLen, 2.0);
640 double afterLen;
641 gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
642
643 auto playOptions = ProjectAudioIO::GetDefaultOptions(project);
644
645 if ( t1 - t0 > 0.0 && t1 - t0 < afterLen )
647 context, SelectedRegion(t0 - beforeLen, t1),
648 playOptions, PlayMode::oneSecondPlay);
649 else
651 context, SelectedRegion(t0 - beforeLen, t0 + afterLen),
652 playOptions, PlayMode::oneSecondPlay);
653}

References ViewInfo::Get(), ProjectAudioIO::GetDefaultOptions(), gPrefs, MakeReadyToPlay(), oneSecondPlay, TransportUtilities::PlayPlayRegionAndWait(), CommandContext::project, project, audacity::BasicSettings::Read(), and wxT().

Referenced by ExtraTransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnPlayBeforeSelectionEnd()

void anonymous_namespace{TransportMenus.cpp}::OnPlayBeforeSelectionEnd ( const CommandContext context)

Definition at line 577 of file TransportMenus.cpp.

578{
579 auto &project = context.project;
580
582 return;
583
584 auto &viewInfo = ViewInfo::Get( project );
585 const auto &selectedRegion = viewInfo.selectedRegion;
586
587 double t0 = selectedRegion.t0();
588 double t1 = selectedRegion.t1();
589 double beforeLen;
590 gPrefs->Read(wxT("/AudioIO/CutPreviewBeforeLen"), &beforeLen, 2.0);
591
592 auto playOptions = ProjectAudioIO::GetDefaultOptions(project);
593
594 if ( t1 - t0 > 0.0 && t1 - t0 < beforeLen )
596 context, SelectedRegion(t0, t1),
597 playOptions, PlayMode::oneSecondPlay);
598 else
600 context, SelectedRegion(t1 - beforeLen, t1),
601 playOptions, PlayMode::oneSecondPlay);
602}

References ViewInfo::Get(), ProjectAudioIO::GetDefaultOptions(), gPrefs, MakeReadyToPlay(), oneSecondPlay, TransportUtilities::PlayPlayRegionAndWait(), CommandContext::project, project, audacity::BasicSettings::Read(), and wxT().

Referenced by ExtraTransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnPlayBeforeSelectionStart()

void anonymous_namespace{TransportMenus.cpp}::OnPlayBeforeSelectionStart ( const CommandContext context)

Definition at line 529 of file TransportMenus.cpp.

530{
531 auto &project = context.project;
532
534 return;
535
536 auto &viewInfo = ViewInfo::Get( project );
537 const auto &selectedRegion = viewInfo.selectedRegion;
538
539 double t0 = selectedRegion.t0();
540 double beforeLen;
541 gPrefs->Read(wxT("/AudioIO/CutPreviewBeforeLen"), &beforeLen, 2.0);
542
543 auto playOptions = ProjectAudioIO::GetDefaultOptions(project);
544
546 context, SelectedRegion(t0 - beforeLen, t0),
547 playOptions, PlayMode::oneSecondPlay);
548}

References ViewInfo::Get(), ProjectAudioIO::GetDefaultOptions(), gPrefs, MakeReadyToPlay(), oneSecondPlay, TransportUtilities::PlayPlayRegionAndWait(), CommandContext::project, project, audacity::BasicSettings::Read(), and wxT().

Referenced by ExtraTransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnPlayCutPreview()

void anonymous_namespace{TransportMenus.cpp}::OnPlayCutPreview ( const CommandContext context)

Definition at line 685 of file TransportMenus.cpp.

686{
687 auto &project = context.project;
688
689 if ( !MakeReadyToPlay(project) )
690 return;
691
692 // Play with cut preview
694}
static void PlayCurrentRegionAndWait(const CommandContext &context, bool newDefault=false, bool cutpreview=false)

References MakeReadyToPlay(), TransportUtilities::PlayCurrentRegionAndWait(), CommandContext::project, and project.

Referenced by ExtraTransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnPlayDefaultOrStop()

void anonymous_namespace{TransportMenus.cpp}::OnPlayDefaultOrStop ( const CommandContext context)

Definition at line 168 of file TransportMenus.cpp.

169{
170 auto &project = context.project;
172 return;
173
175 return;
176
177 // Now play in a loop
178 // Will automatically set mLastPlayMode
180}

References TransportUtilities::DoStopPlaying(), MakeReadyToPlay(), TransportUtilities::PlayCurrentRegionAndWait(), CommandContext::project, and project.

Referenced by TransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnPlayOnceOrStop()

void anonymous_namespace{TransportMenus.cpp}::OnPlayOnceOrStop ( const CommandContext context)

Definition at line 154 of file TransportMenus.cpp.

155{
157 return;
159}

References TransportUtilities::DoStartPlaying(), TransportUtilities::DoStopPlaying(), and CommandContext::project.

Referenced by ExtraTransportMenu(), and TransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnPlayOneSecond()

void anonymous_namespace{TransportMenus.cpp}::OnPlayOneSecond ( const CommandContext context)

Definition at line 460 of file TransportMenus.cpp.

461{
462 auto &project = context.project;
464 return;
465
466 auto &trackPanel = TrackPanel::Get( project );
468
469 double pos = trackPanel.GetMostRecentXPos();
471 context, SelectedRegion(pos - 0.5, pos + 0.5),
472 options, PlayMode::oneSecondPlay);
473}
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:233

References TrackPanel::Get(), ProjectAudioIO::GetDefaultOptions(), MakeReadyToPlay(), oneSecondPlay, TransportUtilities::PlayPlayRegionAndWait(), CommandContext::project, and project.

Referenced by ExtraTransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnPlayStopSelect()

void anonymous_namespace{TransportMenus.cpp}::OnPlayStopSelect ( const CommandContext context)

Definition at line 161 of file TransportMenus.cpp.

162{
164}
bool DoPlayStopSelect(bool click, bool shift)

References ProjectAudioManager::DoPlayStopSelect(), ProjectAudioManager::Get(), and CommandContext::project.

Referenced by TransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnPlayToSelection()

void anonymous_namespace{TransportMenus.cpp}::OnPlayToSelection ( const CommandContext context)

The idea for this function (and first implementation) was from Juhana Sadeharju. The function plays the sound between the current mouse position and the nearest selection boundary. This gives four possible play regions depending on where the current mouse position is relative to the left and right boundaries of the selection region.

Definition at line 482 of file TransportMenus.cpp.

483{
484 auto &project = context.project;
485
487 return;
488
489 auto &trackPanel = TrackPanel::Get( project );
490 auto &viewInfo = ViewInfo::Get( project );
491 const auto &selectedRegion = viewInfo.selectedRegion;
492
493 double pos = trackPanel.GetMostRecentXPos();
494
495 double t0,t1;
496 // check region between pointer and the nearest selection edge
497 if (fabs(pos - selectedRegion.t0()) <
498 fabs(pos - selectedRegion.t1())) {
499 t0 = t1 = selectedRegion.t0();
500 } else {
501 t0 = t1 = selectedRegion.t1();
502 }
503 if( pos < t1)
504 t0=pos;
505 else
506 t1=pos;
507
508 // JKC: oneSecondPlay mode disables auto scrolling
509 // On balance I think we should always do this in this function
510 // since you are typically interested in the sound EXACTLY
511 // where the cursor is.
512 // TODO: have 'playing attributes' such as 'with_autoscroll'
513 // rather than modes, since that's how we're now using the modes.
514
515 // An alternative, commented out below, is to disable autoscroll
516 // only when playing a short region, less than or equal to a second.
517// mLastPlayMode = ((t1-t0) > 1.0) ? normalPlay : oneSecondPlay;
518
519 auto playOptions = ProjectAudioIO::GetDefaultOptions(project);
520
522 context, SelectedRegion(t0, t1),
523 playOptions, PlayMode::oneSecondPlay);
524}

References ViewInfo::Get(), TrackPanel::Get(), ProjectAudioIO::GetDefaultOptions(), MakeReadyToPlay(), oneSecondPlay, TransportUtilities::PlayPlayRegionAndWait(), CommandContext::project, and project.

Referenced by ExtraTransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnRecord()

void anonymous_namespace{TransportMenus.cpp}::OnRecord ( const CommandContext context)

Definition at line 187 of file TransportMenus.cpp.

188{
189 TransportUtilities::RecordAndWait(context, false);
190}
static void RecordAndWait(const CommandContext &context, bool altAppearance)

References TransportUtilities::RecordAndWait().

Referenced by TransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnRecord2ndChoice()

void anonymous_namespace{TransportMenus.cpp}::OnRecord2ndChoice ( const CommandContext context)

Definition at line 194 of file TransportMenus.cpp.

195{
197}

References TransportUtilities::RecordAndWait().

Referenced by TransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnRescanDevices()

void anonymous_namespace{TransportMenus.cpp}::OnRescanDevices ( const CommandContext WXUNUSEDcontext)

Definition at line 404 of file TransportMenus.cpp.

405{
407}
static DeviceManager * Instance()
Gets the singleton instance.

References DeviceManager::Instance(), and DeviceManager::Rescan().

Referenced by TransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnSetPlayRegionIn()

void anonymous_namespace{TransportMenus.cpp}::OnSetPlayRegionIn ( const CommandContext context)

Definition at line 378 of file TransportMenus.cpp.

379{
380 auto &project = context.project;
381 auto &playRegion = ViewInfo::Get(project).playRegion;
382 if (!playRegion.Active())
385 true, false, SetLoopInTitle.Stripped());
386}
static const auto SetLoopInTitle
void ActivatePlayRegion(AudacityProject &project)
void OnSetRegion(AudacityProject &project, bool left, bool selection, const TranslatableString &dialogTitle)
Adjust left or right of selection or play region.

References SelectUtilities::ActivatePlayRegion(), ViewInfo::Get(), SelectUtilities::OnSetRegion(), ViewInfo::playRegion, CommandContext::project, project, and SetLoopInTitle.

Referenced by TransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnSetPlayRegionOut()

void anonymous_namespace{TransportMenus.cpp}::OnSetPlayRegionOut ( const CommandContext context)

Definition at line 389 of file TransportMenus.cpp.

390{
391 auto &project = context.project;
392 auto &playRegion = ViewInfo::Get(project).playRegion;
393 if (!playRegion.Active())
396 false, false, SetLoopOutTitle.Stripped());
397}
static const auto SetLoopOutTitle

References SelectUtilities::ActivatePlayRegion(), ViewInfo::Get(), SelectUtilities::OnSetRegion(), ViewInfo::playRegion, CommandContext::project, project, and SetLoopOutTitle.

Referenced by TransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnSetPlayRegionToSelection()

void anonymous_namespace{TransportMenus.cpp}::OnSetPlayRegionToSelection ( const CommandContext context)

Definition at line 399 of file TransportMenus.cpp.

400{
402}
void SetPlayRegionToSelection(AudacityProject &project)

References CommandContext::project, and SelectUtilities::SetPlayRegionToSelection().

Referenced by TransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnSoundActivated()

void anonymous_namespace{TransportMenus.cpp}::OnSoundActivated ( const CommandContext context)

Definition at line 409 of file TransportMenus.cpp.

410{
412
413 SoundActivatedRecordDialog dialog( &GetProjectFrame( project ) /* parent */ );
414 dialog.ShowModal();
415}
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
Configures sound activated recording.

References GetProjectFrame(), CommandContext::project, and project.

Referenced by TransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnStop()

void anonymous_namespace{TransportMenus.cpp}::OnStop ( const CommandContext context)

Definition at line 455 of file TransportMenus.cpp.

456{
458}
void Stop(bool stopStream=true)

References ProjectAudioManager::Get(), CommandContext::project, and ProjectAudioManager::Stop().

Referenced by ExtraTransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnTogglePlayRecording()

void anonymous_namespace{TransportMenus.cpp}::OnTogglePlayRecording ( const CommandContext WXUNUSEDcontext)

Definition at line 424 of file TransportMenus.cpp.

425{
426 bool Duplex;
427 gPrefs->Read(wxT("/AudioIO/Duplex"), &Duplex, true);
428 gPrefs->Write(wxT("/AudioIO/Duplex"), !Duplex);
429 gPrefs->Flush();
431}
static void ModifyAllProjectToolbarMenus()
virtual bool Flush() noexcept=0
virtual bool Write(const wxString &key, bool value)=0

References audacity::BasicSettings::Flush(), gPrefs, ToolManager::ModifyAllProjectToolbarMenus(), audacity::BasicSettings::Read(), audacity::BasicSettings::Write(), and wxT().

Referenced by TransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnTogglePlayRegion()

void anonymous_namespace{TransportMenus.cpp}::OnTogglePlayRegion ( const CommandContext context)

Definition at line 368 of file TransportMenus.cpp.

369{
371}
void TogglePlayRegion(AudacityProject &project)

References CommandContext::project, and SelectUtilities::TogglePlayRegion().

Referenced by TransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnToggleSoundActivated()

void anonymous_namespace{TransportMenus.cpp}::OnToggleSoundActivated ( const CommandContext WXUNUSEDcontext)

Definition at line 417 of file TransportMenus.cpp.

418{
420 gPrefs->Flush();
422}
BoolSetting SoundActivatedRecord
Definition: AudioIO.cpp:3356
bool Toggle()
Write the negation of the previous value, and then return the current value.
Definition: Prefs.cpp:555

References audacity::BasicSettings::Flush(), gPrefs, ToolManager::ModifyAllProjectToolbarMenus(), SoundActivatedRecord, and BoolSetting::Toggle().

Referenced by TransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnToggleSWPlaythrough()

void anonymous_namespace{TransportMenus.cpp}::OnToggleSWPlaythrough ( const CommandContext WXUNUSEDcontext)

Definition at line 433 of file TransportMenus.cpp.

434{
435 bool SWPlaythrough;
436 gPrefs->Read(wxT("/AudioIO/SWPlaythrough"), &SWPlaythrough, false);
437 gPrefs->Write(wxT("/AudioIO/SWPlaythrough"), !SWPlaythrough);
438 gPrefs->Flush();
440}

References audacity::BasicSettings::Flush(), gPrefs, ToolManager::ModifyAllProjectToolbarMenus(), audacity::BasicSettings::Read(), audacity::BasicSettings::Write(), and wxT().

Referenced by TransportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TransportMenu()

auto anonymous_namespace{TransportMenus.cpp}::TransportMenu ( )

Definition at line 730 of file TransportMenus.cpp.

731{
732 static const auto CanStopFlags =
734 static auto menu = std::shared_ptr{
735 /* i18n-hint: 'Transport' is the name given to the set of controls that
736 play, record, pause etc. */
737 Menu( wxT("Transport"), XXO("Tra&nsport"),
738 Section( "Basic",
739 Menu( wxT("Play"), XXO("Pl&aying"),
740 /* i18n-hint: (verb) Start or Stop audio playback*/
741 Command( wxT("DefaultPlayStop"), XXO("Pl&ay/Stop"), OnPlayDefaultOrStop,
742 CanStopAudioStreamFlag(), wxT("Space") ),
743 Command( wxT("PlayStopSelect"), XXO("Play/Stop and &Set Cursor"),
745 Command( wxT("OncePlayStop"), XXO("Play &Once/Stop"), OnPlayOnceOrStop,
746 CanStopAudioStreamFlag(), wxT("Shift+Space") ),
747 Command( wxT("Pause"), XXO("&Pause"), OnPause,
749 ),
750
751 Menu( wxT("Record"), XXO("&Recording"),
752 /* i18n-hint: (verb)*/
753 Command( wxT("Record1stChoice"), XXO("&Record"), OnRecord,
754 CanStopFlags, wxT("R") ),
755
756 // The OnRecord2ndChoice function is: if normal record records beside,
757 // it records below, if normal record records below, it records beside.
758 // TODO: Do 'the right thing' with other options like TimerRecord.
759 // Delayed evaluation in case gPrefs is not yet defined
760 [](const AudacityProject&)
761 { return Command( wxT("Record2ndChoice"),
762 // Our first choice is bound to R (by default)
763 // and gets the prime position.
764 // We supply the name for the 'other one' here.
765 // It should be bound to Shift+R
766 (gPrefs->ReadBool("/GUI/PreferNewTrackRecord", false)
767 ? XXO("&Append Record") : XXO("Record &New Track")),
769 wxT("Shift+R")
770 ); },
771
772 #ifdef EXPERIMENTAL_PUNCH_AND_ROLL
773 Command( wxT("PunchAndRoll"), XXO("Punch and Rol&l Record"),
774 OnPunchAndRoll,
775 WaveTracksExistFlag() | AudioIONotBusyFlag(), wxT("Shift+D") ),
776 #endif
777
778 // JKC: I decided to duplicate this between play and record,
779 // rather than put it at the top level.
780 // CommandManger::AddItem can now cope with simple duplicated items.
781 // PRL: caution, this is a duplicated command name!
782 Command( wxT("Pause"), XXO("&Pause"), OnPause,
784 )
785 ),
786
787 Section( "Other",
788 Section( "",
789 Menu( wxT("PlayRegion"), XXO("&Looping"),
790 Command( wxT("TogglePlayRegion"), LoopToggleText,
792 Options(L"L").CheckTest([](const AudacityProject& project){
794 } )),
795 Command( wxT("ClearPlayRegion"), XXO("&Clear Loop"),
796 OnClearPlayRegion, AlwaysEnabledFlag, L"Shift+Alt+L" ),
797 Command( wxT("SetPlayRegionToSelection"),
798 XXO("&Set Loop to Selection"),
800 L"Shift+L" ),
801 Command( wxT("SetPlayRegionIn"),
804 Command( wxT("SetPlayRegionOut"),
807 )
808 ),
809
810 Command( wxT("RescanDevices"), XXO("R&escan Audio Devices"),
812
813 Menu( wxT("Options"), XXO("Transport &Options"),
814 Section( "Part1",
815 // Sound Activated recording options
816 Command( wxT("SoundActivationLevel"),
817 XXO("Set sound activation le&vel..."), OnSoundActivated,
819 Command( wxT("SoundActivation"),
820 XXO("Enable sound a&ctivated recording"),
824 ),
825
826 Section( "Part2",
827 Command( wxT("Overdub"), XXO("Hear &other tracks during recording"),
830 Options{}.CheckTest( wxT("/AudioIO/Duplex"), true) ),
831 Command( wxT("SWPlaythrough"), XXO("Enable audible input &monitoring"),
834 Options{}.CheckTest( wxT("/AudioIO/SWPlaythrough"), false ) )
835
836
837 #ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
838 ,
839 Command( wxT("AutomatedInputLevelAdjustmentOnOff"),
840 XXO("A&utomated Recording Level Adjustment (on/off)"),
841 OnToggleAutomatedInputLevelAdjustment,
844 wxT("/AudioIO/AutomatedInputLevelAdjustment"), false ) )
845 #endif
846 )
847 )
848 )
849 ) };
850 return menu;
851}
constexpr CommandFlag AlwaysEnabledFlag
Definition: CommandFlag.h:34
const TranslatableString LoopToggleText
Definition: ViewInfo.cpp:227
bool ReadBool(const wxString &key, bool defaultValue) const
constexpr auto Section
Definition: MenuRegistry.h:436
void OnSetPlayRegionToSelection(const CommandContext &context)
void OnTogglePlayRecording(const CommandContext &WXUNUSED(context))
void OnSetPlayRegionIn(const CommandContext &context)
void OnToggleSWPlaythrough(const CommandContext &WXUNUSED(context))
void OnSoundActivated(const CommandContext &context)
void OnToggleSoundActivated(const CommandContext &WXUNUSED(context))
void OnSetPlayRegionOut(const CommandContext &context)
void OnRecord(const CommandContext &context)
void OnRecord2ndChoice(const CommandContext &context)
void OnPause(const CommandContext &context)
void OnPlayDefaultOrStop(const CommandContext &context)
void OnRescanDevices(const CommandContext &WXUNUSED(context))
void OnPlayStopSelect(const CommandContext &context)
void OnTogglePlayRegion(const CommandContext &context)
void OnClearPlayRegion(const CommandContext &context)
bool IsLoopingEnabled(const AudacityProject &project)
Options && CheckTest(const CheckFn &fn) &&
Definition: MenuRegistry.h:74

References AlwaysEnabledFlag, AudioIONotBusyFlag(), CanStopAudioStreamFlag(), anonymous_namespace{TimerRecordDialog.cpp}::CanStopFlags, MenuRegistry::Options::CheckTest(), MenuRegistry::Command, gPrefs, IsLoopingEnabled(), LoopToggleText, MenuRegistry::Menu, OnClearPlayRegion(), OnPause(), OnPlayDefaultOrStop(), OnPlayOnceOrStop(), OnPlayStopSelect(), OnRecord(), OnRecord2ndChoice(), OnRescanDevices(), OnSetPlayRegionIn(), OnSetPlayRegionOut(), OnSetPlayRegionToSelection(), OnSoundActivated(), OnTogglePlayRecording(), OnTogglePlayRegion(), OnToggleSoundActivated(), OnToggleSWPlaythrough(), project, audacity::BasicSettings::ReadBool(), MenuRegistry::Section, SetLoopInTitle, SetLoopOutTitle, SoundActivatedRecord, WaveTracksExistFlag(), wxT(), and XXO().

Here is the call graph for this function:

Variable Documentation

◆ sAttachment1

AttachedItem anonymous_namespace{TransportMenus.cpp}::sAttachment1 { Indirect(TransportMenu()) }

Definition at line 853 of file TransportMenus.cpp.

◆ sAttachment2

AttachedItem anonymous_namespace{TransportMenus.cpp}::sAttachment2
Initial value:
wxT("Optional/Extra/Part1")
}
std::unique_ptr< detail::IndirectItem< Item > > Indirect(const std::shared_ptr< Item > &ptr)
A convenience function.
Definition: Registry.h:175

Definition at line 898 of file TransportMenus.cpp.

◆ sAttachment4

AttachedItem anonymous_namespace{TransportMenus.cpp}::sAttachment4
Initial value:
{ wxT("Optional/Extra/Part1/Select"), { OrderingHint::End, {} } }
}

Definition at line 916 of file TransportMenus.cpp.