Audacity 3.2.0
Public Member Functions | List of all members
TransportActions::Handler Struct Reference
Inheritance diagram for TransportActions::Handler:
[legend]
Collaboration diagram for TransportActions::Handler:
[legend]

Public Member Functions

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 OnTimerRecord (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 OnTogglePinnedHead (const CommandContext &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 OnPlayAtSpeed (const CommandContext &context)
 
void OnPlayAtSpeedLooped (const CommandContext &context)
 
void OnPlayAtSpeedCutPreview (const CommandContext &context)
 
void OnSetPlaySpeed (const CommandContext &context)
 
void OnPlaySpeedInc (const CommandContext &context)
 
void OnPlaySpeedDec (const CommandContext &context)
 
void OnMoveToPrevLabel (const CommandContext &context)
 
void OnMoveToNextLabel (const CommandContext &context)
 

Detailed Description

Definition at line 163 of file TransportMenus.cpp.

Member Function Documentation

◆ OnClearPlayRegion()

void TransportActions::Handler::OnClearPlayRegion ( const CommandContext context)
inline

Definition at line 505 of file TransportMenus.cpp.

506{
508}
AudacityProject & project
void ClearPlayRegion(AudacityProject &project)

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

Here is the call graph for this function:

◆ OnMoveToNextLabel()

void TransportActions::Handler::OnMoveToNextLabel ( const CommandContext context)
inline

Definition at line 905 of file TransportMenus.cpp.

906{
907 auto &project = context.project;
908 DoMoveToLabel(project, true);
909}
void DoMoveToLabel(AudacityProject &project, bool next)

References anonymous_namespace{TransportMenus.cpp}::DoMoveToLabel(), and CommandContext::project.

Here is the call graph for this function:

◆ OnMoveToPrevLabel()

void TransportActions::Handler::OnMoveToPrevLabel ( const CommandContext context)
inline

Definition at line 899 of file TransportMenus.cpp.

900{
901 auto &project = context.project;
902 DoMoveToLabel(project, false);
903}

References anonymous_namespace{TransportMenus.cpp}::DoMoveToLabel(), and CommandContext::project.

Here is the call graph for this function:

◆ OnPause()

void TransportActions::Handler::OnPause ( const CommandContext context)
inline

Definition at line 195 of file TransportMenus.cpp.

196{
198}
static ProjectAudioManager & Get(AudacityProject &project)

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

Here is the call graph for this function:

◆ OnPlayAfterSelectionEnd()

void TransportActions::Handler::OnPlayAfterSelectionEnd ( const CommandContext context)
inline

Definition at line 747 of file TransportMenus.cpp.

748{
749 auto &project = context.project;
750
751 if( !MakeReadyToPlay(project) )
752 return;
753
754 auto &viewInfo = ViewInfo::Get( project );
755 const auto &selectedRegion = viewInfo.selectedRegion;
756
757 double t1 = selectedRegion.t1();
758 double afterLen;
759 gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
760
761 auto playOptions = DefaultPlayOptions( project );
762
764 context, SelectedRegion(t1, t1 + afterLen),
765 playOptions, PlayMode::oneSecondPlay);
766}
wxT("CloseDown"))
FileConfig * gPrefs
Definition: Prefs.cpp:71
AudioIOStartStreamOptions DefaultPlayOptions(AudacityProject &project, bool newDefault)
Defines a selected portion of a project.
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
bool MakeReadyToPlay(AudacityProject &project)
static void PlayPlayRegionAndWait(const CommandContext &context, const SelectedRegion &selectedRegion, const AudioIOStartStreamOptions &options, PlayMode mode)

References DefaultPlayOptions(), ViewInfo::Get(), gPrefs, anonymous_namespace{TransportMenus.cpp}::MakeReadyToPlay(), oneSecondPlay, TransportUtilities::PlayPlayRegionAndWait(), CommandContext::project, and wxT().

Here is the call graph for this function:

◆ OnPlayAfterSelectionStart()

