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)
 
BaseItemSharedPtr TransportMenu ()
 
BaseItemSharedPtr ExtraTransportMenu ()
 
BaseItemSharedPtr ExtraSelectionItems ()
 

Variables

AttachedItem sAttachment1
 
AttachedItem sAttachment2
 
AttachedItem sAttachment4
 

Function Documentation

◆ DoMoveToLabel()

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

Definition at line 73 of file TransportMenus.cpp.

74{
75 auto &tracks = TrackList::Get( project );
76 auto &trackFocus = TrackFocus::Get( project );
77 auto &window = ProjectWindow::Get( project );
78 auto &projectAudioManager = ProjectAudioManager::Get(project);
79
80 // Find the number of label tracks, and ptr to last track found
81 auto trackRange = tracks.Any<LabelTrack>();
82 auto lt = *trackRange.rbegin();
83 auto nLabelTrack = trackRange.size();
84
85 if (nLabelTrack == 0 ) {
86 trackFocus.MessageForScreenReader(XO("no label track"));
87 }
88 else if (nLabelTrack > 1) {
89 // find first label track, if any, starting at the focused track
90 lt =
91 *tracks.Find(trackFocus.Get()).Filter<LabelTrack>();
92 if (!lt)
93 trackFocus.MessageForScreenReader(
94 XO("no label track at or below focused track"));
95 }
96
97 // If there is a single label track, or there is a label track at or below
98 // the focused track
99 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
100 if (lt) {
101 int i;
102 if (next)
103 i = lt->FindNextLabel(selectedRegion);
104 else
105 i = lt->FindPrevLabel(selectedRegion);
106
107 if (i >= 0) {
108 const LabelStruct* label = lt->GetLabel(i);
109 bool newDefault = projectAudioManager.Looping();
110 if (ProjectAudioIO::Get( project ).IsAudioActive()) {
112 selectedRegion = label->selectedRegion;
113 window.RedrawProject();
114 TransportUtilities::DoStartPlaying(project, newDefault);
115 }
116 else {
117 selectedRegion = label->selectedRegion;
118 window.ScrollIntoView(selectedRegion.t0());
119 window.RedrawProject();
120 }
121 /* i18n-hint:
122 String is replaced by the name of a label,
123 first number gives the position of that label in a sequence
124 of labels,
125 and the last number is the total number of labels in the sequence.
126 */
127 auto message = XO("%s %d of %d")
128 .Format( label->title, i + 1, lt->GetNumLabels() );
129 trackFocus.MessageForScreenReader(message);
130 }
131 else {
132 trackFocus.MessageForScreenReader(XO("no labels in label track"));
133 }
134 }
135}
XO("Cut/Copy/Paste")
TranslatableString label
Definition: TagsEditor.cpp:164
size_t size() const
How many attachment pointers are in the Site.
Definition: ClientData.h:251
Subclass * Find(const RegisteredFactory &key)
Get a (bare) pointer to an attachment, or null, down-cast it to Subclass *; will not create on demand...
Definition: ClientData.h:333
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:934
int FindPrevLabel(const SelectedRegion &currentSelection)
const LabelStruct * GetLabel(int index) const
Definition: LabelTrack.cpp:939
int FindNextLabel(const SelectedRegion &currentSelection)
static ProjectAudioIO & Get(AudacityProject &project)
static ProjectAudioManager & Get(AudacityProject &project)
static ProjectWindow & Get(AudacityProject &project)
Track * Get()
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:487
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:219
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
static bool DoStopPlaying(const CommandContext &context)
static void DoStartPlaying(const CommandContext &context, bool newDefault=false)

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

Referenced by OnMoveToNextLabel(), and OnMoveToPrevLabel().

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

◆ ExtraSelectionItems()

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

Definition at line 911 of file TransportMenus.cpp.

