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

Functions

void OnTimerRecord (const CommandContext &context)
 

Variables

StringSetting DefaultExportAudioFormat { L"/TimerRecordDialog/ExportFormat", L"WAV" }
 
StringSetting DefaultExportAudioPath { L"/TimerRecordDialog/ExportPath", L"" }
 
const auto CanStopFlags = AudioIONotBusyFlag() | CanStopAudioStreamFlag()
 
AttachedItem sAttachment
 

Function Documentation

◆ OnTimerRecord()

void anonymous_namespace{TimerRecordDialog.cpp}::OnTimerRecord ( const CommandContext context)

Definition at line 1183 of file TimerRecordDialog.cpp.

1184{
1185 auto &project = context.project;
1186 const auto &settings = ProjectSettings::Get( project );
1187 auto &undoManager = UndoManager::Get( project );
1188 auto &window = GetProjectFrame(project);
1189
1190 // MY: Due to improvements in how Timer Recording saves and/or exports
1191 // it is now safer to disable Timer Recording when there is more than
1192 // one open project.
1193 if (AllProjects{}.size() > 1) {
1195 XO(
1196"Timer Recording cannot be used with more than one open project.\n\nPlease close any additional projects and try again."),
1197 XO("Timer Recording"),
1198 wxICON_INFORMATION | wxOK);
1199 return;
1200 }
1201
1202 // MY: If the project has unsaved changes then we no longer allow access
1203 // to Timer Recording. This decision has been taken as the safest approach
1204 // preventing issues surrounding "dirty" projects when Automatic Save/Export
1205 // is used in Timer Recording.
1206 if ((undoManager.UnsavedChanges()) &&
1207 (!TrackList::Get(project).empty() || settings.EmptyCanBeDirty())) {
1209 XO(
1210"Timer Recording cannot be used while you have unsaved changes.\n\nPlease save or close this project and try again."),
1211 XO("Timer Recording"),
1212 wxICON_INFORMATION | wxOK);
1213 return;
1214 }
1215
1216 // We check the selected tracks to see if there is enough of them to accommodate
1217 // all input channels and all of them have the same sampling rate.
1218 // Those checks will be later performed by recording function anyway,
1219 // but we want to warn the user about potential problems from the very start.
1220 const auto selectedTracks{ GetPropertiesOfSelected(project) };
1221 const int rateOfSelected{ selectedTracks.rateOfSelected };
1222 const bool anySelected{ selectedTracks.anySelected };
1223 const bool allSameRate{ selectedTracks.allSameRate };
1224
1225 if (!allSameRate) {
1226 AudacityMessageBox(XO("The tracks selected "
1227 "for recording must all have the same sampling rate"),
1228 XO("Mismatched Sampling Rates"),
1229 wxICON_ERROR | wxCENTRE);
1230
1231 return;
1232 }
1233
1234 // Only need the size
1235 const auto existingTracks =
1237 rateOfSelected);
1238 if (existingTracks.empty()) {
1239 if (anySelected && rateOfSelected !=
1242 "Too few tracks are selected for recording at this sample rate.\n"
1243 "(Audacity requires two channels at the same sample rate for\n"
1244 "each stereo track)"),
1245 XO("Too Few Compatible Tracks Selected"),
1246 wxICON_ERROR | wxCENTRE);
1247
1248 return;
1249 }
1250 }
1251
1252 // We use this variable to display "Current Project" in the Timer Recording
1253 // save project field
1254 bool bProjectSaved = !ProjectFileIO::Get( project ).IsModified();
1255
1256 //we break the prompting and waiting dialogs into two sections
1257 //because they both give the user a chance to click cancel
1258 //and therefore remove the newly inserted track.
1259
1260 TimerRecordDialog dialog(
1261 &window, project, bProjectSaved); /* parent, project, project saved? */
1262 int modalResult = dialog.ShowModal();
1263 if (modalResult == wxID_CANCEL)
1264 {
1265 // Cancelled before recording - don't need to do anything.
1266 }
1267 else
1268 {
1269 // Bug #2382
1270 // Allow recording to start at current cursor position.
1271 #if 0
1272 // Timer Record should not record into a selection.
1273 bool bPreferNewTrack;
1274 gPrefs->Read("/GUI/PreferNewTrackRecord",&bPreferNewTrack, false);
1275 if (bPreferNewTrack) {
1276 window.Rewind(false);
1277 } else {
1278 window.SkipEnd(false);
1279 }
1280 #endif
1281
1282 int iTimerRecordingOutcome = dialog.RunWaitDialog();
1283 switch (iTimerRecordingOutcome) {
1285 // Canceled on the wait dialog
1287 break;
1289 // RunWaitDialog() shows the "wait for start" as well as "recording"
1290 // dialog if it returned POST_TIMER_RECORD_CANCEL it means the user
1291 // cancelled while the recording, so throw out the fresh track.
1292 // However, we can't undo it here because the PushState() is called in TrackPanel::OnTimer(),
1293 // which is blocked by this function.
1294 // so instead we mark a flag to undo it there.
1296 break;
1298 // No action required
1299 break;
1301 wxTheApp->CallAfter( []{
1302 // Simulate the application Exit menu item
1303 wxCommandEvent evt{ wxEVT_MENU, wxID_EXIT };
1304 wxTheApp->AddPendingEvent( evt );
1305 } );
1307 break;
1308
1309#ifdef __WINDOWS__
1310 case POST_TIMER_RECORD_RESTART:
1311 // Restart System
1313 system("shutdown /r /f /t 30");
1314 break;
1315 case POST_TIMER_RECORD_SHUTDOWN:
1316 // Shutdown System
1318 system("shutdown /s /f /t 30");
1319 break;
1320#endif
1321 }
1322 }
1323}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
XO("Cut/Copy/Paste")
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
PropertiesOfSelected GetPropertiesOfSelected(const AudacityProject &proj)
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 ...
const auto project
@ POST_TIMER_RECORD_CLOSE
@ POST_TIMER_RECORD_CANCEL
@ POST_TIMER_RECORD_CANCEL_WAIT
@ POST_TIMER_RECORD_NOTHING
static Settings & settings()
Definition: TrackInfo.cpp:69
size_t size() const
Definition: Project.cpp:17
AudacityProject & project
static WritableSampleTrackArray ChooseExistingRecordingTracks(AudacityProject &proj, bool selectedOnly, double targetRate=RATE_NOT_SELECTED)
static ProjectAudioManager & Get(AudacityProject &project)
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)
Dialog for Timer Record, i.e., timed or long recording.
bool empty() const
Definition: Track.cpp:955
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:347
static UndoManager & Get(AudacityProject &project)
Definition: UndoManager.cpp:71
virtual bool Read(const wxString &key, bool *value) const =0
double GetRate(const Track &track)
Definition: TimeTrack.cpp:196