void TransportActions::Handler::OnPlayAfterSelectionStart ( const CommandContext context)
inline

Definition at line 693 of file TransportMenus.cpp.

694{
695 auto &project = context.project;
696
697 if( !MakeReadyToPlay(project) )
698 return;
699
700 auto &viewInfo = ViewInfo::Get( project );
701 const auto &selectedRegion = viewInfo.selectedRegion;
702
703 double t0 = selectedRegion.t0();
704 double t1 = selectedRegion.t1();
705 double afterLen;
706 gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
707
708 auto playOptions = DefaultPlayOptions( project );
709
710 if ( t1 - t0 > 0.0 && t1 - t0 < afterLen )
712 context, SelectedRegion(t0, t1),
713 playOptions, PlayMode::oneSecondPlay);
714 else
716 context, SelectedRegion(t0, t0 + afterLen),
717 playOptions, PlayMode::oneSecondPlay);
718}

References DefaultPlayOptions(), ViewInfo::Get(), gPrefs, anonymous_namespace{TransportMenus.cpp}::MakeReadyToPlay(), oneSecondPlay, TransportUtilities::PlayPlayRegionAndWait(), CommandContext::project, and wxT().

Here is the call graph for this function:

◆ OnPlayAtSpeed()

void TransportActions::Handler::OnPlayAtSpeed ( const CommandContext context)
inline

Definition at line 839 of file TransportMenus.cpp.

840{
841 auto &project = context.project;
842 auto tb = &TranscriptionToolBar::Get( project );
843
844 if (tb) {
845 tb->PlayAtSpeed(false, false);
846 }
847}
static TranscriptionToolBar & Get(AudacityProject &project)

References TranscriptionToolBar::Get(), and CommandContext::project.

Here is the call graph for this function:

◆ OnPlayAtSpeedCutPreview()

void TransportActions::Handler::OnPlayAtSpeedCutPreview ( const CommandContext context)
inline

Definition at line 859 of file TransportMenus.cpp.

860{
861 auto &project = context.project;
862 auto tb = &TranscriptionToolBar::Get( project );
863
864 if (tb) {
865 tb->PlayAtSpeed(false, true);
866 }
867}

References TranscriptionToolBar::Get(), and CommandContext::project.

Here is the call graph for this function:

◆ OnPlayAtSpeedLooped()

void TransportActions::Handler::OnPlayAtSpeedLooped ( const CommandContext context)
inline

Definition at line 849 of file TransportMenus.cpp.

850{
851 auto &project = context.project;
852 auto tb = &TranscriptionToolBar::Get( project );
853
854 if (tb) {
855 tb->PlayAtSpeed(true, false);
856 }
857}

References TranscriptionToolBar::Get(), and CommandContext::project.

Here is the call graph for this function:

◆ OnPlayBeforeAndAfterSelectionEnd()

void TransportActions::Handler::OnPlayBeforeAndAfterSelectionEnd ( const CommandContext context)
inline

Definition at line 798 of file TransportMenus.cpp.

800{
801 auto &project = context.project;
802
803 if (!MakeReadyToPlay(project))
804 return;
805
806 auto &viewInfo = ViewInfo::Get( project );
807 const auto &selectedRegion = viewInfo.selectedRegion;
808
809 double t0 = selectedRegion.t0();
810 double t1 = selectedRegion.t1();
811 double beforeLen;
812 gPrefs->Read(wxT("/AudioIO/CutPreviewBeforeLen"), &beforeLen, 2.0);
813 double afterLen;
814 gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
815
816 auto playOptions = DefaultPlayOptions( project );
817
818 if ( t1 - t0 > 0.0 && t1 - t0 < beforeLen )
820 context, SelectedRegion(t0, t1 + afterLen),
821 playOptions, PlayMode::oneSecondPlay);
822 else
824 context, SelectedRegion(t1 - beforeLen, t1 + afterLen),
825 playOptions, PlayMode::oneSecondPlay);
826}