912{
914 static BaseItemSharedPtr items{
915 Items(wxT("MoveToLabel"),
916 Command(wxT("MoveToPrevLabel"), XXO("Move to Pre&vious Label"),
918 CaptureNotBusyFlag() | TrackPanelHasFocus(), wxT("Alt+Left")),
919 Command(wxT("MoveToNextLabel"), XXO("Move to Ne&xt Label"),
921 CaptureNotBusyFlag() | TrackPanelHasFocus(), wxT("Alt+Right"))
922 ) };
923 return items;
924}
wxT("CloseDown"))
const ReservedCommandFlag & CaptureNotBusyFlag()
const ReservedCommandFlag & TrackPanelHasFocus()
XXO("&Cut/Copy/Paste Toolbar")
std::unique_ptr< MenuItems > Items(const Identifier &internalName, Args &&... args)
std::unique_ptr< CommandItem > Command(const CommandID &name, const TranslatableString &label_in, void(Handler::*pmf)(const CommandContext &), CommandFlag flags, const CommandManager::Options &options={}, CommandHandlerFinder finder=FinderScope::DefaultFinder())
std::shared_ptr< BaseItem > BaseItemSharedPtr
Definition: Registry.h:72
void OnMoveToNextLabel(const CommandContext &context)
void OnMoveToPrevLabel(const CommandContext &context)

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

Here is the call graph for this function:

◆ ExtraTransportMenu()

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

Definition at line 863 of file TransportMenus.cpp.