References AudacityMessageBox(), ProjectAudioManager::ChooseExistingRecordingTracks(), TrackList::empty(), ProjectFileIO::Get(), ProjectHistory::Get(), UndoManager::Get(), ProjectRate::Get(), TrackList::Get(), ProjectAudioManager::Get(), ProjectManager::Get(), ProjectSettings::Get(), GetProjectFrame(), 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, project, PropertiesOfSelected::rateOfSelected, audacity::BasicSettings::Read(), ProjectHistory::RollbackState(), TimerRecordDialog::RunWaitDialog(), ProjectManager::SetSkipSavePrompt(), ProjectAudioManager::SetTimerRecordCancelled(), settings(), AllProjects::size(), and XO().

Here is the call graph for this function:

Variable Documentation

◆ CanStopFlags

const auto anonymous_namespace{TimerRecordDialog.cpp}::CanStopFlags = AudioIONotBusyFlag() | CanStopAudioStreamFlag()

◆ DefaultExportAudioFormat

StringSetting anonymous_namespace{TimerRecordDialog.cpp}::DefaultExportAudioFormat { L"/TimerRecordDialog/ExportFormat", L"WAV" }

Definition at line 106 of file TimerRecordDialog.cpp.

Referenced by TimerRecordDialog::ExecutePostRecordActions().

◆ DefaultExportAudioPath

StringSetting anonymous_namespace{TimerRecordDialog.cpp}::DefaultExportAudioPath { L"/TimerRecordDialog/ExportPath", L"" }

Definition at line 107 of file TimerRecordDialog.cpp.

Referenced by TimerRecordDialog::ExecutePostRecordActions().

◆ sAttachment

AttachedItem anonymous_namespace{TimerRecordDialog.cpp}::sAttachment
Initial value:
{
Command( wxT("TimerRecord"), XXO("&Timer Record..."),
OnTimerRecord, CanStopFlags, wxT("Shift+T") ),
{ wxT("Transport/Basic/Record"),
{ OrderingHint::After, wxT("Record2ndChoice") } }
}
wxT("CloseDown"))
XXO("&Cut/Copy/Paste Toolbar")
constexpr auto Command
Definition: MenuRegistry.h:456
void OnTimerRecord(const CommandContext &context)

Definition at line 1328 of file TimerRecordDialog.cpp.