References DefaultPlayOptions(), ViewInfo::Get(), gPrefs, anonymous_namespace{TransportMenus.cpp}::MakeReadyToPlay(), oneSecondPlay, TransportUtilities::PlayPlayRegionAndWait(), CommandContext::project, and wxT().

Here is the call graph for this function:

◆ OnPlayBeforeAndAfterSelectionStart()

void TransportActions::Handler::OnPlayBeforeAndAfterSelectionStart ( const CommandContext context)
inline

Definition at line 768 of file TransportMenus.cpp.

770{
771 auto &project = context.project;
772
773 if (!MakeReadyToPlay(project))
774 return;
775
776 auto &viewInfo = ViewInfo::Get( project );
777 const auto &selectedRegion = viewInfo.selectedRegion;
778
779 double t0 = selectedRegion.t0();
780 double t1 = selectedRegion.t1();
781 double beforeLen;
782 gPrefs->Read(wxT("/AudioIO/CutPreviewBeforeLen"), &beforeLen, 2.0);
783 double afterLen;
784 gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
785
786 auto playOptions = DefaultPlayOptions( project );
787
788 if ( t1 - t0 > 0.0 && t1 - t0 < afterLen )
790 context, SelectedRegion(t0 - beforeLen, t1),
791 playOptions, PlayMode::oneSecondPlay);
792 else
794 context, SelectedRegion(t0 - beforeLen, t0 + afterLen),
795 playOptions, PlayMode::oneSecondPlay);
796}

References DefaultPlayOptions(), ViewInfo::Get(), gPrefs, anonymous_namespace{TransportMenus.cpp}::MakeReadyToPlay(), oneSecondPlay, TransportUtilities::PlayPlayRegionAndWait(), CommandContext::project, and wxT().

Here is the call graph for this function:

◆ OnPlayBeforeSelectionEnd()

void TransportActions::Handler::OnPlayBeforeSelectionEnd ( const CommandContext context)
inline

Definition at line 720 of file TransportMenus.cpp.

721{
722 auto &project = context.project;
723
724 if( !MakeReadyToPlay(project) )
725 return;
726
727 auto &viewInfo = ViewInfo::Get( project );
728 const auto &selectedRegion = viewInfo.selectedRegion;
729
730 double t0 = selectedRegion.t0();
731 double t1 = selectedRegion.t1();
732 double beforeLen;
733 gPrefs->Read(wxT("/AudioIO/CutPreviewBeforeLen"), &beforeLen, 2.0);
734
735 auto playOptions = DefaultPlayOptions( project );
736
737 if ( t1 - t0 > 0.0 && t1 - t0 < beforeLen )
739 context, SelectedRegion(t0, t1),
740 playOptions, PlayMode::oneSecondPlay);
741 else
743 context, SelectedRegion(t1 - beforeLen, t1),
744 playOptions, PlayMode::oneSecondPlay);
745}

References DefaultPlayOptions(), ViewInfo::Get(), gPrefs, anonymous_namespace{TransportMenus.cpp}::MakeReadyToPlay(), oneSecondPlay, TransportUtilities::PlayPlayRegionAndWait(), CommandContext::project, and wxT().

Here is the call graph for this function:

◆ OnPlayBeforeSelectionStart()

void TransportActions::Handler::OnPlayBeforeSelectionStart ( const CommandContext context)
inline

Definition at line 672 of file TransportMenus.cpp.

673{
674 auto &project = context.project;
675
676 if( !MakeReadyToPlay(project) )
677 return;
678
679 auto &viewInfo = ViewInfo::Get( project );
680 const auto &selectedRegion = viewInfo.selectedRegion;
681
682 double t0 = selectedRegion.t0();
683 double beforeLen;
684 gPrefs->Read(wxT("/AudioIO/CutPreviewBeforeLen"), &beforeLen, 2.0);
685
686 auto playOptions = DefaultPlayOptions( project );
687
689 context, SelectedRegion(t0 - beforeLen, t0),
690 playOptions, PlayMode::oneSecondPlay);
691}