864{
865 static BaseItemSharedPtr menu{
866 Menu( wxT("Transport"), XXO("T&ransport"),
867 // PlayStop is already in the menus.
868 /* i18n-hint: (verb) Start playing audio*/
869 Command( wxT("Play"), XXO("Pl&ay Once"), OnPlayOnceOrStop,
871 /* i18n-hint: (verb) Stop playing audio*/
872 Command( wxT("Stop"), XXO("Sto&p"), OnStop,
874 Command( wxT("PlayOneSec"), XXO("Play &One Second"), OnPlayOneSecond,
875 CaptureNotBusyFlag(), wxT("1") ),
876 Command( wxT("PlayToSelection"), XXO("Play to &Selection"),
878 CaptureNotBusyFlag(), wxT("B") ),
879 Command( wxT("PlayBeforeSelectionStart"),
880 XXO("Play &Before Selection Start"), OnPlayBeforeSelectionStart,
881 CaptureNotBusyFlag(), wxT("Shift+F5") ),
882 Command( wxT("PlayAfterSelectionStart"),
883 XXO("Play Af&ter Selection Start"), OnPlayAfterSelectionStart,
884 CaptureNotBusyFlag(), wxT("Shift+F6") ),
885 Command( wxT("PlayBeforeSelectionEnd"),
886 XXO("Play Be&fore Selection End"), OnPlayBeforeSelectionEnd,
887 CaptureNotBusyFlag(), wxT("Shift+F7") ),
888 Command( wxT("PlayAfterSelectionEnd"),
889 XXO("Play Aft&er Selection End"), OnPlayAfterSelectionEnd,
890 CaptureNotBusyFlag(), wxT("Shift+F8") ),
891 Command( wxT("PlayBeforeAndAfterSelectionStart"),
892 XXO("Play Before a&nd After Selection Start"),
894 wxT("Ctrl+Shift+F5") ),
895 Command( wxT("PlayBeforeAndAfterSelectionEnd"),
896 XXO("Play Before an&d After Selection End"),
898 wxT("Ctrl+Shift+F7") ),
899 Command( wxT("PlayCutPreview"), XXO("Play C&ut Preview"),
901 CaptureNotBusyFlag(), wxT("C") )
902 ) };
903 return menu;
904}
const ReservedCommandFlag & AudioIOBusyFlag()
const ReservedCommandFlag & AudioIONotBusyFlag()
const ReservedCommandFlag & WaveTracksExistFlag()
const ReservedCommandFlag & CanStopAudioStreamFlag()
std::unique_ptr< MenuItem > Menu(const Identifier &internalName, const TranslatableString &title, Args &&... args)
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(), MenuTable::Command(), MenuTable::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 137 of file TransportMenus.cpp.

138{
139 auto &playRegion = ViewInfo::Get(project).playRegion;
140 return playRegion.Active();
141}
bool Active() const
Definition: ViewInfo.h:124
PlayRegion playRegion
Definition: ViewInfo.h:220

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

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 46 of file TransportMenus.cpp.

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

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

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 366 of file TransportMenus.cpp.

367{
369}
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 699 of file TransportMenus.cpp.

700{
701 auto &project = context.project;
702 DoMoveToLabel(project, true);
703}
void DoMoveToLabel(AudacityProject &project, bool next)

References DoMoveToLabel(), and CommandContext::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 693 of file TransportMenus.cpp.

694{
695 auto &project = context.project;
696 DoMoveToLabel(project, false);
697}

References DoMoveToLabel(), and CommandContext::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 185 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 601 of file TransportMenus.cpp.

602{
603 auto &project = context.project;
604
605 if( !MakeReadyToPlay(project) )
606 return;
607
608 auto &viewInfo = ViewInfo::Get( project );
609 const auto &selectedRegion = viewInfo.selectedRegion;
610
611 double t1 = selectedRegion.t1();
612 double afterLen;
613 gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
614
615 auto playOptions = ProjectAudioIO::GetDefaultOptions(project);
616
618 context, SelectedRegion(t1, t1 + afterLen),
619 playOptions, PlayMode::oneSecondPlay);
620}
FileConfig * gPrefs
Definition: Prefs.cpp:70
static AudioIOStartStreamOptions GetDefaultOptions(AudacityProject &project, bool newDefaults=false)
Invoke the global hook, supplying a default argument.
Defines a selected portion of a project.
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, 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 547 of file TransportMenus.cpp.

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

References ViewInfo::Get(), ProjectAudioIO::GetDefaultOptions(), gPrefs, MakeReadyToPlay(), oneSecondPlay, TransportUtilities::PlayPlayRegionAndWait(), CommandContext::project, 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 652 of file TransportMenus.cpp.

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

References ViewInfo::Get(), ProjectAudioIO::GetDefaultOptions(), gPrefs, MakeReadyToPlay(), oneSecondPlay, TransportUtilities::PlayPlayRegionAndWait(), CommandContext::project, 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 622 of file TransportMenus.cpp.

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

References ViewInfo::Get(), ProjectAudioIO::GetDefaultOptions(), gPrefs, MakeReadyToPlay(), oneSecondPlay, TransportUtilities::PlayPlayRegionAndWait(), CommandContext::project, 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 574 of file TransportMenus.cpp.

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

References ViewInfo::Get(), ProjectAudioIO::GetDefaultOptions(), gPrefs, MakeReadyToPlay(), oneSecondPlay, TransportUtilities::PlayPlayRegionAndWait(), CommandContext::project, 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 526 of file TransportMenus.cpp.

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

References ViewInfo::Get(), ProjectAudioIO::GetDefaultOptions(), gPrefs, MakeReadyToPlay(), oneSecondPlay, TransportUtilities::PlayPlayRegionAndWait(), CommandContext::project, 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 682 of file TransportMenus.cpp.

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

References MakeReadyToPlay(), TransportUtilities::PlayCurrentRegionAndWait(), and CommandContext::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 171 of file TransportMenus.cpp.

172{
173 auto &project = context.project;
175 return;
176
177 if( !MakeReadyToPlay(project) )
178 return;
179
180 // Now play in a loop
181 // Will automatically set mLastPlayMode
183}

References TransportUtilities::DoStopPlaying(), MakeReadyToPlay(), TransportUtilities::PlayCurrentRegionAndWait(), and CommandContext::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 157 of file TransportMenus.cpp.

158{
160 return;
162}

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 457 of file TransportMenus.cpp.

458{
459 auto &project = context.project;
460 if( !MakeReadyToPlay(project) )
461 return;
462
463 auto &trackPanel = TrackPanel::Get( project );
464 auto options = ProjectAudioIO::GetDefaultOptions(project);
465
466 double pos = trackPanel.GetMostRecentXPos();
468 context, SelectedRegion(pos - 0.5, pos + 0.5),
469 options, PlayMode::oneSecondPlay);
470}
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:231

References TrackPanel::Get(), ProjectAudioIO::GetDefaultOptions(), MakeReadyToPlay(), oneSecondPlay, TransportUtilities::PlayPlayRegionAndWait(), and CommandContext::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 164 of file TransportMenus.cpp.

165{
167}
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 479 of file TransportMenus.cpp.

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

References ViewInfo::Get(), TrackPanel::Get(), ProjectAudioIO::GetDefaultOptions(), MakeReadyToPlay(), oneSecondPlay, TransportUtilities::PlayPlayRegionAndWait(), and CommandContext::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 190 of file TransportMenus.cpp.

191{
192 TransportUtilities::RecordAndWait(context, false);
193}
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 197 of file TransportMenus.cpp.

198{
200}

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 397 of file TransportMenus.cpp.

398{
400}
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 371 of file TransportMenus.cpp.

