2010-01-23 19:44:49 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity - A Digital Audio Editor
|
|
|
|
Copyright 1999-2009 Audacity Team
|
|
|
|
File License: wxWidgets
|
|
|
|
|
|
|
|
Dan Horgan
|
|
|
|
|
|
|
|
******************************************************************//**
|
|
|
|
|
|
|
|
\file CommandBuilder.cpp
|
|
|
|
\brief Contains definitions for CommandBuilder class.
|
|
|
|
|
|
|
|
\class CommandBuilder
|
|
|
|
\brief A type of factory for Commands of various sorts.
|
|
|
|
|
|
|
|
CommandBuilder has the task of deciding what command is meant by a given
|
|
|
|
command string, and producing a suitable command object. For now, it doesn't
|
|
|
|
actually do any processing - it just passes everything on to the BatchCommand
|
|
|
|
system by constructing BatchCommandEval objects.
|
|
|
|
|
|
|
|
*//*******************************************************************/
|
|
|
|
|
2021-05-09 15:16:56 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
#include "CommandBuilder.h"
|
2018-11-11 02:40:37 +00:00
|
|
|
|
2016-04-10 02:55:15 +00:00
|
|
|
#include "CommandDirectory.h"
|
2019-05-18 17:20:19 +00:00
|
|
|
#include "Command.h"
|
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
2018-01-14 18:51:41 +00:00
|
|
|
#include "CommandContext.h"
|
2019-05-14 17:56:38 +00:00
|
|
|
#include "CommandTargets.h"
|
2019-05-20 17:28:21 +00:00
|
|
|
#include "../Shuttle.h"
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2019-05-22 01:20:58 +00:00
|
|
|
CommandBuilder::CommandBuilder(
|
|
|
|
AudacityProject *project, const wxString &cmdString)
|
2016-03-31 11:40:05 +00:00
|
|
|
: mValid(false)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2019-05-22 01:20:58 +00:00
|
|
|
BuildCommand(project, cmdString);
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2019-05-22 01:20:58 +00:00
|
|
|
CommandBuilder::CommandBuilder(AudacityProject *project,
|
|
|
|
const wxString &cmdName, const wxString ¶ms)
|
2016-03-31 11:40:05 +00:00
|
|
|
: mValid(false)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2019-05-22 01:20:58 +00:00
|
|
|
BuildCommand(project, cmdName, params);
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2014-06-03 20:30:19 +00:00
|
|
|
CommandBuilder::~CommandBuilder()
|
|
|
|
{
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2014-06-03 20:30:19 +00:00
|
|
|
bool CommandBuilder::WasValid()
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2014-06-03 20:30:19 +00:00
|
|
|
return mValid;
|
2010-01-23 19:44:49 +00: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
2018-01-14 18:51:41 +00:00
|
|
|
OldStyleCommandPointer CommandBuilder::GetCommand()
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
wxASSERT(mValid);
|
2016-03-31 11:40:05 +00:00
|
|
|
wxASSERT(mCommand);
|
|
|
|
auto result = mCommand;
|
|
|
|
mCommand.reset();
|
|
|
|
return result;
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2020-04-17 03:14:45 +00:00
|
|
|
wxString CommandBuilder::GetResponse()
|
|
|
|
{
|
|
|
|
if (!mValid && !mError.empty()) {
|
|
|
|
return mError + wxT("\n");
|
|
|
|
}
|
|
|
|
return mResponse->GetResponse() + wxT("\n");
|
|
|
|
}
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
void CommandBuilder::Failure(const wxString &msg)
|
|
|
|
{
|
|
|
|
mError = msg;
|
|
|
|
mValid = false;
|
|
|
|
}
|
|
|
|
|
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
2018-01-14 18:51:41 +00:00
|
|
|
void CommandBuilder::Success(const OldStyleCommandPointer &cmd)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
mCommand = cmd;
|
|
|
|
mValid = true;
|
|
|
|
}
|
|
|
|
|
2019-05-22 01:20:58 +00:00
|
|
|
void CommandBuilder::BuildCommand(AudacityProject *project,
|
|
|
|
const wxString &cmdName,
|
2016-02-23 02:17:41 +00:00
|
|
|
const wxString &cmdParamsArg)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
// Stage 1: create a Command object of the right type
|
|
|
|
|
2020-04-17 03:14:45 +00:00
|
|
|
mResponse = std::make_shared< ResponseTarget >();
|
2016-03-31 11:40:05 +00:00
|
|
|
auto output
|
2018-02-08 19:08:50 +00:00
|
|
|
= std::make_unique<CommandOutputTargets>(std::make_unique<NullProgressTarget>(),
|
2020-04-17 03:14:45 +00:00
|
|
|
mResponse,
|
|
|
|
mResponse);
|
2010-01-23 19:44:49 +00: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
2018-01-14 18:51:41 +00:00
|
|
|
#ifdef OLD_BATCH_SYSTEM
|
2018-02-07 21:50:55 +00:00
|
|
|
OldStyleCommandType *factory = CommandDirectory::Get()->LookUp(cmdName);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
if (factory == NULL)
|
|
|
|
{
|
|
|
|
// Fall back to hoping the Batch Command system can handle it
|
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
2018-01-14 18:51:41 +00:00
|
|
|
#endif
|
2018-02-07 21:50:55 +00:00
|
|
|
OldStyleCommandType *type = CommandDirectory::Get()->LookUp(wxT("BatchCommand"));
|
2010-01-23 19:44:49 +00:00
|
|
|
wxASSERT(type != NULL);
|
2019-05-22 01:20:58 +00:00
|
|
|
mCommand = type->Create(project, nullptr);
|
2010-01-23 19:44:49 +00:00
|
|
|
mCommand->SetParameter(wxT("CommandName"), cmdName);
|
2016-02-23 02:17:41 +00:00
|
|
|
mCommand->SetParameter(wxT("ParamString"), cmdParamsArg);
|
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
2018-01-14 18:51:41 +00:00
|
|
|
auto aCommand = std::make_shared<ApplyAndSendResponse>(mCommand, output);
|
|
|
|
Success(aCommand);
|
2010-01-23 19:44:49 +00:00
|
|
|
return;
|
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
2018-01-14 18:51:41 +00:00
|
|
|
#ifdef OLD_BATCH_SYSTEM
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CommandSignature &signature = factory->GetSignature();
|
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
2018-01-14 18:51:41 +00:00
|
|
|
mCommand = factory->Create(nullptr);
|
|
|
|
//mCommand->SetOutput( std::move(output) );
|
2010-01-23 19:44:49 +00:00
|
|
|
// Stage 2: set the parameters
|
|
|
|
|
|
|
|
ShuttleCli shuttle;
|
2016-02-23 02:17:41 +00:00
|
|
|
shuttle.mParams = cmdParamsArg;
|
2010-01-23 19:44:49 +00:00
|
|
|
shuttle.mbStoreInClient = true;
|
|
|
|
|
|
|
|
ParamValueMap::const_iterator iter;
|
|
|
|
ParamValueMap params = signature.GetDefaults();
|
|
|
|
|
2017-12-20 19:58:05 +00:00
|
|
|
// Iterate through the parameters defined by the command
|
2010-01-23 19:44:49 +00:00
|
|
|
for (iter = params.begin(); iter != params.end(); ++iter)
|
|
|
|
{
|
|
|
|
wxString paramString;
|
2017-12-20 19:58:05 +00:00
|
|
|
// IF there is a match in the args actually used
|
2010-01-23 19:44:49 +00:00
|
|
|
if (shuttle.TransferString(iter->first, paramString, wxT("")))
|
|
|
|
{
|
2017-12-20 19:58:05 +00:00
|
|
|
// Then set that parameter.
|
2010-01-23 19:44:49 +00:00
|
|
|
if (!mCommand->SetParameter(iter->first, paramString))
|
|
|
|
{
|
|
|
|
Failure();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check for unrecognised parameters
|
|
|
|
|
2016-02-23 02:17:41 +00:00
|
|
|
wxString cmdParams(cmdParamsArg);
|
|
|
|
|
2019-03-14 20:20:18 +00:00
|
|
|
while (!cmdParams.empty())
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
cmdParams.Trim(true);
|
|
|
|
cmdParams.Trim(false);
|
|
|
|
int splitAt = cmdParams.Find(wxT('='));
|
2019-03-14 20:20:18 +00:00
|
|
|
if (splitAt < 0 && !cmdParams.empty())
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
Failure(wxT("Parameter string is missing '='"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
wxString paramName = cmdParams.Left(splitAt);
|
|
|
|
if (params.find(paramName) == params.end())
|
|
|
|
{
|
2012-04-25 22:44:00 +00:00
|
|
|
Failure(wxT("Unrecognized parameter: '") + paramName + wxT("'"));
|
2010-01-23 19:44:49 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-04-11 07:08:33 +00:00
|
|
|
// Handling of quoted strings is quite limited.
|
2018-01-18 15:30:05 +00:00
|
|
|
// You start and end with a " or a '.
|
|
|
|
// There is no escaping in the string.
|
2010-01-23 19:44:49 +00:00
|
|
|
cmdParams = cmdParams.Mid(splitAt+1);
|
2019-02-12 00:10:48 +00:00
|
|
|
if( cmdParams.empty() )
|
2018-01-18 15:30:05 +00:00
|
|
|
splitAt =-1;
|
|
|
|
else if( cmdParams[0] == '\"' ){
|
|
|
|
cmdParams = cmdParams.Mid(1);
|
|
|
|
splitAt = cmdParams.Find(wxT('\"'))+1;
|
|
|
|
}
|
|
|
|
else if( cmdParams[0] == '\'' ){
|
|
|
|
cmdParams = cmdParams.Mid(1);
|
|
|
|
splitAt = cmdParams.Find(wxT('\''))+1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
splitAt = cmdParams.Find(wxT(' '))+1;
|
|
|
|
if (splitAt < 1)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2019-03-06 19:53:39 +00:00
|
|
|
splitAt = cmdParams.length();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
cmdParams = cmdParams.Mid(splitAt);
|
|
|
|
}
|
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
2018-01-14 18:51:41 +00:00
|
|
|
auto aCommand = std::make_shared<ApplyAndSendResponse>(mCommand, output);
|
|
|
|
Success(aCommand);
|
|
|
|
#endif
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2019-05-22 01:20:58 +00:00
|
|
|
void CommandBuilder::BuildCommand(
|
|
|
|
AudacityProject *project, const wxString &cmdStringArg)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2016-02-23 02:17:41 +00:00
|
|
|
wxString cmdString(cmdStringArg);
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
// Find the command name terminator... If there is more than one word and
|
|
|
|
// no terminator, the command is badly formed
|
|
|
|
cmdString.Trim(true); cmdString.Trim(false);
|
|
|
|
int splitAt = cmdString.Find(wxT(':'));
|
|
|
|
if (splitAt < 0 && cmdString.Find(wxT(' ')) >= 0) {
|
2020-04-17 03:14:45 +00:00
|
|
|
Failure(wxT("Syntax error!\nCommand is missing ':'"));
|
2010-01-23 19:44:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString cmdName = cmdString.Left(splitAt);
|
|
|
|
wxString cmdParams = cmdString.Mid(splitAt+1);
|
2017-12-20 21:19:23 +00:00
|
|
|
if( splitAt < 0 )
|
|
|
|
cmdParams = "";
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
cmdName.Trim(true);
|
|
|
|
cmdParams.Trim(false);
|
|
|
|
|
2019-05-22 01:20:58 +00:00
|
|
|
BuildCommand(project, cmdName, cmdParams);
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|