References DefaultPlayOptions(), ViewInfo::Get(), gPrefs, anonymous_namespace{TransportMenus.cpp}::MakeReadyToPlay(), oneSecondPlay, TransportUtilities::PlayPlayRegionAndWait(), CommandContext::project, and wxT().

Here is the call graph for this function:

◆ OnPlayCutPreview()

void TransportActions::Handler::OnPlayCutPreview ( const CommandContext context)
inline

Definition at line 828 of file TransportMenus.cpp.

829{
830 auto &project = context.project;
831
832 if ( !MakeReadyToPlay(project) )
833 return;
834
835 // Play with cut preview
837}
static void PlayCurrentRegionAndWait(const CommandContext &context, bool newDefault=false, bool cutpreview=false)

References anonymous_namespace{TransportMenus.cpp}::MakeReadyToPlay(), TransportUtilities::PlayCurrentRegionAndWait(), and CommandContext::project.

Here is the call graph for this function:

◆ OnPlayDefaultOrStop()

void TransportActions::Handler::OnPlayDefaultOrStop ( const CommandContext context)
inline

Definition at line 181 of file TransportMenus.cpp.

182{
183 auto &project = context.project;
185 return;
186
187 if( !MakeReadyToPlay(project) )
188 return;
189
190 // Now play in a loop
191 // Will automatically set mLastPlayMode
193}
static bool DoStopPlaying(const CommandContext &context)

References TransportUtilities::DoStopPlaying(), anonymous_namespace{TransportMenus.cpp}::MakeReadyToPlay(), TransportUtilities::PlayCurrentRegionAndWait(), and CommandContext::project.

Here is the call graph for this function:

◆ OnPlayOnceOrStop()

void TransportActions::Handler::OnPlayOnceOrStop ( const CommandContext context)
inline

Definition at line 167 of file TransportMenus.cpp.

168{
170 return;
172}
static void DoStartPlaying(const CommandContext &context, bool newDefault=false)

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

Here is the call graph for this function:

◆ OnPlayOneSecond()

void TransportActions::Handler::OnPlayOneSecond ( const CommandContext context)
inline

Definition at line 603 of file TransportMenus.cpp.

604{
605 auto &project = context.project;
606 if( !MakeReadyToPlay(project) )
607 return;
608
609 auto &trackPanel = TrackPanel::Get( project );
610 auto options = DefaultPlayOptions( project );
611
612 double pos = trackPanel.GetMostRecentXPos();
614 context, SelectedRegion(pos - 0.5, pos + 0.5),
615 options, PlayMode::oneSecondPlay);
616}
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:230

References DefaultPlayOptions(), TrackPanel::Get(), anonymous_namespace{TransportMenus.cpp}::MakeReadyToPlay(), oneSecondPlay, TransportUtilities::PlayPlayRegionAndWait(), and CommandContext::project.

Here is the call graph for this function:

◆ OnPlaySpeedDec()

void TransportActions::Handler::OnPlaySpeedDec ( const CommandContext context)
inline

Definition at line 889 of file TransportMenus.cpp.

890{
891 auto &project = context.project;
892 auto tb = &TranscriptionToolBar::Get( project );
893
894 if (tb) {
895 tb->AdjustPlaySpeed(-0.1f);
896 }
897}

References TranscriptionToolBar::Get(), and CommandContext::project.

Here is the call graph for this function:

◆ OnPlaySpeedInc()

void TransportActions::Handler::OnPlaySpeedInc ( const CommandContext context)
inline

Definition at line 879 of file TransportMenus.cpp.

880{
881 auto &project = context.project;
882 auto tb = &TranscriptionToolBar::Get( project );
883
884 if (tb) {
885 tb->AdjustPlaySpeed(0.1f);
886 }
887}

References TranscriptionToolBar::Get(), and CommandContext::project.

