mirror of
https://github.com/cookiengineer/audacity
synced 2026-02-06 03:32:09 +01: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:
committed by
Paul Licameli
parent
b7b01d48e0
commit
1c988b4e3a
230
src/Shuttle.cpp
230
src/Shuttle.cpp
@@ -64,6 +64,8 @@ preferences.
|
||||
#include <wx/radiobut.h>
|
||||
#include <wx/button.h>
|
||||
|
||||
#include "../include/audacity/EffectAutomationParameters.h" // for command automation
|
||||
|
||||
//#include "Project.h"
|
||||
#include "Shuttle.h"
|
||||
#include "WrappedType.h"
|
||||
@@ -323,3 +325,231 @@ bool ShuttleCli::ExchangeWithMaster(const wxString & Name)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool ShuttleParams::ExchangeWithMaster(const wxString & WXUNUSED(Name))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable: 4100 ) // unused parameters.
|
||||
/*
|
||||
void ShuttleParams::DefineEnum( int &var, const wxChar * key, const int vdefault, wxArrayString strings )
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
void ShuttleGetAutomation::Define( bool & var, const wxChar * key, const bool vdefault, const bool vmin, const bool vmax, const bool vscl )
|
||||
{
|
||||
mpEap->Write(key, var);
|
||||
}
|
||||
|
||||
void ShuttleGetAutomation::Define( int & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl )
|
||||
{
|
||||
mpEap->Write(key, var);
|
||||
}
|
||||
|
||||
void ShuttleGetAutomation::Define( size_t & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl )
|
||||
{
|
||||
mpEap->Write(key, var);
|
||||
}
|
||||
|
||||
void ShuttleGetAutomation::Define( double & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl )
|
||||
{
|
||||
mpEap->WriteFloat(key, var);
|
||||
}
|
||||
|
||||
void ShuttleGetAutomation::Define( float & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl )
|
||||
{
|
||||
mpEap->WriteFloat(key, var);
|
||||
}
|
||||
|
||||
void ShuttleGetAutomation::Define( double & var, const wxChar * key, const double vdefault, const double vmin, const double vmax, const double vscl )
|
||||
{
|
||||
mpEap->Write(key, var);
|
||||
}
|
||||
|
||||
|
||||
void ShuttleGetAutomation::Define( wxString &var, const wxChar * key, const wxString vdefault, const wxString vmin, const wxString vmax, const wxString vscl )
|
||||
{
|
||||
mpEap->Write(key, var);
|
||||
}
|
||||
|
||||
void ShuttleGetAutomation::DefineEnum( wxString &var, const wxChar * key, const wxString vdefault, wxArrayString strings )
|
||||
{
|
||||
mpEap->Write(key, var);
|
||||
}
|
||||
|
||||
void ShuttleGetAutomation::DefineEnum( int &var, const wxChar * key, const int vdefault, wxArrayString strings )
|
||||
{
|
||||
mpEap->Write(key, strings[var]);
|
||||
}
|
||||
|
||||
|
||||
void ShuttleSetAutomation::Define( bool & var, const wxChar * key, const bool vdefault, const bool vmin, const bool vmax, const bool vscl )
|
||||
{
|
||||
if( !bOK )
|
||||
return;
|
||||
// Use of temp in this and related functions is to handle the case of
|
||||
// only committing values if all values pass verification.
|
||||
bool temp =var;
|
||||
bOK = mpEap->ReadAndVerify(key, &temp, vdefault);
|
||||
if( bWrite && bOK)
|
||||
var = temp;
|
||||
}
|
||||
|
||||
void ShuttleSetAutomation::Define( int & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl )
|
||||
{
|
||||
if( !bOK )
|
||||
return;
|
||||
int temp =var;
|
||||
bOK = mpEap->ReadAndVerify(key, &temp, vdefault, vmin, vmax);
|
||||
if( bWrite && bOK)
|
||||
var = temp;
|
||||
}
|
||||
|
||||
void ShuttleSetAutomation::Define( size_t & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl )
|
||||
{
|
||||
if( !bOK )
|
||||
return;
|
||||
int temp = var;
|
||||
bOK = mpEap->ReadAndVerify(key, &temp, vdefault, vmin, vmax);
|
||||
if( bWrite && bOK )
|
||||
var = temp;
|
||||
}
|
||||
|
||||
void ShuttleSetAutomation::Define( float & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl )
|
||||
{
|
||||
if( !bOK )
|
||||
return;
|
||||
float temp = var;
|
||||
bOK = mpEap->ReadAndVerify(key, &temp, vdefault, vmin, vmax);
|
||||
if( bWrite && bOK )
|
||||
var = temp;
|
||||
}
|
||||
|
||||
|
||||
void ShuttleSetAutomation::Define( double & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl )
|
||||
{
|
||||
if( !bOK )
|
||||
return;
|
||||
double temp = var;
|
||||
bOK = mpEap->ReadAndVerify(key, &temp, vdefault, vmin, vmax);
|
||||
if( bWrite && bOK)
|
||||
var = temp;
|
||||
}
|
||||
|
||||
void ShuttleSetAutomation::Define( double & var, const wxChar * key, const double vdefault, const double vmin, const double vmax, const double vscl )
|
||||
{
|
||||
if( !bOK )
|
||||
return;
|
||||
double temp = var;
|
||||
bOK = mpEap->ReadAndVerify(key, &temp, vdefault, vmin, vmax);
|
||||
if( bWrite && bOK)
|
||||
var = temp;
|
||||
}
|
||||
|
||||
|
||||
void ShuttleSetAutomation::Define( wxString &var, const wxChar * key, const wxString vdefault, const wxString vmin, const wxString vmax, const wxString vscl )
|
||||
{
|
||||
if( !bOK )
|
||||
return;
|
||||
wxString temp = var;
|
||||
bOK = mpEap->ReadAndVerify(key, &temp, vdefault);
|
||||
if( bWrite && bOK )
|
||||
var = temp;
|
||||
}
|
||||
|
||||
|
||||
void ShuttleSetAutomation::DefineEnum( wxString &var, const wxChar * key, const wxString vdefault, wxArrayString strings )
|
||||
{
|
||||
if( !bOK )
|
||||
return;
|
||||
int temp =0;
|
||||
bOK = mpEap->ReadAndVerify(key, &temp, vdefault, strings);
|
||||
if( bWrite && bOK)
|
||||
var = strings[temp];
|
||||
}
|
||||
|
||||
void ShuttleSetAutomation::DefineEnum( int &var, const wxChar * key, const int vdefault, wxArrayString strings )
|
||||
{
|
||||
if( !bOK )
|
||||
return;
|
||||
int temp = var;
|
||||
bOK = mpEap->ReadAndVerify(key, &temp, vdefault, strings);
|
||||
if( bWrite && bOK)
|
||||
var = temp;
|
||||
}
|
||||
|
||||
// JSON definitions.
|
||||
// All these MUST end with ",\r\n", so that we can put them in an array (and so we can remove the last "," easily for JSON).
|
||||
void ShuttleGetDefinition::Define( bool & var, const wxChar * key, const bool vdefault, const bool vmin, const bool vmax, const bool vscl )
|
||||
{
|
||||
Result += wxString::Format( " { key: \"%s\", type: \"bool\", default: \"%s\"},\r\n",
|
||||
key , vdefault ? "True" : "False" );
|
||||
}
|
||||
|
||||
void ShuttleGetDefinition::Define( int & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl )
|
||||
{
|
||||
Result += wxString::Format( " { key: \"%s\", type: \"int\", default: \"%i\"},\r\n",
|
||||
key , vdefault );
|
||||
}
|
||||
|
||||
void ShuttleGetDefinition::Define( size_t & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl )
|
||||
{
|
||||
Result += wxString::Format( " { key: \"%s\", type: \"size_t\", default: \"%li\"},\r\n",
|
||||
key , vdefault );
|
||||
}
|
||||
|
||||
void ShuttleGetDefinition::Define( float & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl )
|
||||
{
|
||||
Result += wxString::Format( " { key: \"%s\", type: \"float\", default: \"%f\"},\r\n",
|
||||
key , vdefault );
|
||||
}
|
||||
|
||||
void ShuttleGetDefinition::Define( double & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl )
|
||||
{
|
||||
Result += wxString::Format( " { key: \"%s\", type: \"float\", default: \"%f\"},\r\n",
|
||||
key , vdefault );
|
||||
}
|
||||
|
||||
void ShuttleGetDefinition::Define( double & var, const wxChar * key, const double vdefault, const double vmin, const double vmax, const double vscl )
|
||||
{
|
||||
Result += wxString::Format( " { key: \"%s\", type: \"double\", default: \"%f\"},\r\n",
|
||||
key , vdefault );
|
||||
}
|
||||
|
||||
|
||||
void ShuttleGetDefinition::Define( wxString &var, const wxChar * key, const wxString vdefault, const wxString vmin, const wxString vmax, const wxString vscl )
|
||||
{
|
||||
Result += wxString::Format( " { key: \"%s\", type: \"string\", default: \"%s\"},\r\n",
|
||||
key , vdefault );
|
||||
}
|
||||
|
||||
|
||||
void ShuttleGetDefinition::DefineEnum( wxString &var, const wxChar * key, const wxString vdefault, wxArrayString strings )
|
||||
{
|
||||
Result += wxString::Format( " { key: \"%s\", type: \"enum\", default: \"%s\",\r\n enum : [",
|
||||
key , vdefault );
|
||||
for( size_t i=0;i<strings.Count(); i++ )
|
||||
Result += wxString::Format("%s\"%s\"", (i>0) ? ", ":"", strings[i] );
|
||||
Result += "]\r\n },\r\n";
|
||||
}
|
||||
|
||||
void ShuttleGetDefinition::DefineEnum( int&var, const wxChar * key, const int vdefault, wxArrayString strings )
|
||||
{
|
||||
Result += wxString::Format( " { key: \"%s\", type: \"enum\", default: \"%i\",\r\n enum : [",
|
||||
key , vdefault );
|
||||
for( size_t i=0;i<strings.Count(); i++ )
|
||||
Result += wxString::Format("%s\"%s\"", (i>0) ? ", ":"",strings[i] );
|
||||
Result += "]\r\n },\r\n";
|
||||
}
|
||||
|
||||
#pragma warning( pop )
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user