1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-21 06:01:13 +02:00

Automation: AudacityCommand

This is a squash of 50 commits.

This merges the capabilities of BatchCommands and Effects using a new
AudacityCommand class.  AudacityCommand provides one function to specify the
parameters, and then we leverage that one function in automation, whether by chains,
mod-script-pipe or (future) Nyquist.

- Now have AudacityCommand which is using the same mechanism as Effect
- Has configurable parameters
- Has data-entry GUI (built using shuttle GUI)
- Registers with PluginManager.
- Menu commands now provided in chains, and to python batch.
   - Tested with Zoom Toggle.

- ShuttleParams now can set, get, set defaults, validate and specify
the parameters.
- Bugfix: Don't overwrite values with defaults first time out.
- Add DefineParams function for all built-in effects.
- Extend CommandContext to carry output channels for results.

We abuse EffectsManager.  It handles both Effects and
AudacityCommands now.  In time an Effect should become a special case of
AudacityCommand and we'll split and rename the EffectManager class.

- Don't use 'default' as a parameter name.
- Massive renaming for CommandDefinitionInterface
- EffectIdentInterface becomes EffectDefinitionInterface
- EffectAutomationParameters becomes CommandAutomationParameters
- PluginType is now a bit field.

This way we can search for related types at the same time.

- Most old batch commands made into AudacityCommands.
The ones that weren't are for a reason.  They are used by mod-script-pipe
to carry commands and responses across from a non-GUI thread to the GUI
thread.

- Major tidy up of ScreenshotCommand
- Reworking of SelectCommand
- GetPreferenceCommand and SetPreferenceCommand
- GetTrackInfo and SetTrackInfo
- GetInfoCommand
- Help, Open, Save, Import and Export commands.
- Removed obsolete commands ExecMenu, GetProjectInfo and SetProjectInfo
  which are now better handled by other commands.

- JSONify "GetInfo: Commands" output, i.e. commas in the right places.

- General work on better Doxygen.
    - Lyrics -> LyricsPanel
    - Meter -> MeterPanel
- Updated Linux makefile.
- Scripting commands added into Extra menu.
- Distinct names for previously duplicated find-clipping parameters.
- Fixed longstanding error with erroneous status field number which
  previously caused an ASSERT in debug.
- Sensible formatting of numbers in Chains, 0.1 not 0.1000000000137
This commit is contained in:
James Crook
2018-01-14 18:51:41 +00:00
committed by Paul Licameli
parent b7b01d48e0
commit 1c988b4e3a
191 changed files with 4659 additions and 2768 deletions

View File