Here is the call graph for this function:

◆ OnPlayStopSelect()

void TransportActions::Handler::OnPlayStopSelect ( const CommandContext context)
inline

Definition at line 174 of file TransportMenus.cpp.

175{
177}
bool DoPlayStopSelect(bool click, bool shift)

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

Here is the call graph for this function:

◆ OnPlayToSelection()

void TransportActions::Handler::OnPlayToSelection ( const CommandContext context)
inline

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

626{
627 auto &project = context.project;
628
629 if( !MakeReadyToPlay(project) )
630 return;
631
632 auto &trackPanel = TrackPanel::Get( project );
633 auto &viewInfo = ViewInfo::Get( project );
634 const auto &selectedRegion = viewInfo.selectedRegion;
635
636 double pos = trackPanel.GetMostRecentXPos();
637
638 double t0,t1;
639 // check region between pointer and the nearest selection edge
640 if (fabs(pos - selectedRegion.t0()) <
641 fabs(pos - selectedRegion.t1())) {
642 t0 = t1 = selectedRegion.t0();
643 } else {
644 t0 = t1 = selectedRegion.t1();
645 }
646 if( pos < t1)
647 t0=pos;
648 else
649 t1=pos;
650
651 // JKC: oneSecondPlay mode disables auto scrolling
652 // On balance I think we should always do this in this function
653 // since you are typically interested in the sound EXACTLY
654 // where the cursor is.
655 // TODO: have 'playing attributes' such as 'with_autoscroll'
656 // rather than modes, since that's how we're now using the modes.
657
658 // An alternative, commented out below, is to disable autoscroll
659 // only when playing a short region, less than or equal to a second.
660// mLastPlayMode = ((t1-t0) > 1.0) ? normalPlay : oneSecondPlay;
661
662 auto playOptions = DefaultPlayOptions( project );
663
665 context, SelectedRegion(t0, t1),
666 playOptions, PlayMode::oneSecondPlay);
667}

References DefaultPlayOptions(), ViewInfo::Get(), TrackPanel::Get(), anonymous_namespace{TransportMenus.cpp}::MakeReadyToPlay(), oneSecondPlay, TransportUtilities::PlayPlayRegionAndWait(), and CommandContext::project.

Here is the call graph for this function:

◆ OnRecord()

void TransportActions::Handler::OnRecord ( const CommandContext context)
inline

Definition at line 200 of file TransportMenus.cpp.

201{
202 TransportUtilities::RecordAndWait(context, false);
203}
static void RecordAndWait(const CommandContext &context, bool altAppearance)

References TransportUtilities::RecordAndWait().

Here is the call graph for this function:

◆ OnRecord2ndChoice()

void TransportActions::Handler::OnRecord2ndChoice ( const CommandContext context)
inline

Definition at line 207 of file TransportMenus.cpp.

208{
210}

References TransportUtilities::RecordAndWait().

Here is the call graph for this function:

◆ OnRescanDevices()

void TransportActions::Handler::OnRescanDevices ( const CommandContext WXUNUSEDcontext)
inline

Definition at line 536 of file TransportMenus.cpp.

537{
539}
static DeviceManager * Instance()
Gets the singleton instance.

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

Here is the call graph for this function:

◆ OnSetPlayRegionIn()

void TransportActions::Handler::OnSetPlayRegionIn ( const CommandContext context)
inline

Definition at line 510 of file TransportMenus.cpp.

511{
512 auto &project = context.project;
513 auto &playRegion = ViewInfo::Get(project).playRegion;
514 if (!playRegion.Active())
517 true, false, SetLoopInTitle.Stripped());
518}
static const auto SetLoopInTitle
PlayRegion playRegion
Definition: ViewInfo.h:217
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.

Here is the call graph for this function:

◆ OnSetPlayRegionOut()

void TransportActions::Handler::OnSetPlayRegionOut ( const CommandContext context)
inline

Definition at line 521 of file TransportMenus.cpp.

