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()) && (!TrackList::Get(project).empty() )) {
1208 XO(
1209"Timer Recording cannot be used while you have unsaved changes.\n\nPlease save or close this project and try again."),
1210 XO("Timer Recording"),
1211 wxICON_INFORMATION | wxOK);
1212 return;
1213 }
1214
1215 // We check the selected tracks to see if there is enough of them to accommodate
1216 // all input channels and all of them have the same sampling rate.
1217 // Those checks will be later performed by recording function anyway,
1218 // but we want to warn the user about potential problems from the very start.
1219 const auto selectedTracks{ GetPropertiesOfSelected(project) };
1220 const int rateOfSelected{ selectedTracks.rateOfSelected };
1221 const bool anySelected{ selectedTracks.anySelected };
1222 const bool allSameRate{ selectedTracks.allSameRate };
1223
1224 if (!allSameRate) {
1225 AudacityMessageBox(XO("The tracks selected "
1226 "for recording must all have the same sampling rate"),
1227 XO("Mismatched Sampling Rates"),
1228 wxICON_ERROR | wxCENTRE);
1229
1230 return;
1231 }
1232
1233 // Only need the size
1234 const auto existingTracks =
1236 rateOfSelected);
1237 if (existingTracks.empty()) {
1238 if (anySelected && rateOfSelected !=
1241 "Too few tracks are selected for recording at this sample rate.\n"
1242 "(Audacity requires two channels at the same sample rate for\n"
1243 "each stereo track)"),
1244 XO("Too Few Compatible Tracks Selected"),
1245 wxICON_ERROR | wxCENTRE);
1246
1247 return;
1248 }
1249 }
1250
1251 // We use this variable to display "Current Project" in the Timer Recording
1252 // save project field
1253 bool bProjectSaved = !ProjectFileIO::Get( project ).IsModified();
1254
1255 //we break the prompting and waiting dialogs into two sections
1256 //because they both give the user a chance to click cancel
1257 //and therefore remove the newly inserted track.
1258
1259 TimerRecordDialog dialog(
1260 &window, project, bProjectSaved); /* parent, project, project saved? */
1261 int modalResult = dialog.ShowModal();
1262 if (modalResult == wxID_CANCEL)
1263 {
1264 // Cancelled before recording - don't need to do anything.
1265 }
1266 else
1267 {
1268 // Bug #2382
1269 // Allow recording to start at current cursor position.
1270 #if 0
1271 // Timer Record should not record into a selection.
1272 bool bPreferNewTrack;
1273 gPrefs->Read("/GUI/PreferNewTrackRecord",&bPreferNewTrack, false);
1274 if (bPreferNewTrack) {
1275 window.Rewind(false);
1276 } else {
1277 window.SkipEnd(false);
1278 }
1279 #endif
1280
1281 int iTimerRecordingOutcome = dialog.RunWaitDialog();
1282 switch (iTimerRecordingOutcome) {
1284 // Canceled on the wait dialog
1286 break;
1288 // RunWaitDialog() shows the "wait for start" as well as "recording"
1289 // dialog if it returned POST_TIMER_RECORD_CANCEL it means the user
1290 // cancelled while the recording, so throw out the fresh track.
1291 // However, we can't undo it here because the PushState() is called in TrackPanel::OnTimer(),
1292 // which is blocked by this function.
1293 // so instead we mark a flag to undo it there.
1295 break;
1297 // No action required
1298 break;
1300 wxTheApp->CallAfter( []{
1301 // Simulate the application Exit menu item
1302 wxCommandEvent evt{ wxEVT_MENU, wxID_EXIT };
1303 wxTheApp->AddPendingEvent( evt );
1304 } );
1306 break;
1307
1308#ifdef __WINDOWS__
1309 case POST_TIMER_RECORD_RESTART:
1310 // Restart System
1312 system("shutdown /r /f /t 30");
1313 break;
1314 case POST_TIMER_RECORD_SHUTDOWN:
1315 // Shutdown System
1317 system("shutdown /s /f /t 30");
1318 break;
1319#endif
1320 }
1321 }
1322}
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:51
size_t size() const
Definition: Project.cpp:17
AudacityProject & project
static WritableSampleTrackArray ChooseExistingRecordingTracks(AudacityProject &proj, bool selectedOnly, double targetRate=RATE_NOT_SELECTED)
Find suitable tracks to record into, or return an empty array.
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:758
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314
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:182

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 1327 of file TimerRecordDialog.cpp.