372{
373 auto &project = context.project;
374 auto &playRegion = ViewInfo::Get(project).playRegion;
375 if (!playRegion.Active())
378 true, false, SetLoopInTitle.Stripped());
379}
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, 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 382 of file TransportMenus.cpp.

383{
384 auto &project = context.project;
385 auto &playRegion = ViewInfo::Get(project).playRegion;
386 if (!playRegion.Active())
389 false, false, SetLoopOutTitle.Stripped());
390}
static const auto SetLoopOutTitle

References SelectUtilities::ActivatePlayRegion(), ViewInfo::Get(), SelectUtilities::OnSetRegion(), ViewInfo::playRegion, CommandContext::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 392 of file TransportMenus.cpp.

393{
395}
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 402 of file TransportMenus.cpp.

403{
404 AudacityProject &project = context.project;
405
406 SoundActivatedRecordDialog dialog( &GetProjectFrame( project ) /* parent */ );
407 dialog.ShowModal();
408}
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(), and CommandContext::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 452 of file TransportMenus.cpp.

453{
455}
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 417 of file TransportMenus.cpp.

418{
419 bool Duplex;
420#ifdef EXPERIMENTAL_DA
421 gPrefs->Read(wxT("/AudioIO/Duplex"), &Duplex, false);
422#else
423 gPrefs->Read(wxT("/AudioIO/Duplex"), &Duplex, true);
424#endif
425 gPrefs->Write(wxT("/AudioIO/Duplex"), !Duplex);
426 gPrefs->Flush();
428}
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
static void ModifyAllProjectToolbarMenus()

References FileConfig::Flush(), gPrefs, ToolManager::ModifyAllProjectToolbarMenus(), 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 361 of file TransportMenus.cpp.

362{
364}
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 410 of file TransportMenus.cpp.

411{
413 gPrefs->Flush();
415}
BoolSetting SoundActivatedRecord
Definition: AudioIO.cpp:3333
bool Toggle()
Write the negation of the previous value, and then return the current value.
Definition: Prefs.cpp:514

References FileConfig::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 430 of file TransportMenus.cpp.

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

References FileConfig::Flush(), gPrefs, ToolManager::ModifyAllProjectToolbarMenus(), and wxT().

Referenced by TransportMenu().

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

◆ TransportMenu()

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

Definition at line 727 of file TransportMenus.cpp.