522{
523 auto &project = context.project;
524 auto &playRegion = ViewInfo::Get(project).playRegion;
525 if (!playRegion.Active())
528 false, false, SetLoopOutTitle.Stripped());
529}
static const auto SetLoopOutTitle

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

Here is the call graph for this function:

◆ OnSetPlayRegionToSelection()

void TransportActions::Handler::OnSetPlayRegionToSelection ( const CommandContext context)
inline

Definition at line 531 of file TransportMenus.cpp.

532{
534}
void SetPlayRegionToSelection(AudacityProject &project)

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

Here is the call graph for this function:

◆ OnSetPlaySpeed()

void TransportActions::Handler::OnSetPlaySpeed ( const CommandContext context)
inline

Definition at line 869 of file TransportMenus.cpp.

870{
871 auto &project = context.project;
872 auto tb = &TranscriptionToolBar::Get( project );
873
874 if (tb) {
875 tb->ShowPlaySpeedDialog();
876 }
877}

References TranscriptionToolBar::Get(), and CommandContext::project.

Here is the call graph for this function:

◆ OnSoundActivated()

void TransportActions::Handler::OnSoundActivated ( const CommandContext context)
inline

Definition at line 541 of file TransportMenus.cpp.

542{
543 AudacityProject &project = context.project;
544
545 SoundActivatedRecordDialog dialog( &GetProjectFrame( project ) /* parent */ );
546 dialog.ShowModal();
547}
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:89
Configures sound activated recording.

References GetProjectFrame(), and CommandContext::project.

Here is the call graph for this function:

◆ OnStop()

void TransportActions::Handler::OnStop ( const CommandContext context)
inline

Definition at line 598 of file TransportMenus.cpp.

599{
601}
void Stop(bool stopStream=true)

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

Here is the call graph for this function:

◆ OnTimerRecord()

void TransportActions::Handler::OnTimerRecord ( const CommandContext context)
inline

Definition at line 212 of file TransportMenus.cpp.

