2010-01-23 19:44:49 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
Echo.cpp
|
|
|
|
|
|
|
|
Dominic Mazzoni
|
|
|
|
Vaughan Johnson (dialog)
|
|
|
|
|
|
|
|
*******************************************************************//**
|
|
|
|
|
|
|
|
\class EffectEcho
|
|
|
|
\brief An Effect that causes an echo, variable delay and volume.
|
|
|
|
|
|
|
|
*//****************************************************************//**
|
|
|
|
|
|
|
|
\class EchoDialog
|
|
|
|
\brief EchoDialog used with EffectEcho
|
|
|
|
|
|
|
|
*//*******************************************************************/
|
|
|
|
|
2021-05-09 15:16:56 +00:00
|
|
|
|
2015-06-18 14:24:36 +00:00
|
|
|
#include "Echo.h"
|
2019-01-17 23:31:08 +00:00
|
|
|
#include "LoadEffects.h"
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
#include <float.h>
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
#include <wx/intl.h>
|
2015-04-17 03:53:42 +00:00
|
|
|
|
2015-06-18 14:24:36 +00:00
|
|
|
#include "../ShuttleGui.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 "../Shuttle.h"
|
2019-05-20 18:27:11 +00:00
|
|
|
#include "../widgets/AudacityMessageBox.h"
|
2015-04-17 03:53:42 +00:00
|
|
|
#include "../widgets/valnum.h"
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
// Define keys, defaults, minimums, and maximums for the effect parameters
|
|
|
|
//
|
2015-04-22 18:04:06 +00:00
|
|
|
// Name Type Key Def Min Max Scale
|
2017-10-03 22:07:04 +00:00
|
|
|
Param( Delay, float, wxT("Delay"), 1.0f, 0.001f, FLT_MAX, 1.0f );
|
|
|
|
Param( Decay, float, wxT("Decay"), 0.5f, 0.0f, FLT_MAX, 1.0f );
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2019-01-17 22:33:49 +00:00
|
|
|
const ComponentInterfaceSymbol EffectEcho::Symbol
|
|
|
|
{ XO("Echo") };
|
|
|
|
|
2019-01-17 23:31:08 +00:00
|
|
|
namespace{ BuiltinEffectsModule::Registration< EffectEcho > reg; }
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
EffectEcho::EffectEcho()
|
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
delay = DEF_Delay;
|
|
|
|
decay = DEF_Decay;
|
2015-05-15 11:47:51 +00:00
|
|
|
|
|
|
|
SetLinearEffectFlag(true);
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
EffectEcho::~EffectEcho()
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
}
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2018-11-02 15:31:44 +00:00
|
|
|
// ComponentInterface implementation
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2018-11-02 15:31:44 +00:00
|
|
|
ComponentInterfaceSymbol EffectEcho::GetSymbol()
|
2015-04-17 03:53:42 +00:00
|
|
|
{
|
2019-01-17 22:33:49 +00:00
|
|
|
return Symbol;
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2019-12-08 18:53:48 +00:00
|
|
|
TranslatableString EffectEcho::GetDescription()
|
2014-06-03 20:30:19 +00:00
|
|
|
{
|
2019-12-08 18:53:48 +00:00
|
|
|
return XO("Repeats the selected audio again and again");
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2021-06-06 16:18:35 +00:00
|
|
|
ManualPageID EffectEcho::ManualPage()
|
2017-05-20 13:40:09 +00:00
|
|
|
{
|
2021-06-06 16:18:35 +00:00
|
|
|
return L"Echo";
|
2017-05-20 13:40:09 +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
|
|
|
// EffectDefinitionInterface implementation
|
2015-04-17 03:53:42 +00:00
|
|
|
|
|
|
|
EffectType EffectEcho::GetType()
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
return EffectTypeProcess;
|
|
|
|
}
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
// EffectClientInterface implementation
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2016-09-02 19:53:09 +00:00
|
|
|
unsigned EffectEcho::GetAudioInCount()
|
2015-04-17 03:53:42 +00:00
|
|
|
{
|
|
|
|
return 1;
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2016-09-02 19:53:09 +00:00
|
|
|
unsigned EffectEcho::GetAudioOutCount()
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
bool EffectEcho::ProcessInitialize(sampleCount WXUNUSED(totalLen), ChannelNames WXUNUSED(chanMap))
|
|
|
|
{
|
2015-04-22 18:04:06 +00:00
|
|
|
if (delay == 0.0)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
histPos = 0;
|
2016-08-31 04:49:22 +00:00
|
|
|
auto requestedHistLen = (sampleCount) (mSampleRate * delay);
|
2016-08-28 15:25:53 +00:00
|
|
|
|
|
|
|
// Guard against extreme delay values input by the user
|
|
|
|
try {
|
2016-08-31 04:49:22 +00:00
|
|
|
// Guard against huge delay values from the user.
|
|
|
|
// Don't violate the assertion in as_size_t
|
|
|
|
if (requestedHistLen !=
|
|
|
|
(histLen = static_cast<size_t>(requestedHistLen.as_long_long())))
|
|
|
|
throw std::bad_alloc{};
|
2016-04-14 16:35:15 +00:00
|
|
|
history.reinit(histLen, true);
|
2016-08-28 15:25:53 +00:00
|
|
|
}
|
|
|
|
catch ( const std::bad_alloc& ) {
|
2019-12-19 19:19:51 +00:00
|
|
|
Effect::MessageBox( XO("Requested value exceeds memory capacity.") );
|
2016-08-28 15:25:53 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
return history != NULL;
|
|
|
|
}
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
bool EffectEcho::ProcessFinalize()
|
|
|
|
{
|
2016-04-14 16:35:15 +00:00
|
|
|
history.reset();
|
2015-04-17 03:53:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2016-09-06 13:19:27 +00:00
|
|
|
size_t EffectEcho::ProcessBlock(float **inBlock, float **outBlock, size_t blockLen)
|
2015-04-17 03:53:42 +00:00
|
|
|
{
|
|
|
|
float *ibuf = inBlock[0];
|
|
|
|
float *obuf = outBlock[0];
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2016-08-24 15:24:26 +00:00
|
|
|
for (decltype(blockLen) i = 0; i < blockLen; i++, histPos++)
|
2015-04-17 03:53:42 +00:00
|
|
|
{
|
|
|
|
if (histPos == histLen)
|
|
|
|
{
|
|
|
|
histPos = 0;
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
2015-04-17 03:53:42 +00:00
|
|
|
history[histPos] = obuf[i] = ibuf[i] + history[histPos] * decay;
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
return blockLen;
|
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
|
|
|
bool EffectEcho::DefineParams( ShuttleParams & S ){
|
|
|
|
S.SHUTTLE_PARAM( delay, Delay );
|
|
|
|
S.SHUTTLE_PARAM( decay, Decay );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-21 14:24:25 +00:00
|
|
|
bool EffectEcho::GetAutomationParameters(CommandParameters & parms)
|
2015-04-17 03:53:42 +00:00
|
|
|
{
|
|
|
|
parms.WriteFloat(KEY_Delay, delay);
|
|
|
|
parms.WriteFloat(KEY_Decay, decay);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2018-02-21 14:24:25 +00:00
|
|
|
bool EffectEcho::SetAutomationParameters(CommandParameters & parms)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
ReadAndVerifyFloat(Delay);
|
|
|
|
ReadAndVerifyFloat(Decay);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
delay = Delay;
|
|
|
|
decay = Decay;
|
2013-02-23 04:33:20 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
return true;
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectEcho::PopulateOrExchange(ShuttleGui & S)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2014-06-03 20:30:19 +00:00
|
|
|
S.AddSpace(0, 5);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
S.StartMultiColumn(2, wxALIGN_CENTER);
|
|
|
|
{
|
2017-10-30 16:23:41 +00:00
|
|
|
S.Validator<FloatingPointValidator<double>>(
|
|
|
|
3, &delay, NumValidatorStyle::NO_TRAILING_ZEROES,
|
|
|
|
MIN_Delay, MAX_Delay
|
|
|
|
)
|
2020-05-11 15:28:14 +00:00
|
|
|
.AddTextBox(XXO("&Delay time (seconds):"), wxT(""), 10);
|
2017-10-30 16:23:41 +00:00
|
|
|
|
|
|
|
S.Validator<FloatingPointValidator<double>>(
|
|
|
|
3, &decay, NumValidatorStyle::NO_TRAILING_ZEROES,
|
|
|
|
MIN_Decay, MAX_Decay)
|
2020-05-11 15:28:14 +00:00
|
|
|
.AddTextBox(XXO("D&ecay factor:"), wxT(""), 10);
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
S.EndMultiColumn();
|
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
bool EffectEcho::TransferDataToWindow()
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
if (!mUIParent->TransferDataToWindow())
|
|
|
|
{
|
|
|
|
return false;
|
2013-02-23 04:33:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
bool EffectEcho::TransferDataFromWindow()
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
|
|
|
|
{
|
|
|
|
return false;
|
2013-02-23 04:33:20 +00:00
|
|
|
}
|
2015-04-17 03:53:42 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|