@@ -4,7 +4,6 @@
Shuttle.h
Dominic Mazzoni
James Crook
**********************************************************************/
@@ -59,4 +58,134 @@ public:
bool ExchangeWithMaster(const wxString & Name) override;
};
class CommandAutomationParameters;
/**************************************************************************//**
\brief Shuttle that deals with parameters. This is a base class with lots of
pure virtual functions.
********************************************************************************/
class ShuttleParams : public Shuttle
{
public:
wxString mParams;
CommandAutomationParameters * mpEap;
ShuttleParams(){ mParams = wxT("") ;mpEap=NULL;}
virtual ~ShuttleParams() {}
bool ExchangeWithMaster(const wxString & Name) override;
ShuttleParams & Optional( bool & var ){ var = true;return *this;};
virtual void Define( bool & var, const wxChar * key, const bool vdefault, const bool vmin=false, const bool vmax=false, const bool vscl=false )=0;
virtual void Define( size_t & var, const wxChar * key, const int vdefault, const int vmin=0, const int vmax=100000, const int vscl=1 )=0;
virtual void Define( int & var, const wxChar * key, const int vdefault, const int vmin=0, const int vmax=100000, const int vscl=1 )=0;
virtual void Define( float & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl=1.0f )=0;
virtual void Define( double & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl=1.0f )=0;
virtual void Define( double & var, const wxChar * key, const double vdefault, const double vmin, const double vmax, const double vscl=1.0f )=0;
virtual void Define( wxString &var, const wxChar * key, const wxString vdefault, const wxString vmin="", const wxString vmax="", const wxString vscl="" )=0;
virtual void DefineEnum( wxString &var, const wxChar * key, const wxString vdefault, wxArrayString strings )=0;
virtual void DefineEnum( int &var, const wxChar * key, const int vdefault, wxArrayString strings )=0;
};
/**************************************************************************//**
\brief Shuttle that gets parameter values into a string.
********************************************************************************/
class ShuttleGetAutomation : public ShuttleParams
{
public:
void Define( bool & var, const wxChar * key, const bool vdefault, const bool vmin, const bool vmax, const bool vscl ) override;
void Define( int & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl ) override;
void Define( size_t & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl ) override;
void Define( float & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl ) override;
void Define( double & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl ) override;
void Define( double & var, const wxChar * key, const double vdefault, const double vmin, const double vmax, const double vscl ) override;
void Define( wxString &var, const wxChar * key, const wxString vdefault, const wxString vmin, const wxString vmax, const wxString vscl ) override;
void DefineEnum( wxString &var, const wxChar * key, const wxString vdefault, wxArrayString strings )override;
void DefineEnum( int &var, const wxChar * key, const int vdefault, wxArrayString strings )override;
};
/**************************************************************************//**
\brief Shuttle that sets parameters to a value (from a string)
********************************************************************************/
class ShuttleSetAutomation : public ShuttleParams
{
public:
ShuttleSetAutomation(){ bWrite = false; bOK = false;};
bool bOK;
bool bWrite;
void SetForValidating( CommandAutomationParameters * pEap){ mpEap=pEap; bOK=true;bWrite=false;};
void SetForWriting(CommandAutomationParameters * pEap){ mpEap=pEap;bOK=true;bWrite=true;};
void Define( bool & var, const wxChar * key, const bool vdefault, const bool vmin, const bool vmax, const bool vscl ) override;
void Define( int & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl ) override;
void Define( size_t & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl ) override;
void Define( float & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl ) override;
void Define( double & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl ) override;
void Define( double & var, const wxChar * key, const double vdefault, const double vmin, const double vmax, const double vscl ) override;
void Define( wxString &var, const wxChar * key, const wxString vdefault, const wxString vmin, const wxString vmax, const wxString vscl ) override;
void DefineEnum( wxString &var, const wxChar * key, const wxString vdefault, wxArrayString strings )override;
void DefineEnum( int &var, const wxChar * key, const int vdefault, wxArrayString strings )override;
};
/**************************************************************************//**
\brief Shuttle that retrieves a JSON format definition of a command's parameters.
********************************************************************************/
class ShuttleGetDefinition : public ShuttleParams
{
public:
wxString Result;
void Define( bool & var, const wxChar * key, const bool vdefault, const bool vmin, const bool vmax, const bool vscl ) override;
void Define( int & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl ) override;
void Define( size_t & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl ) override;
void Define( float & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl ) override;
void Define( double & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl ) override;
void Define( double & var, const wxChar * key, const double vdefault, const double vmin, const double vmax, const double vscl ) override;
void Define( wxString &var, const wxChar * key, const wxString vdefault, const wxString vmin, const wxString vmax, const wxString vscl ) override;
void DefineEnum( wxString &var, const wxChar * key, const wxString vdefault, wxArrayString strings )override;
void DefineEnum( int &var, const wxChar * key, const int vdefault, wxArrayString strings )override;
};
/**************************************************************************//**
\brief Shuttle that sets parameters to their default values.
********************************************************************************/
class ShuttleDefaults : public ShuttleParams
{
public:
wxString Result;
void Define( bool & var, const wxChar * WXUNUSED(key), const bool vdefault,
const bool WXUNUSED(vmin), const bool WXUNUSED(vmax), const bool WXUNUSED(vscl) )
override { var = vdefault;};
void Define( int & var, const wxChar * WXUNUSED(key), const int vdefault,
const int WXUNUSED(vmin), const int WXUNUSED(vmax), const int WXUNUSED(vscl) )
override { var = vdefault;};
void Define( size_t & var, const wxChar * WXUNUSED(key), const int vdefault,
const int WXUNUSED(vmin), const int WXUNUSED(vmax), const int WXUNUSED(vscl) )
override{ var = vdefault;};
void Define( float & var, const wxChar * WXUNUSED(key), const float vdefault,
const float WXUNUSED(vmin), const float WXUNUSED(vmax), const float WXUNUSED(vscl) )
override { var = vdefault;};
void Define( double & var, const wxChar * WXUNUSED(key), const float vdefault,
const float WXUNUSED(vmin), const float WXUNUSED(vmax), const float WXUNUSED(vscl) )
override { var = vdefault;};
void Define( double & var, const wxChar * WXUNUSED(key), const double vdefault,
const double WXUNUSED(vmin), const double WXUNUSED(vmax), const double WXUNUSED(vscl) )
override { var = vdefault;};
void Define( wxString &var, const wxChar * WXUNUSED(key), const wxString vdefault,
const wxString WXUNUSED(vmin), const wxString WXUNUSED(vmax), const wxString WXUNUSED(vscl) )
override { var = vdefault;};
void DefineEnum( wxString &var, const wxChar * WXUNUSED(key), const wxString vdefault,
wxArrayString WXUNUSED(strings) )
override { var = vdefault;};
void DefineEnum( int &var, const wxChar * WXUNUSED(key), const int vdefault,
wxArrayString WXUNUSED(strings) )
override { var = vdefault;};
};
#define SHUTTLE_PARAM( var, name ) \
Define( var, KEY_ ## name, DEF_ ## name, MIN_ ## name, MAX_ ## name, SCL_ ## name )
#define SHUTTLE_ENUM_PARAM( var, name, strings ) \
DefineEnum( var, KEY_ ## name, DEF_ ## name, strings )
#endif