213{
214 auto &project = context.project;
215 const auto &settings = ProjectSettings::Get( project );
216 auto &undoManager = UndoManager::Get( project );
217 auto &window = ProjectWindow::Get( project );
218
219 // MY: Due to improvements in how Timer Recording saves and/or exports
220 // it is now safer to disable Timer Recording when there is more than
221 // one open project.
222 if (AllProjects{}.size() > 1) {
224 XO(
225"Timer Recording cannot be used with more than one open project.\n\nPlease close any additional projects and try again."),
226 XO("Timer Recording"),
227 wxICON_INFORMATION | wxOK);
228 return;
229 }
230
231 // MY: If the project has unsaved changes then we no longer allow access
232 // to Timer Recording. This decision has been taken as the safest approach
233 // preventing issues surrounding "dirty" projects when Automatic Save/Export
234 // is used in Timer Recording.
235 if ((undoManager.UnsavedChanges()) &&
236 (TrackList::Get( project ).Any() || settings.EmptyCanBeDirty())) {
238 XO(
239"Timer Recording cannot be used while you have unsaved changes.\n\nPlease save or close this project and try again."),
240 XO("Timer Recording"),
241 wxICON_INFORMATION | wxOK);
242 return;
243 }
244
245 // We check the selected tracks to see if there is enough of them to accommodate
246 // all input channels and all of them have the same sampling rate.
247 // Those checks will be later performed by recording function anyway,
248 // but we want to warn the user about potential problems from the very start.
249 const auto selectedTracks{ GetPropertiesOfSelected(project) };
250 const int rateOfSelected{ selectedTracks.rateOfSelected };
251 const int numberOfSelected{ selectedTracks.numberOfSelected };
252 const bool allSameRate{ selectedTracks.allSameRate };
253
254 if (!allSameRate) {
255 AudacityMessageBox(XO("The tracks selected "
256 "for recording must all have the same sampling rate"),
257 XO("Mismatched Sampling Rates"),
258 wxICON_ERROR | wxCENTRE);
259
260 return;
261 }
262
263 const auto existingTracks{ ProjectAudioManager::ChooseExistingRecordingTracks(project, true, rateOfSelected) };
264 if (existingTracks.empty()) {
265 if (numberOfSelected > 0 && rateOfSelected !=
266 ProjectRate::Get(project).GetRate()) {
268 "Too few tracks are selected for recording at this sample rate.\n"
269 "(Audacity requires two channels at the same sample rate for\n"
270 "each stereo track)"),
271 XO("Too Few Compatible Tracks Selected"),
272 wxICON_ERROR | wxCENTRE);
273
274 return;
275 }
276 }
277
278 // We use this variable to display "Current Project" in the Timer Recording
279 // save project field
280 bool bProjectSaved = !ProjectFileIO::Get( project ).IsModified();
281
282 //we break the prompting and waiting dialogs into two sections
283 //because they both give the user a chance to click cancel
284 //and therefore remove the newly inserted track.
285
286 TimerRecordDialog dialog(
287 &window, project, bProjectSaved); /* parent, project, project saved? */
288 int modalResult = dialog.ShowModal();
289 if (modalResult == wxID_CANCEL)
290 {
291 // Cancelled before recording - don't need to do anything.
292 }
293 else
294 {
295 // Bug #2382
296 // Allow recording to start at current cursor position.
297 #if 0
298 // Timer Record should not record into a selection.
299 bool bPreferNewTrack;
300 gPrefs->Read("/GUI/PreferNewTrackRecord",&bPreferNewTrack, false);
301 if (bPreferNewTrack) {
302 window.Rewind(false);
303 } else {
304 window.SkipEnd(false);
305 }
306 #endif
307
308 int iTimerRecordingOutcome = dialog.RunWaitDialog();
309 switch (iTimerRecordingOutcome) {
311 // Canceled on the wait dialog
313 break;
315 // RunWaitDialog() shows the "wait for start" as well as "recording"
316 // dialog if it returned POST_TIMER_RECORD_CANCEL it means the user
317 // cancelled while the recording, so throw out the fresh track.
318 // However, we can't undo it here because the PushState() is called in TrackPanel::OnTimer(),
319 // which is blocked by this function.
320 // so instead we mark a flag to undo it there.
322 break;
324 // No action required
325 break;
327 wxTheApp->CallAfter( []{
328 // Simulate the application Exit menu item
329 wxCommandEvent evt{ wxEVT_MENU, wxID_EXIT };
330 wxTheApp->AddPendingEvent( evt );
331 } );
333 break;
334
335#ifdef __WINDOWS__
336 case POST_TIMER_RECORD_RESTART:
337 // Restart System
339 system("shutdown /r /f /t 30");
340 break;
341 case POST_TIMER_RECORD_SHUTDOWN:
342 // Shutdown System
344 system("shutdown /s /f /t 30");
345 break;
346#endif
347 }
348 }
349}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
#define XO(s)
Definition: Internat.h:31
PropertiesOfSelected GetPropertiesOfSelected(const AudacityProject &proj)
@ POST_TIMER_RECORD_CLOSE
@ POST_TIMER_RECORD_CANCEL
@ POST_TIMER_RECORD_CANCEL_WAIT
@ POST_TIMER_RECORD_NOTHING
static Settings & settings()
Definition: TrackInfo.cpp:87
size_t size() const
Definition: Project.cpp:17
static WaveTrackArray ChooseExistingRecordingTracks(AudacityProject &proj, bool selectedOnly, double targetRate=RATE_NOT_SELECTED)
static ProjectFileIO & Get(AudacityProject &project)
bool IsModified() const
static ProjectHistory & Get(AudacityProject &project)
static ProjectManager & Get(AudacityProject &project)
void SetSkipSavePrompt(bool bSkip)
static ProjectRate & Get(AudacityProject &project)
Definition: ProjectRate.cpp:28
static ProjectSettings & Get(AudacityProject &project)
static ProjectWindow & Get(AudacityProject &project)
Dialog for Timer Record, i.e., timed or long recording.
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1437
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:486
static UndoManager & Get(AudacityProject &project)
Definition: UndoManager.cpp:67