728{
730
732
733 static BaseItemSharedPtr menu{
734 /* i18n-hint: 'Transport' is the name given to the set of controls that
735 play, record, pause etc. */
736 Menu( wxT("Transport"), XXO("Tra&nsport"),
737 Section( "Basic",
738 Menu( wxT("Play"), XXO("Pl&aying"),
739 /* i18n-hint: (verb) Start or Stop audio playback*/
740 Command( wxT("DefaultPlayStop"), XXO("Pl&ay/Stop"), OnPlayDefaultOrStop,
741 CanStopAudioStreamFlag(), wxT("Space") ),
742 Command( wxT("PlayStopSelect"), XXO("Play/Stop and &Set Cursor"),
744 Command( wxT("OncePlayStop"), XXO("Play &Once/Stop"), OnPlayOnceOrStop,
745 CanStopAudioStreamFlag(), wxT("Shift+Space") ),
746 Command( wxT("Pause"), XXO("&Pause"), OnPause,
748 ),
749
750 Menu( wxT("Record"), XXO("&Recording"),
751 /* i18n-hint: (verb)*/
752 Command( wxT("Record1stChoice"), XXO("&Record"), OnRecord,
753 CanStopFlags, wxT("R") ),
754
755 // The OnRecord2ndChoice function is: if normal record records beside,
756 // it records below, if normal record records below, it records beside.
757 // TODO: Do 'the right thing' with other options like TimerRecord.
758 // Delayed evaluation in case gPrefs is not yet defined
759 [](const AudacityProject&)
760 { return Command( wxT("Record2ndChoice"),
761 // Our first choice is bound to R (by default)
762 // and gets the prime position.
763 // We supply the name for the 'other one' here.
764 // It should be bound to Shift+R
765 (gPrefs->ReadBool("/GUI/PreferNewTrackRecord", false)
766 ? XXO("&Append Record") : XXO("Record &New Track")),
768 wxT("Shift+R")
769 ); },
770
771 #ifdef EXPERIMENTAL_PUNCH_AND_ROLL
772 Command( wxT("PunchAndRoll"), XXO("Punch and Rol&l Record"),
773 OnPunchAndRoll,
774 WaveTracksExistFlag() | AudioIONotBusyFlag(), wxT("Shift+D") ),
775 #endif
776
777 // JKC: I decided to duplicate this between play and record,
778 // rather than put it at the top level.
779 // CommandManger::AddItem can now cope with simple duplicated items.
780 // PRL: caution, this is a duplicated command name!
781 Command( wxT("Pause"), XXO("&Pause"), OnPause,
783 )
784 ),
785
786 Section( "Other",
787 Section( "",
788 Menu( wxT("PlayRegion"), XXO("&Looping"),
789 Command( wxT("TogglePlayRegion"), LoopToggleText,
791 Options(L"L").CheckTest([](const AudacityProject& project){
792 return IsLoopingEnabled(project);
793 } )),
794 Command( wxT("ClearPlayRegion"), XXO("&Clear Loop"),
795 OnClearPlayRegion, AlwaysEnabledFlag, L"Shift+Alt+L" ),
796 Command( wxT("SetPlayRegionToSelection"),
797 XXO("&Set Loop to Selection"),
799 L"Shift+L" ),
800 Command( wxT("SetPlayRegionIn"),
803 Command( wxT("SetPlayRegionOut"),
806 )
807 ),
808
809 Command( wxT("RescanDevices"), XXO("R&escan Audio Devices"),
811
812 Menu( wxT("Options"), XXO("Transport &Options"),
813 Section( "Part1",
814 // Sound Activated recording options
815 Command( wxT("SoundActivationLevel"),
816 XXO("Sound Activation Le&vel..."), OnSoundActivated,
818 Command( wxT("SoundActivation"),
819 XXO("Sound A&ctivated Recording (on/off)"),
823 ),
824
825 Section( "Part2",
826 Command( wxT("Overdub"), XXO("&Overdub (on/off)"),
829 Options{}.CheckTest( wxT("/AudioIO/Duplex"),
830#ifdef EXPERIMENTAL_DA
831 false
832#else
833 true
834#endif
835 ) ),
836 Command( wxT("SWPlaythrough"), XXO("So&ftware Playthrough (on/off)"),
839 Options{}.CheckTest( wxT("/AudioIO/SWPlaythrough"), false ) )
840
841
842 #ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
843 ,
844 Command( wxT("AutomatedInputLevelAdjustmentOnOff"),
845 XXO("A&utomated Recording Level Adjustment (on/off)"),
846 OnToggleAutomatedInputLevelAdjustment,
849 wxT("/AudioIO/AutomatedInputLevelAdjustment"), false ) )
850 #endif
851 )
852 )
853 )
854 ) };
855 return menu;
856}
constexpr CommandFlag AlwaysEnabledFlag
Definition: CommandFlag.h:34
const TranslatableString LoopToggleText
Definition: ViewInfo.cpp:227
std::unique_ptr< MenuPart > Section(const Identifier &internalName, Args &&... args)
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) &&

References AlwaysEnabledFlag, AudioIONotBusyFlag(), CanStopAudioStreamFlag(), anonymous_namespace{TimerRecordDialog.cpp}::CanStopFlags, CommandManager::Options::CheckTest(), MenuTable::Command(), gPrefs, IsLoopingEnabled(), LoopToggleText, MenuTable::Menu(), OnClearPlayRegion(), OnPause(), OnPlayDefaultOrStop(), OnPlayOnceOrStop(), OnPlayStopSelect(), OnRecord(), OnRecord2ndChoice(), OnRescanDevices(), OnSetPlayRegionIn(), OnSetPlayRegionOut(), OnSetPlayRegionToSelection(), OnSoundActivated(), OnTogglePlayRecording(), OnTogglePlayRegion(), OnToggleSoundActivated(), OnToggleSWPlaythrough(), MenuTable::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
Initial value:

Definition at line 858 of file TransportMenus.cpp.

◆ sAttachment2

AttachedItem anonymous_namespace{TransportMenus.cpp}::sAttachment2
Initial value:
{
wxT("Optional/Extra/Part1"),
}

Definition at line 906 of file TransportMenus.cpp.

◆ sAttachment4

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

Definition at line 926 of file TransportMenus.cpp.