Audacity  2.2.2
BatchCommands.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  MacroCommands.h
6 
7  Dominic Mazzoni
8  James Crook
9 
10 **********************************************************************/
11 
12 #ifndef __AUDACITY_BATCH_COMMANDS_DIALOG__
13 #define __AUDACITY_BATCH_COMMANDS_DIALOG__
14 
15 #include <wx/defs.h>
16 #include <wx/string.h>
17 
18 #include "export/Export.h"
19 
20 class Effect;
21 class CommandContext;
22 class AudacityProject;
23 
25 public:
26  // A triple of user-visible name, internal string identifier and type/help string.
27  struct Entry {
29  wxString category;
30  };
31  using Entries = std::vector<Entry>;
32 
33  MacroCommandsCatalog( const AudacityProject *project );
34 
35  // binary search
36  Entries::const_iterator ByFriendlyName( const wxString &friendlyName ) const;
37  // linear search
38  Entries::const_iterator ByCommandId( const wxString &commandId ) const;
39 
40  // Lookup by position as sorted by friendly name
41  const Entry &operator[] ( size_t index ) const { return mCommands[index]; }
42 
43  Entries::const_iterator begin() const { return mCommands.begin(); }
44  Entries::const_iterator end() const { return mCommands.end(); }
45 
46 private:
47  // Sorted by friendly name
49 };
50 
51 // Stores information for one macro
52 class MacroCommands final {
53  public:
54  // constructors and destructors
55  MacroCommands();
56  public:
57  bool ApplyMacro( const MacroCommandsCatalog &catalog,
58  const wxString & filename = wxT(""));
59  bool ApplyCommand( const wxString &friendlyCommand,
60  const wxString & command, const wxString & params,
61  CommandContext const * pContext=NULL );
62  bool ApplyCommandInBatchMode( const wxString &friendlyCommand,
63  const wxString & command, const wxString &params);
65  int iCommand, const wxString &friendlyCommand,
66  const wxString & command, const wxString & params);
67  bool ApplyEffectCommand(
68  const PluginID & ID, const wxString &friendlyCommand,
69  const wxString & command,
70  const wxString & params, const CommandContext & Context);
71  bool ReportAndSkip( const wxString & friendlyCommand, const wxString & params );
72  void AbortBatch();
73 
74  // Utility functions for the special commands.
75  wxString BuildCleanFileName(const wxString &fileName, const wxString &extension);
76  bool WriteMp3File( const wxString & Name, int bitrate );
77  double GetEndTime();
78  bool IsMono();
79 
80  // These commands do not depend on the command list.
81  static void MigrateLegacyChains();
82  static wxArrayString GetNames();
83  static wxArrayString GetNamesOfDefaultMacros();
84 
85  static wxString GetCurrentParamsFor(const wxString & command);
86  static wxString PromptForParamsFor(const wxString & command, const wxString & params, wxWindow *parent);
87  static wxString PromptForPresetFor(const wxString & command, const wxString & params, wxWindow *parent);
88 
89  // These commands do depend on the command list.
90  void ResetMacro();
91 
92  void RestoreMacro(const wxString & name);
93  bool ReadMacro(const wxString & macro);
94  bool WriteMacro(const wxString & macro);
95  bool AddMacro(const wxString & macro);
96  bool DeleteMacro(const wxString & name);
97  bool RenameMacro(const wxString & oldmacro, const wxString & newmacro);
98 
99  void AddToMacro(const wxString & command, int before = -1);
100  void AddToMacro(const wxString & command, const wxString & params, int before = -1);
101  void DeleteFromMacro(int index);
102  wxString GetCommand(int index);
103  wxString GetParams(int index);
104  int GetCount();
105  wxString GetMessage(){ return mMessage;};
106  void AddToMessage(const wxString & msgIn ){ mMessage += msgIn;};
107 
108  bool IsFixed(const wxString & name);
109 
110  void Split(const wxString & str, wxString & command, wxString & param);
111  wxString Join(const wxString & command, const wxString & param);
112 
113  wxArrayString mCommandMacro;
114  wxArrayString mParamsMacro;
115  bool mAbort;
116  wxString mMessage;
117 
119  wxString mFileName;
120 };
121 
122 #endif
bool AddMacro(const wxString &macro)
void AddToMacro(const wxString &command, int before=-1)
wxString GetParams(int index)
Definition: BatchCommands.h:27
wxString mFileName
wxString mMessage
wxString BuildCleanFileName(const wxString &fileName, const wxString &extension)
Entries::const_iterator begin() const
Definition: BatchCommands.h:43
static wxString PromptForPresetFor(const wxString &command, const wxString &params, wxWindow *parent)
wxString GetCommand(int index)
static wxArrayString GetNames()
wxString PluginID
Definition: Types.h:209
bool RenameMacro(const wxString &oldmacro, const wxString &newmacro)
Base class for many of the effects in Audacity.
Definition: Effect.h:62
bool ApplyMacro(const MacroCommandsCatalog &catalog, const wxString &filename=wxT(""))
CommandContext provides addiitonal information to an 'Apply()' command. It provides the project...
TranslatedInternalString name
Definition: BatchCommands.h:28
Maintains the list of commands for batch/macro processing. See also MacrosWindow and ApplyMacroDialog...
Definition: BatchCommands.h:52
bool ApplySpecialCommand(int iCommand, const wxString &friendlyCommand, const wxString &command, const wxString &params)
Entries::const_iterator ByFriendlyName(const wxString &friendlyName) const
void RestoreMacro(const wxString &name)
bool ReportAndSkip(const wxString &friendlyCommand, const wxString &params)
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
bool ApplyCommand(const wxString &friendlyCommand, const wxString &command, const wxString &params, CommandContext const *pContext=NULL)
std::vector< Entry > Entries
Definition: BatchCommands.h:31
bool DeleteMacro(const wxString &name)
wxString category
Definition: BatchCommands.h:29
static wxString PromptForParamsFor(const wxString &command, const wxString &params, wxWindow *parent)
static wxArrayString GetNamesOfDefaultMacros()
bool WriteMp3File(const wxString &Name, int bitrate)
bool ReadMacro(const wxString &macro)
wxArrayString mParamsMacro
bool WriteMacro(const wxString &macro)
wxString Join(const wxString &command, const wxString &param)
Entries::const_iterator ByCommandId(const wxString &commandId) const
void DeleteFromMacro(int index)
const wxChar * name
Definition: Distortion.cpp:94
wxArrayString mCommandMacro
Entries::const_iterator end() const
Definition: BatchCommands.h:44
Exporter mExporter
double GetEndTime()
void AddToMessage(const wxString &msgIn)
const Entry & operator[](size_t index) const
Definition: BatchCommands.h:41
bool ApplyCommandInBatchMode(const wxString &friendlyCommand, const wxString &command, const wxString &params)
wxString GetMessage()
EffectDistortion::Params params
Definition: Distortion.cpp:95
MacroCommandsCatalog(const AudacityProject *project)
static void MigrateLegacyChains()
void Split(const wxString &str, wxString &command, wxString &param)
static wxString GetCurrentParamsFor(const wxString &command)
bool IsFixed(const wxString &name)
bool ApplyEffectCommand(const PluginID &ID, const wxString &friendlyCommand, const wxString &command, const wxString &params, const CommandContext &Context)