References TrackList::Any(), AudacityMessageBox(), ProjectAudioManager::ChooseExistingRecordingTracks(), ProjectHistory::Get(), UndoManager::Get(), ProjectRate::Get(), TrackList::Get(), ProjectAudioManager::Get(), ProjectFileIO::Get(), ProjectManager::Get(), ProjectSettings::Get(), ProjectWindow::Get(), GetPropertiesOfSelected(), anonymous_namespace{TimeTrack.cpp}::GetRate(), gPrefs, ProjectFileIO::IsModified(), POST_TIMER_RECORD_CANCEL, POST_TIMER_RECORD_CANCEL_WAIT, POST_TIMER_RECORD_CLOSE, POST_TIMER_RECORD_NOTHING, CommandContext::project, PropertiesOfSelected::rateOfSelected, ProjectHistory::RollbackState(), TimerRecordDialog::RunWaitDialog(), ProjectManager::SetSkipSavePrompt(), ProjectAudioManager::SetTimerRecordCancelled(), settings(), AllProjects::size(), and XO.

Here is the call graph for this function:

◆ OnTogglePinnedHead()

void TransportActions::Handler::OnTogglePinnedHead ( const CommandContext context)
inline

Definition at line 558 of file TransportMenus.cpp.

559{
561}
static AdornedRulerPanel & Get(AudacityProject &project)

References AdornedRulerPanel::Get(), CommandContext::project, and AdornedRulerPanel::TogglePinnedHead().

Here is the call graph for this function:

◆ OnTogglePlayRecording()

void TransportActions::Handler::OnTogglePlayRecording ( const CommandContext WXUNUSEDcontext)
inline

Definition at line 563 of file TransportMenus.cpp.

564{
565 bool Duplex;
566#ifdef EXPERIMENTAL_DA
567 gPrefs->Read(wxT("/AudioIO/Duplex"), &Duplex, false);
568#else
569 gPrefs->Read(wxT("/AudioIO/Duplex"), &Duplex, true);
570#endif
571 gPrefs->Write(wxT("/AudioIO/Duplex"), !Duplex);
572 gPrefs->Flush();
574}
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
static void ModifyAllProjectToolbarMenus()
Definition: Menus.cpp:592

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

Here is the call graph for this function:

◆ OnTogglePlayRegion()

void TransportActions::Handler::OnTogglePlayRegion ( const CommandContext context)
inline

Definition at line 500 of file TransportMenus.cpp.

501{
503}
void TogglePlayRegion(AudacityProject &project)

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

Here is the call graph for this function:

◆ OnToggleSoundActivated()

void TransportActions::Handler::OnToggleSoundActivated ( const CommandContext WXUNUSEDcontext)
inline

Definition at line 549 of file TransportMenus.cpp.

550{
551 bool pause;
552 gPrefs->Read(wxT("/AudioIO/SoundActivatedRecord"), &pause, false);
553 gPrefs->Write(wxT("/AudioIO/SoundActivatedRecord"), !pause);
554 gPrefs->Flush();
556}

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

Here is the call graph for this function:

◆ OnToggleSWPlaythrough()

void TransportActions::Handler::OnToggleSWPlaythrough ( const CommandContext WXUNUSEDcontext)
inline

Definition at line 576 of file TransportMenus.cpp.

577{
578 bool SWPlaythrough;
579 gPrefs->Read(wxT("/AudioIO/SWPlaythrough"), &SWPlaythrough, false);
580 gPrefs->Write(wxT("/AudioIO/SWPlaythrough"), !SWPlaythrough);
581 gPrefs->Flush();
583}

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

Here is the call graph for this function:

The documentation for this struct was generated from the following file: