Audacity 3.2.0
BatchCommands.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 MacroCommands.cpp
6
7 Dominic Mazzoni
8 James Crook
9
10********************************************************************//*******************************************************************/
17#define wxLOG_COMPONENT "MacroCommands"
18
19#include "BatchCommands.h"
20
21#include <wx/defs.h>
22#include <wx/datetime.h>
23#include <wx/dir.h>
24#include <wx/log.h>
25#include <wx/textfile.h>
26#include <wx/time.h>
27
28#include "Project.h"
29#include "ProjectHistory.h"
30#include "ProjectSettings.h"
32#include "effects/EffectUI.h"
33#include "FileNames.h"
34#include "PluginManager.h"
35#include "Prefs.h"
36#include "SelectFile.h"
37#include "SelectUtilities.h"
38#include "SettingsVisitor.h"
39#include "Track.h"
40#include "UndoManager.h"
41
42#include "AllThemeResources.h"
43
44#include "AudacityMessageBox.h"
45
46#include "CommandContext.h"
48#include "CommandManager.h"
49
51: mProject{ project }
52{
53 ResetMacro();
54
55 auto names = GetNames();
56 auto defaults = GetNamesOfDefaultMacros();
57
58 for( size_t i = 0;i<defaults.size();i++){
59 wxString name = defaults[i];
60 if ( ! make_iterator_range( names ).contains(name) ) {
64 }
65 }
66}
67
68static const auto MP3Conversion = XO("MP3 Conversion");
69static const auto FadeEnds = XO("Fade Ends");
70
72{
73 return {
74 MP3Conversion.Translation() ,
75 FadeEnds.Translation() ,
76 };
77}
78
79void MacroCommands::RestoreMacro(const wxString & name)
80{
81// TIDY-ME: Effects change their name with localisation.
82// Commands (at least currently) don't. Messy.
83 ResetMacro();
84 if (name == MP3Conversion.Translation() ){
85 AddToMacro( wxT("Normalize") );
86 AddToMacro( wxT("ExportMP3") );
87 } else if (name == FadeEnds.Translation() ){
88 AddToMacro( wxT("Select"), wxT("Start=\"0\" End=\"1\"") );
89 AddToMacro( wxT("FadeIn") );
90 AddToMacro( wxT("Select"), wxT("Start=\"0\" End=\"1\" RelativeTo=\"ProjectEnd\"") );
91 AddToMacro( wxT("FadeOut") );
92 AddToMacro( wxT("Select"), wxT("Start=\"0\" End=\"0\"") );
93 }
94}
95
97{
98 if (index < 0 || index >= (int)mCommandMacro.size()) {
99 return wxT("");
100 }
101
102 return mCommandMacro[index];
103}
104
105wxString MacroCommands::GetParams(int index)
106{
107 if (index < 0 || index >= (int)mParamsMacro.size()) {
108 return wxT("");
109 }
110
111 return mParamsMacro[index];
112}
113
115{
116 return (int)mCommandMacro.size();
117}
118
119wxString MacroCommands::ReadMacro(const wxString & macro, wxWindow *parent)
120{
121 // Clear any previous macro
122 ResetMacro();
123
124 // Build the filename
125 wxFileName name(FileNames::MacroDir(), macro, wxT("txt"));
126
127 // But, ask the user for the real name if we're importing
128 if (parent) {
129 FilePath fn = SelectFile(FileNames::Operation::_None,
130 XO("Import Macro"),
131 wxEmptyString,
132 name.GetName(),
133 wxT("txt"),
135 wxFD_OPEN | wxRESIZE_BORDER,
136 parent);
137
138 // User canceled...
139 if (fn.empty()) {
140 return wxEmptyString;
141 }
142
143 wxFileName check(fn);
144 check.SetPath(name.GetPath());
145 if (check.FileExists())
146 {
147 int id = AudacityMessageBox(
148 XO("Macro %s already exists. Would you like to replace it?").Format(check.GetName()),
149 XO("Import Macro"),
150 wxYES_NO);
151 if (id == wxNO) {
152 return wxEmptyString;
153 }
154 }
155
156 name.Assign(fn);
157 }
158
159 // Set the file name
160 wxTextFile tf(name.GetFullPath());
161
162 // Open and check
163 tf.Open();
164 if (!tf.IsOpened()) {
165 // wxTextFile will display any errors
166 return wxEmptyString;
167 }
168
169 // Load commands from the file
170 int lines = tf.GetLineCount();
171 if (lines > 0) {
172 for (int i = 0; i < lines; i++) {
173
174 // Find the command name terminator...ignore line if not found
175 int splitAt = tf[i].Find(wxT(':'));
176 if (splitAt < 0) {
177 continue;
178 }
179
180 // Parse and clean
181 wxString cmd = tf[i].Left(splitAt).Strip(wxString::both);
182 wxString parm = tf[i].Mid(splitAt + 1).Strip(wxString::trailing);
183
184 // Add to lists
185 mCommandMacro.push_back(cmd);
186 mParamsMacro.push_back(parm);
187 }
188 }
189
190 // Done with the file
191 tf.Close();
192
193 // Write to macro directory if importing
194 if (parent) {
195 return WriteMacro(name.GetName());
196 }
197
198 return name.GetName();
199}
200
201wxString MacroCommands::WriteMacro(const wxString & macro, wxWindow *parent)
202{
203 // Build the default filename
204 wxFileName name(FileNames::MacroDir(), macro, wxT("txt"));
205
206 // But, ask the user for the real name if we're exporting
207 if (parent) {
208 FilePath fn = SelectFile(FileNames::Operation::_None,
209 XO("Export Macro"),
210 wxEmptyString,
211 name.GetName(),
212 wxT("txt"),
214 wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
215 parent);
216
217 // User canceled...
218 if (fn.empty()) {
219 return wxEmptyString;
220 }
221
222 name.Assign(fn);
223 }
224
225 // Set the file name
226 wxTextFile tf(name.GetFullPath());
227
228 // Create the file (Create() doesn't leave the file open)
229 if (!tf.Exists()) {
230 tf.Create();
231 }
232
233 // Open it
234 tf.Open();
235
236 if (!tf.IsOpened()) {
237 // wxTextFile will display any errors
238 return wxEmptyString;
239 }
240
241 // Start with a clean slate
242 tf.Clear();
243
244 // Copy over the commands
245 int lines = mCommandMacro.size();
246 for (int i = 0; i < lines; i++) {
247 // using GET to serialize macro definition to a text file
248 tf.AddLine(mCommandMacro[i].GET() + wxT(":") + mParamsMacro[ i ]);
249 }
250
251 // Write the macro
252 tf.Write();
253
254 // Done with the file
255 tf.Close();
256
257 return name.GetName();
258}
259
260bool MacroCommands::AddMacro(const wxString & macro)
261{
262 // Build the filename
263 wxFileName name(FileNames::MacroDir(), macro, wxT("txt"));
264
265 // Set the file name
266 wxTextFile tf(name.GetFullPath());
267
268 // Create it..Create will display errors
269 return tf.Create();
270}
271
272bool MacroCommands::DeleteMacro(const wxString & macro)
273{
274 // Build the filename
275 wxFileName name(FileNames::MacroDir(), macro, wxT("txt"));
276
277 // Delete it...wxRemoveFile will display errors
278 auto result = wxRemoveFile(name.GetFullPath());
279
280 // Delete any legacy chain that it shadowed
281 auto oldPath = wxFileName{ FileNames::LegacyChainDir(), macro, wxT("txt") };
282 wxRemoveFile(oldPath.GetFullPath()); // Don't care about this return value
283
284 return result;
285}
286
287bool MacroCommands::RenameMacro(const wxString & oldmacro, const wxString & newmacro)
288{
289 // Build the filenames
290 wxFileName oname(FileNames::MacroDir(), oldmacro, wxT("txt"));
291 wxFileName nname(FileNames::MacroDir(), newmacro, wxT("txt"));
292
293 // Rename it...wxRenameFile will display errors
294 return wxRenameFile(oname.GetFullPath(), nname.GetFullPath());
295}
296
297// Gets all commands that are valid for this mode.
299{
300 if (!project)
301 return;
302
303 Entries commands;
304
307 {
308 for (auto &plug
310 auto command = em.GetCommandIdentifier(plug.GetID());
311 if (!command.empty())
312 commands.push_back( {
313 { command, plug.GetSymbol().Msgid() },
314 plug.GetPluginType() == PluginTypeEffect ?
315 XO("Effect") : XO("Menu Command (With Parameters)")
316 } );
317 }
318 }
319
321 TranslatableStrings mLabels;
322 CommandIDs mNames;
323 std::vector<bool> vExcludeFromMacros;
324 mLabels.clear();
325 mNames.clear();
326 manager.GetAllCommandLabels(mLabels, vExcludeFromMacros, true);
327 manager.GetAllCommandNames(mNames, true);
328
329 const bool english = wxGetLocale()->GetCanonicalName().StartsWith(wxT("en"));
330
331 for(size_t i=0; i<mNames.size(); i++) {
332 if( !vExcludeFromMacros[i] ){
333 auto label = mLabels[i];
334 label.Strip();
335 bool suffix;
336 if (!english)
337 suffix = false;
338 else {
339 // We'll disambiguate if the squashed name is short and shorter than the internal name.
340 // Otherwise not.
341 // This means we won't have repetitive items like "Cut (Cut)"
342 // But we will show important disambiguation like "All (SelectAll)" and "By Date (SortByDate)"
343 // Disambiguation is no longer essential as the details box will show it.
344 // PRL: I think this reasoning applies only when locale is English.
345 // For other locales, show the (CamelCaseCodeName) always. Or, never?
346 wxString squashed = label.Translation();
347 squashed.Replace( " ", "" );
348
349 // uh oh, using GET for dubious comparison of (lengths of)
350 // user-visible name and internal CommandID!
351 // and doing this only for English locale!
352 suffix = squashed.length() < wxMin( 18, mNames[i].GET().length());
353 }
354
355 if( suffix )
356 // uh oh, using GET to expose CommandID to the user, as a
357 // disambiguating suffix on a name, but this is only ever done if
358 // the locale is English!
359 // PRL: In case this logic does get fixed for other locales,
360 // localize even this punctuation format. I'm told Chinese actually
361 // prefers slightly different parenthesis characters
362 label.Join( XO("(%s)").Format( mNames[i].GET() ), wxT(" ") );
363
364 // Bug 2294. The Close command pulls the rug out from under
365 // batch processing, because it destroys the project.
366 // So it is UNSAFE for scripting, and therefore excluded from
367 // the catalog.
368 if (mNames[i] == "Close")
369 continue;
370
371 commands.push_back(
372 {
373 {
374 mNames[i], // Internal name.
375 label // User readable name
376 },
377 XO("Menu Command (No Parameters)")
378 }
379 );
380 }
381 }
382
383 // Sort commands by their user-visible names.
384 // PRL: What exactly should happen if first members of pairs are not unique?
385 // I'm not sure, but at least I can sort stably for a better defined result.
386 auto less =
387 [](const Entry &a, const Entry &b)
388 { return a.name.StrippedTranslation() <
389 b.name.StrippedTranslation(); };
390 std::stable_sort(commands.begin(), commands.end(), less);
391
392 // Now uniquify by friendly name
393 auto equal =
394 [](const Entry &a, const Entry &b)
395 { return a.name.StrippedTranslation() ==
396 b.name.StrippedTranslation(); };
397 std::unique_copy(
398 commands.begin(), commands.end(), std::back_inserter(mCommands), equal);
399}
400
401// binary search
403 -> Entries::const_iterator
404{
405 const auto less = [](const Entry &entryA, const Entry &entryB)
406 { return entryA.name.StrippedTranslation() <
407 entryB.name.StrippedTranslation(); };
408 auto range = std::equal_range(
409 begin(), end(), Entry{ { {}, friendlyName }, {} }, less
410 );
411 if (range.first != range.second) {
412 wxASSERT_MSG( range.first + 1 == range.second,
413 "Non-unique user-visible command name" );
414 return range.first;
415 }
416 else
417 return end();
418}
419
420// linear search
421auto MacroCommandsCatalog::ByCommandId( const CommandID &commandId ) const
422 -> Entries::const_iterator
423{
424 // Maybe this too should have a uniqueness check?
425 return std::find_if( begin(), end(),
426 [&](const Entry &entry)
427 { return entry.name.Internal() == commandId; });
428}
429
431{
432 const PluginID & ID =
434 if (ID.empty())
435 {
436 return wxEmptyString; // effect not found.
437 }
438
440}
441
443 const CommandID & command, const wxString & params, wxWindow &parent)
444{
445 const PluginID & ID =
447 if (ID.empty())
448 return wxEmptyString; // effect not found
449
450 wxString res = params;
451 auto cleanup = EffectManager::Get().SetBatchProcessing(ID);
452 if (EffectManager::Get().SetEffectParameters(ID, params))
453 if (EffectManager::Get().PromptUser(ID, EffectUI::DialogFactory, parent))
455 return res;
456}
457
458wxString MacroCommands::PromptForPresetFor(const CommandID & command, const wxString & params, wxWindow *parent)
459{
460 const PluginID & ID =
462 if (ID.empty())
463 {
464 return wxEmptyString; // effect not found.
465 }
466
467 wxString preset = EffectManager::Get().GetPreset(ID, params, parent);
468
469 // Preset will be empty if the user cancelled the dialog, so return the original
470 // parameter value.
471 if (preset.empty())
472 {
473 return params;
474 }
475
476 return preset;
477}
478
480 const PluginID & ID, const TranslatableString &friendlyCommand,
481 const CommandID & command, const wxString & params,
482 const CommandContext & Context)
483{
484 static_cast<void>(command);//compiler food.
485
486 //Possibly end processing here, if in batch-debug
487 if( ReportAndSkip(friendlyCommand, params))
488 return true;
489
491 if (!plug)
492 return false;
493
495
496 // IF nothing selected, THEN select everything depending
497 // on preferences setting.
498 // (most effects require that you have something selected).
500 {
502 {
504 // i18n-hint: %s will be replaced by the name of an action, such as "Remove Tracks".
505 XO("\"%s\" requires one or more tracks to be selected.").Format(friendlyCommand));
506 return false;
507 }
508 }
509
510 bool res = false;
511
512 auto cleanup = EffectManager::Get().SetBatchProcessing(ID);
513
514 // transfer the parameters to the effect...
515 if (EffectManager::Get().SetEffectParameters(ID, params))
516 {
518 // and apply the effect...
520 Context,
524 else
525 // and apply the effect...
526 res = EffectUI::DoEffect(ID,
527 Context,
531 }
532
533 return res;
534}
535
537 const CommandID & command, const wxString & params,
538 CommandContext const *const pContext)
539{
540 // Test for an effect.
541 const PluginID & ID =
543 if (!ID.empty())
544 {
545 if( pContext )
546 return ApplyEffectCommand(
547 ID, friendlyCommand, command, params, *pContext);
548 const CommandContext context( mProject );
549 return ApplyEffectCommand(
550 ID, friendlyCommand, command, params, context);
551 }
552
553 if (pContext) {
554 assert(&pContext->project == &GetProject());
556 command, *pContext, AlwaysEnabledFlag, true ) )
557 return true;
558 pContext->Status( wxString::Format(
559 _("Your batch command of %s was not recognized."), friendlyCommand.Translation() ));
560 return false;
561 }
562 else
563 {
564 const CommandContext context( mProject );
566 command, context, AlwaysEnabledFlag, true ) )
567 return true;
568 }
569
571 XO("Your batch command of %s was not recognized.")
572 .Format( friendlyCommand ) );
573
574 return false;
575}
576
578 const TranslatableString &friendlyCommand,
579 const CommandID & command, const wxString &params,
580 CommandContext const * pContext)
581{
582 assert(!pContext || &pContext->project == &GetProject());
585 // Recalc flags and enable items that may have become enabled.
586 CommandManager::Get(*project).UpdateMenus(false);
587 // enter batch mode...
588 project->mBatchMode++;
589 auto cleanup = finally( [&] {
590 // exit batch mode...
591 project->mBatchMode--;
592 } );
593
594 return ApplyCommand( friendlyCommand, command, params, pContext );
595}
596
597static int MacroReentryCount = 0;
598// ApplyMacro returns true on success, false otherwise.
599// Any error reporting to the user in setting up the macro
600// has already been done.
602 const MacroCommandsCatalog &catalog, const wxString & filename)
603{
604 // Check for reentrant ApplyMacro commands.
605 // We'll allow 1 level of reentry, but not more.
606 // And we treat ignoring deeper levels as a success.
607 if (MacroReentryCount > 1) {
608 return true;
609 }
610
611 // Restore the reentry counter (to zero) when we exit.
612 auto cleanup1 = valueRestorer(MacroReentryCount);
614
615 AudacityProject *proj = &mProject;
616 bool res = false;
617
618 // Only perform this group on initial entry. They should not be done
619 // while recursing.
620 if (MacroReentryCount == 1) {
621 mFileName = filename;
622
623 TranslatableString longDesc, shortDesc;
624 wxString name = gPrefs->Read(wxT("/Batch/ActiveMacro"), wxEmptyString);
625 if (name.empty()) {
626 /* i18n-hint: active verb in past tense */
627 longDesc = XO("Applied Macro");
628 shortDesc = XO("Apply Macro");
629 }
630 else {
631 /* i18n-hint: active verb in past tense */
632 longDesc = XO("Applied Macro '%s'").Format(name);
633 shortDesc = XO("Apply '%s'").Format(name);
634 }
635
636 // Save the project state before making any changes. It will be rolled
637 // back if an error occurs.
638 // It also causes any calls to ModifyState (such as by simple
639 // view-changing commands) to append changes to this state, not to the
640 // previous state in history. See Bug 2076
641 if (proj) {
642 ProjectHistory::Get(*proj).PushState(longDesc, shortDesc);
643 }
644 }
645
646 // Upon exit of the top level apply, roll back the state if an error occurs.
647 auto cleanup2 = finally([&, macroReentryCount = MacroReentryCount] {
648 if (macroReentryCount == 1 && !res && proj) {
649 // Be sure that exceptions do not escape this destructor
650 GuardedCall([&]{
651 // Macro failed or was cancelled; revert to the previous state
652 auto &history = ProjectHistory::Get(*proj);
653 history.RollbackState();
654 // The added undo state is now vacuous. Remove it (Bug 2759)
655 auto &undoManager = UndoManager::Get(*proj);
656 undoManager.Undo(
657 [&]( const UndoStackElem &elem ){
658 history.PopState( elem.state ); } );
659 undoManager.AbandonRedo();
660 });
661 }
662 });
663
664 mAbort = false;
665
666 // Is tracing enabled?
667 bool trace;
668 gPrefs->Read(wxT("/EnableMacroTracing"), &trace, false);
669
670 // If so, then block most other messages while running the macro
671 wxLogLevel prevLevel = wxLog::GetComponentLevel("");
672 if (trace) {
673 wxLog::SetComponentLevel("", wxLOG_FatalError);
674 wxLog::SetComponentLevel(wxLOG_COMPONENT, wxLOG_Info);
675 }
676
677 size_t i = 0;
678 for (; i < mCommandMacro.size(); i++) {
679 const auto &command = mCommandMacro[i];
680 auto iter = catalog.ByCommandId(command);
681 const auto friendly = (iter == catalog.end())
682 ?
683 // uh oh, using GET to expose an internal name to the user!
684 // in default of any better friendly name
685 Verbatim( command.GET() )
686 : iter->name.Msgid().Stripped();
687
688 wxTimeSpan before;
689 if (trace) {
690 before = wxTimeSpan(0, 0, 0, wxGetUTCTimeMillis());
691 }
692
693 bool success = ApplyCommandInBatchMode(friendly, command, mParamsMacro[i]);
694
695 if (trace) {
696 auto after = wxTimeSpan(0, 0, 0, wxGetUTCTimeMillis());
697 wxLogMessage(wxT("Macro line #%ld took %s : %s:%s"),
698 i + 1,
699 (after - before).Format(wxT("%H:%M:%S.%l")),
700 command.GET(),
701 mParamsMacro[i]);
702 }
703
704 if (!success || mAbort)
705 break;
706 }
707
708 // Restore message level
709 if (trace) {
710 wxLog::SetComponentLevel("", prevLevel);
711 }
712
713 res = (i == mCommandMacro.size());
714 if (!res)
715 return false;
716
717 if (MacroReentryCount == 1) {
718 mFileName.Empty();
719
720 if (proj)
721 ProjectHistory::Get(*proj).ModifyState(true);
722 }
723
724 return true;
725}
726
727// AbortBatch() allows a premature terminatation of a batch.
729{
730 mAbort = true;
731}
732
733void MacroCommands::AddToMacro(const CommandID &command, int before)
734{
735 AddToMacro(command, GetCurrentParamsFor(command), before);
736}
737
738void MacroCommands::AddToMacro(const CommandID &command, const wxString &params, int before)
739{
740 if (before == -1) {
741 before = (int)mCommandMacro.size();
742 }
743
744 mCommandMacro.insert(mCommandMacro.begin() + before, command);
745 mParamsMacro.insert(mParamsMacro.begin() + before, params);
746}
747
749{
750 if (index < 0 || index >= (int)mCommandMacro.size()) {
751 return;
752 }
753
754 mCommandMacro.erase( mCommandMacro.begin() + index );
755 mParamsMacro.erase( mParamsMacro.begin() + index );
756}
757
759{
760 mCommandMacro.clear();
761 mParamsMacro.clear();
762}
763
764// ReportAndSkip() is a diagnostic function that avoids actually
765// applying the requested effect if in batch-debug mode.
767 const TranslatableString & friendlyCommand, const wxString & params)
768{
769 int bDebug;
770 gPrefs->Read(wxT("/Batch/Debug"), &bDebug, 0);
771 if( bDebug == 0 )
772 return false;
773
774 //TODO: Add a cancel button to these, and add the logic so that we can abort.
775 if( !params.empty() )
776 {
778 XO("Apply %s with parameter(s)\n\n%s")
779 .Format( friendlyCommand, params ),
780 XO("Test Mode"));
781 }
782 else
783 {
785 XO("Apply %s").Format( friendlyCommand ),
786 XO("Test Mode"));
787 }
788 return true;
789}
790
792{
793 static bool done = false;
794 if (!done) {
795 // Check once per session at most
796
797 // Copy chain files from the old Chains into the new Macros directory,
798 // but only if like-named files are not already present in Macros.
799
800 // Leave the old copies in place, in case a user wants to go back to
801 // an old Audacity version. They will have their old chains intact, but
802 // won't have any edits they made to the copy that now lives in Macros
803 // which old Audacity will not read.
804
805 const auto oldDir = FileNames::LegacyChainDir();
806 FilePaths files;
807 wxDir::GetAllFiles(oldDir, &files, wxT("*.txt"), wxDIR_FILES);
808
809 // add a dummy path component to be overwritten by SetFullName
810 wxFileName newDir{ FileNames::MacroDir(), wxT("x") };
811
812 for (const auto &file : files) {
813 auto name = wxFileName{file}.GetFullName();
814 newDir.SetFullName(name);
815 const auto newPath = newDir.GetFullPath();
816 if (!wxFileExists(newPath))
817 FileNames::DoCopyFile(file, newPath);
818 }
819 done = true;
820 }
821 // To do: use std::once
822}
823
825{
827
828 wxArrayString names;
829 FilePaths files;
830 wxDir::GetAllFiles(FileNames::MacroDir(), &files, wxT("*.txt"), wxDIR_FILES);
831 size_t i;
832
833 wxFileName ff;
834 for (i = 0; i < files.size(); i++) {
835 ff = (files[i]);
836 names.push_back(ff.GetName());
837 }
838
839 std::sort( names.begin(), names.end() );
840
841 return names;
842}
843
844bool MacroCommands::IsFixed(const wxString & name)
845{
846 auto defaults = GetNamesOfDefaultMacros();
847 if( make_iterator_range( defaults ).contains( name ) )
848 return true;
849 return false;
850}
851
852void MacroCommands::Split(const wxString & str, wxString & command, wxString & param)
853{
854 int splitAt;
855
856 command.Empty();
857 param.Empty();
858
859 if (str.empty()) {
860 return;
861 }
862
863 splitAt = str.Find(wxT(':'));
864 if (splitAt < 0) {
865 return;
866 }
867
868 command = str.Mid(0, splitAt);
869 param = str.Mid(splitAt + 1);
870
871 return;
872}
873
874wxString MacroCommands::Join(const wxString & command, const wxString & param)
875{
876 return command + wxT(": ") + param;
877}
wxT("CloseDown"))
R GuardedCall(const F1 &body, const F2 &handler=F2::Default(), F3 delayedHandler=DefaultDelayedHandlerAction) noexcept(noexcept(handler(std::declval< AudacityException * >())) &&noexcept(handler(nullptr)) &&noexcept(std::function< void(AudacityException *)>{std::move(delayedHandler)}))
Execute some code on any thread; catch any AudacityException; enqueue error report on the main thread...
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
static const auto MP3Conversion
static const auto FadeEnds
#define wxLOG_COMPONENT
static int MacroReentryCount
wxString PluginID
constexpr CommandFlag AlwaysEnabledFlag
Definition: CommandFlag.h:34
#define str(a)
EffectDistortionSettings params
Definition: Distortion.cpp:77
const TranslatableString name
Definition: Distortion.cpp:76
XO("Cut/Copy/Paste")
std::vector< CommandID > CommandIDs
Definition: Identifier.h:233
static ProjectFileIORegistry::AttributeWriterEntry entry
#define _(s)
Definition: Internat.h:73
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: IteratorX.h:210
ValueRestorer< T > valueRestorer(T &var)
inline functions provide convenient parameter type deduction
Definition: MemoryX.h:250
@ PluginTypeAudacityCommand
@ PluginTypeEffect
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
wxString FilePath
Definition: Project.h:21
static const AttachedProjectObjects::RegisteredFactory manager
EffectReverbSettings preset
Definition: Reverb.cpp:44
FilePath SelectFile(FileNames::Operation op, const TranslatableString &message, const FilePath &default_path, const FilePath &default_filename, const FileExtension &default_extension, const FileTypes &fileTypes, int flags, wxWindow *parent)
Definition: SelectFile.cpp:17
TranslatableString label
Definition: TagsEditor.cpp:165
static TranslatableStrings names
Definition: TagsEditor.cpp:153
const auto project
declares abstract base class Track, TrackList, and iterators over TrackList
static Settings & settings()
Definition: TrackInfo.cpp:69
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
std::vector< TranslatableString > TranslatableStrings
static const auto fn
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
virtual void Status(const wxString &message, bool bFlush=false) const
AudacityProject & project
static CommandManager & Get(AudacityProject &project)
void UpdateMenus(bool checkActive=true)
const wxString StrippedTranslation() const
EffectManager is the class that handles effects and effect categories.
Definition: EffectManager.h:48
CommandID GetCommandIdentifier(const PluginID &ID)
BatchProcessingScope SetBatchProcessing(const PluginID &ID)
Begin a scope that ends when the returned object is destroyed.
static EffectManager & Get()
wxString GetPreset(const PluginID &ID, const wxString &params, wxWindow *parent)
wxString GetEffectParameters(const PluginID &ID)
const PluginID & GetEffectByIdentifier(const CommandID &strTarget)
FILES_API const FileType TextFiles
Definition: FileNames.h:73
Abstract base class used in importing a file.
Entries::const_iterator ByCommandId(const CommandID &commandId) const
Entries::const_iterator end() const
Definition: BatchCommands.h:49
std::vector< Entry > Entries
Definition: BatchCommands.h:36
MacroCommandsCatalog(const AudacityProject *project)
Entries::const_iterator ByFriendlyName(const TranslatableString &friendlyName) const
static wxArrayStringEx GetNamesOfDefaultMacros()
static wxString PromptForPresetFor(const CommandID &command, const wxString &params, wxWindow *parent)
bool IsFixed(const wxString &name)
CommandIDs mCommandMacro
void AddToMacro(const CommandID &command, int before=-1)
bool ApplyEffectCommand(const PluginID &ID, const TranslatableString &friendlyCommand, const CommandID &command, const wxString &params, const CommandContext &Context)
wxString mFileName
bool ApplyCommand(const TranslatableString &friendlyCommand, const CommandID &command, const wxString &params, CommandContext const *pContext=nullptr)
wxString GetParams(int index)
void DeleteFromMacro(int index)
wxArrayString mParamsMacro
wxString Join(const wxString &command, const wxString &param)
static wxString GetCurrentParamsFor(const CommandID &command)
static void MigrateLegacyChains()
bool RenameMacro(const wxString &oldmacro, const wxString &newmacro)
CommandID GetCommand(int index)
static wxArrayString GetNames()
bool DeleteMacro(const wxString &name)
bool ReportAndSkip(const TranslatableString &friendlyCommand, const wxString &params)
void Split(const wxString &str, wxString &command, wxString &param)
bool ApplyCommandInBatchMode(const TranslatableString &friendlyCommand, const CommandID &command, const wxString &params, CommandContext const *pContext=nullptr)
AudacityProject & GetProject()
Definition: BatchCommands.h:61
wxString WriteMacro(const wxString &macro, wxWindow *parent=nullptr)
bool ApplyMacro(const MacroCommandsCatalog &catalog, const wxString &filename={})
static wxString PromptForParamsFor(const CommandID &command, const wxString &params, wxWindow &parent)
bool AddMacro(const wxString &macro)
MacroCommands(AudacityProject &project)
wxString ReadMacro(const wxString &macro, wxWindow *parent=nullptr)
void RestoreMacro(const wxString &name)
AudacityProject & mProject
PluginType GetPluginType() const
PluginManager maintains a list of all plug ins. That covers modules, effects, generators,...
Definition: PluginManager.h:51
Range PluginsOfType(int type)
const PluginDescriptor * GetPlugin(const PluginID &ID) const
static PluginManager & Get()
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
void ModifyState(bool bWantsAutoSave)
static ProjectHistory & Get(AudacityProject &project)
static ProjectSettings & Get(AudacityProject &project)
Holds a msgid for the translation catalog; may also bind format arguments.
TranslatableString & Strip(unsigned options=MenuCodes) &
TranslatableString & Join(TranslatableString arg, const wxString &separator={}) &
Append another translatable string.
wxString Translation() const
TranslatableString Stripped(unsigned options=MenuCodes) const
non-mutating, constructs another TranslatableString object
static UndoManager & Get(AudacityProject &project)
Definition: UndoManager.cpp:71
virtual bool Read(const wxString &key, bool *value) const =0
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
AUDACITY_DLL_API bool DoAudacityCommand(const PluginID &ID, const CommandContext &context, unsigned flags)
AUDACITY_DLL_API bool HandleTextualCommand(const CommandID &Str, const CommandContext &context, CommandFlag flags, bool alwaysEnabled)
AUDACITY_DLL_API bool DoEffect(const PluginID &ID, const CommandContext &context, unsigned flags)
'Repeat Last Effect'.
Definition: EffectUI.cpp:1148
AUDACITY_DLL_API DialogFactoryResults DialogFactory(wxWindow &parent, EffectBase &host, EffectUIServices &client, EffectSettingsAccess &access)
Definition: EffectUI.cpp:1111
FILES_API FilePath MacroDir()
FILES_API bool DoCopyFile(const FilePath &file1, const FilePath &file2, bool overwrite=true)
FILES_API FilePath LegacyChainDir()
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:150
bool SelectAllIfNoneAndAllowed(AudacityProject &project)
Definition: BatchCommands.h:32
ComponentInterfaceSymbol name
Definition: BatchCommands.h:33
Holds one item with description and time range for the UndoManager.
Definition: UndoManager.h:117
UndoState state
Definition: UndoManager.h:128