// New events for timer recording automation void TimerRecordDialog::OnAutoSavePathButton_Click(wxCommandEvent& WXUNUSED(event)) { wxString fName = FileNames::SelectFile(FileNames::Operation::Export, _("Save Timer Recording As"), m_fnAutoSaveFile.GetPath(), m_fnAutoSaveFile.GetFullName(), wxT("aup"), _("Audacity projects") + wxT(" (*.aup)|*.aup"), wxFD_SAVE | wxRESIZE_BORDER, this); if (fName == wxT("")) return; AudacityProject* pProject = GetActiveProject(); // If project already exists then abort - we do not allow users to overwrite an existing project // unless it is the current project. if (wxFileExists(fName) && (pProject->GetFileName() != fName)) { AudacityMessageDialog m( NULL, _("The selected file name could not be used\nfor Timer Recording because it \ would overwrite another project.\nPlease try again and select an original name."), _("Error Saving Timer Recording Project"), wxOK|wxICON_ERROR); m.ShowModal(); return; } // Set this boolean to false so we now do a SaveAs at the end of the recording // unless we're saving the current project. m_bProjectAlreadySaved = pProject->GetFileName() == fName? true : false; m_fnAutoSaveFile = fName; m_fnAutoSaveFile.SetExt(wxT("aup")); this->UpdateTextBoxControls(); }
void ContrastDialog::OnExport(wxCommandEvent & WXUNUSED(event)) { // TODO: Handle silence checks better (-infinity dB) AudacityProject * project = GetActiveProject(); wxString fName = wxT("contrast.txt"); fName = FileNames::SelectFile(FileNames::Operation::Export, _("Export Contrast Result As:"), wxEmptyString, fName, wxT("txt"), wxT("*.txt"), wxFD_SAVE | wxRESIZE_BORDER, this); if (fName == wxT("")) return; wxTextFile f(fName); #ifdef __WXMAC__ wxFile{}.Create(fName); #else f.Create(); #endif f.Open(); if (!f.IsOpened()) { AudacityMessageBox( wxString::Format( _("Couldn't write to file: %s"), fName) ); return; } f.AddLine(wxT("===================================")); /* i18n-hint: WCAG abbreviates Web Content Accessibility Guidelines */ f.AddLine(_("WCAG 2.0 Success Criteria 1.4.7 Contrast Results")); f.AddLine(wxT("")); f.AddLine(wxString::Format(_("Filename = %s."), project->GetFileName() )); f.AddLine(wxT("")); f.AddLine(_("Foreground")); float t = (float)mForegroundStartT->GetValue(); int h = (int)(t/3600); // there must be a standard function for this! int m = (int)((t - h*3600)/60); float s = t - h*3600.0 - m*60.0; f.AddLine(wxString::Format(_("Time started = %2d hour(s), %2d minute(s), %.2f seconds."), h, m, s )); t = (float)mForegroundEndT->GetValue(); h = (int)(t/3600); m = (int)((t - h*3600)/60); s = t - h*3600.0 - m*60.0; f.AddLine(wxString::Format(_("Time ended = %2d hour(s), %2d minute(s), %.2f seconds."), h, m, s )); f.AddLine( FormatRMSMessage( mForegroundIsDefined ? &foregrounddB : nullptr ) ); f.AddLine(wxT("")); f.AddLine(_("Background")); t = (float)mBackgroundStartT->GetValue(); h = (int)(t/3600); m = (int)((t - h*3600)/60); s = t - h*3600.0 - m*60.0; f.AddLine(wxString::Format(_("Time started = %2d hour(s), %2d minute(s), %.2f seconds."), h, m, s )); t = (float)mBackgroundEndT->GetValue(); h = (int)(t/3600); m = (int)((t - h*3600)/60); s = t - h*3600.0 - m*60.0; f.AddLine(wxString::Format(_("Time ended = %2d hour(s), %2d minute(s), %.2f seconds."), h, m, s )); f.AddLine( FormatRMSMessage( mBackgroundIsDefined ? &backgrounddB : nullptr ) ); f.AddLine(wxT("")); f.AddLine(_("Results")); float diffdB = foregrounddB - backgrounddB; f.AddLine( FormatDifferenceForExport( diffdB ) ); if( diffdB > 20. ) f.AddLine(_("Success Criteria 1.4.7 of WCAG 2.0: Pass")); else f.AddLine(_("Success Criteria 1.4.7 of WCAG 2.0: Fail")); f.AddLine(wxT("")); f.AddLine(_("Data gathered")); wxString sNow; wxDateTime now = wxDateTime::Now(); int year = now.GetYear(); wxDateTime::Month month = now.GetMonth(); wxString monthName = now.GetMonthName(month); int dom = now.GetDay(); int hour = now.GetHour(); int minute = now.GetMinute(); int second = now.GetSecond(); sNow = wxString::Format(wxT("%d %s %02d %02dh %02dm %02ds"), dom, monthName, year, hour, minute, second); f.AddLine(sNow); f.AddLine(wxT("===================================")); f.AddLine(wxT("")); #ifdef __WXMAC__ f.Write(wxTextFileType_Mac); #else f.Write(); #endif f.Close(); }
// TIDY-ME: Get rid of special commands and make them part of the // 'menu' system (but not showing on the menu) // // ======= IMPORTANT ======== // Special Commands are a KLUDGE whilst we wait for a better system to handle the menu // commands from batch mode. // // Really we should be using a similar (or same) system to that used for effects // so that parameters can be passed to the commands. Many of the menu // commands take a selection as their parameter. // // If you find yourself adding lots of existing commands from the menus here, STOP // and think again. // ======= IMPORTANT ======== // CLEANSPEECH remnant bool BatchCommands::ApplySpecialCommand(int WXUNUSED(iCommand), const wxString command,const wxString params) { if (ReportAndSkip(command, params)) return true; AudacityProject *project = GetActiveProject(); int numChannels = 1; //used to switch between mono and stereo export if (IsMono()) { numChannels = 1; //export in mono } else { numChannels = 2; //export in stereo } wxString filename; wxString extension; // required for correct message if (command == wxT("ExportWAV")) extension = wxT(".wav"); else if (command == wxT("ExportOgg")) extension = wxT(".ogg"); else if (command == wxT("ExportFLAC")) extension = wxT(".flac"); else extension = wxT(".mp3"); if (mFileName.IsEmpty()) { filename = project->BuildCleanFileName(project->GetFileName(), extension); } else { filename = project->BuildCleanFileName(mFileName, extension); } // We have a command index, but we don't use it! // TODO: Make this special-batch-command code use the menu item code.... // FIXME: No error reporting on write file failure in batch mode. if (command == wxT("NoAction")) { return true; } else if (!mFileName.IsEmpty() && command == wxT("Import")) { // historically this was in use, now ignored if there return true; } else if (command == wxT("ExportMP3_56k_before")) { filename.Replace(wxT("cleaned/"), wxT("cleaned/MasterBefore_"), false); return WriteMp3File(filename, 56); } else if (command == wxT("ExportMP3_56k_after")) { filename.Replace(wxT("cleaned/"), wxT("cleaned/MasterAfter_"), false); return WriteMp3File(filename, 56); } else if (command == wxT("StereoToMono")) { // StereoToMono is an effect masquerading as a menu item. Effect * f = EffectManager::Get().GetEffectByIdentifier(wxT("StereoToMono")); if (f != NULL) { return ApplyEffectCommand(f, command, params); } wxMessageBox(_("Stereo to Mono Effect not found")); return false; } else if (command == wxT("ExportMP3")) { return WriteMp3File(filename, 0); // 0 bitrate means use default/current } else if (command == wxT("ExportWAV")) { filename.Replace(wxT(".mp3"), wxT(".wav"), false); double endTime = GetEndTime(); if (endTime <= 0.0f) { return false; } return mExporter.Process(project, numChannels, wxT("WAV"), filename, false, 0.0, endTime); } else if (command == wxT("ExportOgg")) { #ifdef USE_LIBVORBIS filename.Replace(wxT(".mp3"), wxT(".ogg"), false); double endTime = GetEndTime(); if (endTime <= 0.0f) { return false; } return mExporter.Process(project, numChannels, wxT("OGG"), filename, false, 0.0, endTime); #else wxMessageBox(_("Ogg Vorbis support is not included in this build of Audacity")); return false; #endif } else if (command == wxT("ExportFLAC")) { #ifdef USE_LIBFLAC filename.Replace(wxT(".mp3"), wxT(".flac"), false); double endTime = GetEndTime(); if (endTime <= 0.0f) { return false; } return mExporter.Process(project, numChannels, wxT("FLAC"), filename, false, 0.0, endTime); #else wxMessageBox(_("FLAC support is not included in this build of Audacity")); return false; #endif } wxMessageBox(wxString::Format(_("Command %s not implemented yet"),command.c_str())); return false; }
void ContrastDialog::OnExport(wxCommandEvent & WXUNUSED(event)) { // TODO: Handle silence checks better (-infinity dB) AudacityProject * project = GetActiveProject(); wxString fName = wxT("contrast.txt"); fName = FileSelector(_("Export Contrast Result As:"), wxEmptyString, fName, wxT("txt"), wxT("*.txt"), wxFD_SAVE | wxRESIZE_BORDER, this); if (fName == wxT("")) return; wxTextFile f(fName); #ifdef __WXMAC__ wxFile{}.Create(fName); #else f.Create(); #endif f.Open(); if (!f.IsOpened()) { wxMessageBox(_("Couldn't write to file: ") + fName); return; } f.AddLine(wxT("===================================")); f.AddLine(_("WCAG 2.0 Success Criteria 1.4.7 Contrast Results")); f.AddLine(wxT("")); f.AddLine(wxString::Format(_("Filename = %s."), project->GetFileName().c_str() )); f.AddLine(wxT("")); f.AddLine(_("Foreground")); float t = (float)mForegroundStartT->GetValue(); int h = (int)(t/3600); // there must be a standard function for this! int m = (int)((t - h*3600)/60); float s = t - h*3600.0 - m*60.0; f.AddLine(wxString::Format(_("Time started = %2d hour(s), %2d minute(s), %.2f seconds."), h, m, s )); t = (float)mForegroundEndT->GetValue(); h = (int)(t/3600); m = (int)((t - h*3600)/60); s = t - h*3600.0 - m*60.0; f.AddLine(wxString::Format(_("Time ended = %2d hour(s), %2d minute(s), %.2f seconds."), h, m, s )); if(mForegroundIsDefined) if( fabs(foregrounddB) != std::numeric_limits<float>::infinity() ) f.AddLine(wxString::Format(_("Average RMS = %.2f dB."), foregrounddB )); else f.AddLine(wxString::Format(_("Average RMS = zero.") )); else f.AddLine(wxString::Format(_("Average RMS = dB."))); f.AddLine(wxT("")); f.AddLine(_("Background")); t = (float)mBackgroundStartT->GetValue(); h = (int)(t/3600); m = (int)((t - h*3600)/60); s = t - h*3600.0 - m*60.0; f.AddLine(wxString::Format(_("Time started = %2d hour(s), %2d minute(s), %.2f seconds."), h, m, s )); t = (float)mBackgroundEndT->GetValue(); h = (int)(t/3600); m = (int)((t - h*3600)/60); s = t - h*3600.0 - m*60.0; f.AddLine(wxString::Format(_("Time ended = %2d hour(s), %2d minute(s), %.2f seconds."), h, m, s )); if(mBackgroundIsDefined) if( fabs(backgrounddB) != std::numeric_limits<float>::infinity() ) f.AddLine(wxString::Format(_("Average RMS = %.2f dB."), backgrounddB )); else f.AddLine(wxString::Format(_("Average RMS = zero.") )); else f.AddLine(wxString::Format(_("Average RMS = dB."))); f.AddLine(wxT("")); f.AddLine(_("Results")); float diffdB = foregrounddB - backgrounddB; if( diffdB != diffdB ) //test for NaN, reliant on IEEE implementation f.AddLine(wxString::Format(_("Difference is indeterminate.") )); else if( fabs(diffdB) != std::numeric_limits<float>::infinity() ) f.AddLine(wxString::Format(_("Difference = %.2f Average RMS dB."), diffdB )); else f.AddLine(wxString::Format(_("Difference = infinite Average RMS dB."))); if( diffdB > 20. ) f.AddLine(_("Success Criteria 1.4.7 of WCAG 2.0: Pass")); else f.AddLine(_("Success Criteria 1.4.7 of WCAG 2.0: Fail")); f.AddLine(wxT("")); f.AddLine(_("Data gathered")); wxString sNow; wxDateTime now = wxDateTime::Now(); int year = now.GetYear(); wxDateTime::Month month = now.GetMonth(); wxString monthName = now.GetMonthName(month); int dom = now.GetDay(); int hour = now.GetHour(); int minute = now.GetMinute(); int second = now.GetSecond(); sNow = wxString::Format(wxT("%d %s %02d %02dh %02dm %02ds"), dom, monthName.c_str(), year, hour, minute, second); f.AddLine(sNow); f.AddLine(wxT("===================================")); f.AddLine(wxT("")); #ifdef __WXMAC__ f.Write(wxTextFileType_Mac); #else f.Write(); #endif f.Close(); }
// TIDY-ME: Get rid of special commands and make them part of the // 'menu' system (but not showing on the menu) // // ======= IMPORTANT ======== // Special Commands are a KLUDGE whilst we wait for a better system to handle the menu // commands from batch mode. // // Really we should be using a similar (or same) system to that used for effects // so that parameters can be passed to the commands. Many of the menu // commands take a selection as their parameter. // // If you find yourself adding lots of existing commands from the menus here, STOP // and think again. // ======= IMPORTANT ======== bool BatchCommands::ApplySpecialCommand(int iCommand, const wxString command,const wxString params) { AudacityProject *project = GetActiveProject(); wxString filename; int numChannels = 1; //used to switch between mono and stereo export if (IsMono()) { numChannels = 1; //export in mono } else { numChannels = 2; //export in stereo } if( ReportAndSkip(command, params)) return true; if (mFileName.IsEmpty()) { filename = project->BuildCleanFileName(project->GetFileName()); } else { filename = project->BuildCleanFileName(mFileName); } // We have a command index, but we don't use it! // TODO: Make this special-batch-command code use the menu item code.... // FIX-ME: No error reporting on write file failure in batch mode. if( command == wxT("No Action")){ return true; } else if (!mFileName.IsEmpty() && command == wxT("Import") ){ project->OnRemoveTracks(); project->Import(mFileName); project->OnSelectAll(); return true; } else if (command == wxT("Save Hq Master1")){ filename.Replace(wxT("cleaned/"), wxT("cleaned/MasterBefore_"), false); return WriteMp3File( filename, 56 ); } else if (command == wxT("Save Hq Master2")){ filename.Replace(wxT("cleaned/"), wxT("cleaned/MasterAfter_"), false); return WriteMp3File ( filename, 56 ); } else if (command == wxT("Stereo To Mono")){ // StereoToMono is an effect masquerading as a menu item. Effect * f=GetEffectFromCommandName( _("Stereo To Mono") ); if( f!=NULL ) return ApplyEffectCommand( f, command, params ); wxMessageBox( _("Stereo To Mono Effect not found")); return false; } else if (command == wxT("ExportMp3") ){ return WriteMp3File ( filename, 0 ); // 0 bitrate means use default/current } else if (command == wxT("ExportWav") ){ filename.Replace(wxT(".mp3"), wxT(".wav"), false); double endTime = GetEndTime(); if( endTime <= 0.0f ) return false; return ::ExportPCM(project, numChannels, filename, false, 0.0, endTime); } else if (command == wxT("ExportOgg")){ #ifdef USE_LIBVORBIS filename.Replace(wxT(".mp3"), wxT(".ogg"), false); double endTime = GetEndTime(); if( endTime <= 0.0f ) return false; return ::ExportOGG(project, numChannels, filename, false, 0.0, endTime); #else wxMessageBox(_("Ogg Vorbis support is not included in this build of Audacity")); return false; #endif } else if (command == wxT("ExportFlac")){ #ifdef USE_LIBFLAC filename.Replace(wxT(".mp3"), wxT(".flac"), false); double endTime = GetEndTime(); if( endTime <= 0.0f ) return false; return ::ExportFLAC(project, numChannels, filename, false, 0.0, endTime); #else wxMessageBox(_("FLAC support is not included in this build of Audacity")); return false; #endif } wxMessageBox( wxString::Format(_("Command %s not implemented yet"),command.c_str()) ); return false; }
void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S) { bool bAutoSave = gPrefs->ReadBool("/TimerRecord/AutoSave", false); bool bAutoExport = gPrefs->ReadBool("/TimerRecord/AutoExport", false); int iPostTimerRecordAction = gPrefs->ReadLong("/TimerRecord/PostAction", 0); S.SetBorder(5); S.StartMultiColumn(2, wxCENTER); { S.StartVerticalLay(true); { /* i18n-hint: This string is used to configure the controls for times when the recording is * started and stopped. As such it is important that only the alphabetic parts of the string * are translated, with the numbers left exactly as they are. * The 'h' indicates the first number displayed is hours, the 'm' indicates the second number * displayed is minutes, and the 's' indicates that the third number displayed is seconds. */ wxString strFormat = _("099 h 060 m 060 s"); using Options = NumericTextCtrl::Options; S.StartStatic(_("Start Date and Time"), true); { m_pDatePickerCtrl_Start = safenew wxDatePickerCtrl(this, // wxWindow *parent, ID_DATEPICKER_START, // wxWindowID id, m_DateTime_Start); // const wxDateTime& dt = wxDefaultDateTime, // const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDP_DEFAULT | wxDP_SHOWCENTURY, const wxValidator& validator = wxDefaultValidator, const wxString& name = "datectrl") m_pDatePickerCtrl_Start->SetName(_("Start Date")); m_pDatePickerCtrl_Start->SetRange(wxDateTime::Today(), wxInvalidDateTime); // No backdating. #if wxUSE_ACCESSIBILITY m_pDatePickerCtrl_Start->SetAccessible( safenew DatePickerCtrlAx(m_pDatePickerCtrl_Start)); #endif S.AddWindow(m_pDatePickerCtrl_Start); m_pTimeTextCtrl_Start = safenew NumericTextCtrl( this, ID_TIMETEXT_START, NumericConverter::TIME, wxEmptyString, 0, 44100, Options{} .MenuEnabled(false) .Format(strFormat) .Value(true, wxDateTime_to_AudacityTime(m_DateTime_Start))); m_pTimeTextCtrl_Start->SetName(_("Start Time")); S.AddWindow(m_pTimeTextCtrl_Start); } S.EndStatic(); S.StartStatic(_("End Date and Time"), true); { m_pDatePickerCtrl_End = safenew wxDatePickerCtrl(this, // wxWindow *parent, ID_DATEPICKER_END, // wxWindowID id, m_DateTime_End); // const wxDateTime& dt = wxDefaultDateTime, // const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, // long style = wxDP_DEFAULT | wxDP_SHOWCENTURY, // const wxValidator& validator = wxDefaultValidator, // const wxString& name = "datectrl") m_pDatePickerCtrl_End->SetRange(m_DateTime_Start, wxInvalidDateTime); // No backdating. m_pDatePickerCtrl_End->SetName(_("End Date")); #if wxUSE_ACCESSIBILITY m_pDatePickerCtrl_End->SetAccessible( safenew DatePickerCtrlAx(m_pDatePickerCtrl_End)); #endif S.AddWindow(m_pDatePickerCtrl_End); m_pTimeTextCtrl_End = safenew NumericTextCtrl( this, ID_TIMETEXT_END, NumericConverter::TIME, wxEmptyString, 0, 44100, Options{} .MenuEnabled(false) .Format(strFormat) .Value(true, wxDateTime_to_AudacityTime(m_DateTime_End))); m_pTimeTextCtrl_End->SetName(_("End Time")); S.AddWindow(m_pTimeTextCtrl_End); } S.EndStatic(); S.StartStatic(_("Duration"), true); { /* i18n-hint: This string is used to configure the controls which shows the recording * duration. As such it is important that only the alphabetic parts of the string * are translated, with the numbers left exactly as they are. * The string 'days' indicates that the first number in the control will be the number of days, * then the 'h' indicates the second number displayed is hours, the 'm' indicates the third * number displayed is minutes, and the 's' indicates that the fourth number displayed is * seconds. */ wxString strFormat1 = _("099 days 024 h 060 m 060 s"); m_pTimeTextCtrl_Duration = safenew NumericTextCtrl( this, ID_TIMETEXT_DURATION, NumericConverter::TIME, wxEmptyString, 0, 44100, Options{} .MenuEnabled(false) .Format(strFormat1) .Value(true, m_TimeSpan_Duration.GetSeconds().ToDouble())); m_pTimeTextCtrl_Duration->SetName(_("Duration")); S.AddWindow(m_pTimeTextCtrl_Duration); } S.EndStatic(); } S.EndVerticalLay(); S.StartVerticalLay(true); { S.StartStatic(_("Automatic Save"), true); { // If checked, the project will be saved when the recording is completed m_pTimerAutoSaveCheckBoxCtrl = S.Id(ID_AUTOSAVE_CHECKBOX).AddCheckBox(_("Enable &Automatic Save?"), (bAutoSave ? "true" : "false")); S.StartMultiColumn(3, wxEXPAND); { wxString sInitialValue = wxT(""); AudacityProject* pProject = GetActiveProject(); wxString sSaveValue = pProject->GetFileName(); if (sSaveValue != wxEmptyString) { m_fnAutoSaveFile.Assign(sSaveValue); sInitialValue = _("Current Project"); } S.AddPrompt(_("Save Project As:")); m_pTimerSavePathTextCtrl = NewPathControl(this, ID_AUTOSAVEPATH_TEXT, _("Save Project As:"), sInitialValue); m_pTimerSavePathTextCtrl->SetEditable(false); S.AddWindow(m_pTimerSavePathTextCtrl); m_pTimerSavePathButtonCtrl = S.Id(ID_AUTOSAVEPATH_BUTTON).AddButton(_("Select...")); } S.EndMultiColumn(); } S.EndStatic(); S.StartStatic(_("Automatic Export"), true); { m_pTimerAutoExportCheckBoxCtrl = S.Id(ID_AUTOEXPORT_CHECKBOX).AddCheckBox(_("Enable Automatic &Export?"), (bAutoExport ? "true" : "false")); S.StartMultiColumn(3, wxEXPAND); { S.AddPrompt(_("Export Project As:")); m_pTimerExportPathTextCtrl = NewPathControl(this, ID_AUTOEXPORTPATH_TEXT, _("Export Project As:"), wxT("")); m_pTimerExportPathTextCtrl->SetEditable(false); S.AddWindow(m_pTimerExportPathTextCtrl); m_pTimerExportPathButtonCtrl = S.Id(ID_AUTOEXPORTPATH_BUTTON).AddButton(_("Select...")); } S.EndMultiColumn(); } S.EndStatic(); S.StartStatic(_("Options"), true); { wxArrayString arrayOptions; arrayOptions.Add(_("Do nothing")); arrayOptions.Add(_("Exit Audacity")); arrayOptions.Add(_("Restart system")); arrayOptions.Add(_("Shutdown system")); m_sTimerAfterCompleteOptionsArray.Add(arrayOptions.Item(0)); m_sTimerAfterCompleteOptionsArray.Add(arrayOptions.Item(1)); #ifdef __WINDOWS__ m_sTimerAfterCompleteOptionsArray.Add(arrayOptions.Item(2)); m_sTimerAfterCompleteOptionsArray.Add(arrayOptions.Item(3)); #endif m_sTimerAfterCompleteOption = arrayOptions.Item(iPostTimerRecordAction); m_pTimerAfterCompleteChoiceCtrl = S.AddChoice(_("After Recording completes:"), m_sTimerAfterCompleteOption, &m_sTimerAfterCompleteOptionsArray); } S.EndStatic(); } S.EndVerticalLay(); } S.EndMultiColumn(); // MY: Added the help button here S.AddStandardButtons(eOkButton | eCancelButton | eHelpButton); Layout(); Fit(); SetMinSize(GetSize()); Center(); EnableDisableAutoControls(bAutoSave, CONTROL_GROUP_SAVE); EnableDisableAutoControls(bAutoExport, CONTROL_GROUP_EXPORT); }