2010-01-23 19:44:49 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
ClickRemoval.cpp
|
|
|
|
|
|
|
|
Craig DeForest
|
|
|
|
|
|
|
|
*******************************************************************//**
|
|
|
|
|
|
|
|
\class EffectClickRemoval
|
2015-05-09 16:36:54 +00:00
|
|
|
\brief An Effect for removing clicks.
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
Clicks are identified as small regions of high amplitude compared
|
|
|
|
to the surrounding chunk of sound. Anything sufficiently tall compared
|
|
|
|
to a large (2048 sample) window around it, and sufficiently narrow,
|
|
|
|
is considered to be a click.
|
|
|
|
|
|
|
|
The structure was largely stolen from Domonic Mazzoni's NoiseRemoval
|
2016-02-13 15:43:16 +00:00
|
|
|
module, and reworked for the NEW effect.
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
This file is intended to become part of Audacity. You may modify
|
|
|
|
and/or distribute it under the same terms as Audacity itself.
|
|
|
|
|
|
|
|
*//*******************************************************************/
|
|
|
|
|
2021-05-09 15:16:56 +00:00
|
|
|
|
2015-06-18 14:24:36 +00:00
|
|
|
#include "ClickRemoval.h"
|
2019-01-17 23:31:08 +00:00
|
|
|
#include "LoadEffects.h"
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include <wx/intl.h>
|
2018-11-11 21:18:23 +00:00
|
|
|
#include <wx/slider.h>
|
2015-04-17 03:53:42 +00:00
|
|
|
#include <wx/valgen.h>
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
#include "../Prefs.h"
|
2019-02-06 18:44:52 +00:00
|
|
|
#include "../Shuttle.h"
|
2015-06-18 14:24:36 +00:00
|
|
|
#include "../ShuttleGui.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-07-03 04:20:21 +00:00
|
|
|
#include "../WaveTrack.h"
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
ID_Thresh = 10000,
|
|
|
|
ID_Width
|
|
|
|
};
|
|
|
|
|
|
|
|
// Define keys, defaults, minimums, and maximums for the effect parameters
|
|
|
|
//
|
2015-04-19 03:49:05 +00:00
|
|
|
// Name Type Key Def Min Max Scale
|
2017-10-03 22:07:04 +00:00
|
|
|
Param( Threshold, int, wxT("Threshold"), 200, 0, 900, 1 );
|
|
|
|
Param( Width, int, wxT("Width"), 20, 0, 40, 1 );
|
2015-04-17 03:53:42 +00:00
|
|
|
|
2019-01-17 22:33:49 +00:00
|
|
|
const ComponentInterfaceSymbol EffectClickRemoval::Symbol
|
|
|
|
{ XO("Click Removal") };
|
|
|
|
|
2019-01-17 23:31:08 +00:00
|
|
|
namespace{ BuiltinEffectsModule::Registration< EffectClickRemoval > reg; }
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
BEGIN_EVENT_TABLE(EffectClickRemoval, wxEvtHandler)
|
|
|
|
EVT_SLIDER(ID_Thresh, EffectClickRemoval::OnThreshSlider)
|
|
|
|
EVT_SLIDER(ID_Width, EffectClickRemoval::OnWidthSlider)
|
|
|
|
EVT_TEXT(ID_Thresh, EffectClickRemoval::OnThreshText)
|
|
|
|
EVT_TEXT(ID_Width, EffectClickRemoval::OnWidthText)
|
|
|
|
END_EVENT_TABLE()
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
EffectClickRemoval::EffectClickRemoval()
|
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
mThresholdLevel = DEF_Threshold;
|
|
|
|
mClickWidth = DEF_Width;
|
|
|
|
|
2015-05-15 11:47:51 +00:00
|
|
|
SetLinearEffectFlag(false);
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
windowSize = 8192;
|
2013-12-17 02:29:02 +00:00
|
|
|
sep = 2049;
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EffectClickRemoval::~EffectClickRemoval()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-11-02 15:31:44 +00:00
|
|
|
// ComponentInterface implementation
|
2015-04-17 03:53:42 +00:00
|
|
|
|
2018-11-02 15:31:44 +00:00
|
|
|
ComponentInterfaceSymbol EffectClickRemoval::GetSymbol()
|
2010-01-23 19:44:49 +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 EffectClickRemoval::GetDescription()
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2019-12-08 18:53:48 +00:00
|
|
|
return XO("Click Removal is designed to remove clicks on audio tracks");
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2021-06-06 16:18:35 +00:00
|
|
|
ManualPageID EffectClickRemoval::ManualPage()
|
2017-05-20 13:40:09 +00:00
|
|
|
{
|
2021-06-06 16:18:35 +00:00
|
|
|
return L"Click_Removal";
|
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 EffectClickRemoval::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
|
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 EffectClickRemoval::DefineParams( ShuttleParams & S ){
|
|
|
|
S.SHUTTLE_PARAM( mThresholdLevel, Threshold );
|
|
|
|
S.SHUTTLE_PARAM( mClickWidth, Width );
|
|
|
|
return true;
|
|
|
|
}
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2018-02-21 14:24:25 +00:00
|
|
|
bool EffectClickRemoval::GetAutomationParameters(CommandParameters & parms)
|
2015-04-17 03:53:42 +00:00
|
|
|
{
|
|
|
|
parms.Write(KEY_Threshold, mThresholdLevel);
|
|
|
|
parms.Write(KEY_Width, mClickWidth);
|
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 EffectClickRemoval::SetAutomationParameters(CommandParameters & parms)
|
2015-04-17 03:53:42 +00:00
|
|
|
{
|
|
|
|
ReadAndVerifyInt(Threshold);
|
|
|
|
ReadAndVerifyInt(Width);
|
|
|
|
|
|
|
|
mThresholdLevel = Threshold;
|
|
|
|
mClickWidth = Width;
|
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
|
|
|
}
|
2013-12-17 02:29:02 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
// Effect implementation
|
|
|
|
|
|
|
|
bool EffectClickRemoval::CheckWhetherSkipEffect()
|
2014-06-03 20:30:19 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
return ((mClickWidth == 0) || (mThresholdLevel == 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectClickRemoval::Startup()
|
|
|
|
{
|
|
|
|
wxString base = wxT("/Effects/ClickRemoval/");
|
|
|
|
|
|
|
|
// Migrate settings from 2.1.0 or before
|
|
|
|
|
|
|
|
// Already migrated, so bail
|
|
|
|
if (gPrefs->Exists(base + wxT("Migrated")))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load the old "current" settings
|
|
|
|
if (gPrefs->Exists(base))
|
|
|
|
{
|
|
|
|
mThresholdLevel = gPrefs->Read(base + wxT("ClickThresholdLevel"), 200);
|
|
|
|
if ((mThresholdLevel < MIN_Threshold) || (mThresholdLevel > MAX_Threshold))
|
|
|
|
{ // corrupted Prefs?
|
|
|
|
mThresholdLevel = 0; //Off-skip
|
|
|
|
}
|
|
|
|
mClickWidth = gPrefs->Read(base + wxT("ClickWidth"), 20);
|
|
|
|
if ((mClickWidth < MIN_Width) || (mClickWidth > MAX_Width))
|
|
|
|
{ // corrupted Prefs?
|
|
|
|
mClickWidth = 0; //Off-skip
|
|
|
|
}
|
|
|
|
|
|
|
|
SaveUserPreset(GetCurrentSettingsGroup());
|
|
|
|
|
|
|
|
// Do not migrate again
|
|
|
|
gPrefs->Write(base + wxT("Migrated"), true);
|
|
|
|
gPrefs->Flush();
|
|
|
|
}
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectClickRemoval::Process()
|
|
|
|
{
|
|
|
|
this->CopyInputTracks(); // Set up mOutputTracks.
|
|
|
|
bool bGoodResult = true;
|
2014-06-03 20:30:19 +00:00
|
|
|
mbDidSomething = false;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
int count = 0;
|
2018-09-11 17:07:32 +00:00
|
|
|
for( auto track : mOutputTracks->Selected< WaveTrack >() ) {
|
2010-01-23 19:44:49 +00:00
|
|
|
double trackStart = track->GetStartTime();
|
|
|
|
double trackEnd = track->GetEndTime();
|
|
|
|
double t0 = mT0 < trackStart? trackStart: mT0;
|
|
|
|
double t1 = mT1 > trackEnd? trackEnd: mT1;
|
|
|
|
|
|
|
|
if (t1 > t0) {
|
2016-08-24 15:24:26 +00:00
|
|
|
auto start = track->TimeToLongSamples(t0);
|
|
|
|
auto end = track->TimeToLongSamples(t1);
|
|
|
|
auto len = end - start;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
if (!ProcessOne(count, track, start, len))
|
|
|
|
{
|
|
|
|
bGoodResult = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
count++;
|
|
|
|
}
|
2014-06-03 20:30:19 +00:00
|
|
|
if (bGoodResult && !mbDidSomething) // Processing successful, but ineffective.
|
2017-09-10 14:42:33 +00:00
|
|
|
Effect::MessageBox(
|
2019-12-19 19:19:51 +00:00
|
|
|
XO("Algorithm not effective on this audio. Nothing changed."),
|
|
|
|
wxOK | wxICON_ERROR );
|
2013-12-17 03:07:26 +00:00
|
|
|
|
2014-06-03 20:30:19 +00:00
|
|
|
this->ReplaceProcessedTracks(bGoodResult && mbDidSomething);
|
2013-12-17 03:07:26 +00:00
|
|
|
return bGoodResult && mbDidSomething;
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2013-12-15 03:57:36 +00:00
|
|
|
bool EffectClickRemoval::ProcessOne(int count, WaveTrack * track, sampleCount start, sampleCount len)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2016-09-08 18:28:34 +00:00
|
|
|
if (len <= windowSize / 2)
|
2013-12-15 03:57:36 +00:00
|
|
|
{
|
2017-09-10 14:42:33 +00:00
|
|
|
Effect::MessageBox(
|
2019-12-19 19:19:51 +00:00
|
|
|
XO("Selection must be larger than %d samples.")
|
|
|
|
.Format(windowSize / 2),
|
|
|
|
wxOK | wxICON_ERROR );
|
2014-06-03 20:30:19 +00:00
|
|
|
return false;
|
2013-12-15 03:57:36 +00:00
|
|
|
}
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2016-08-24 15:24:26 +00:00
|
|
|
auto idealBlockLen = track->GetMaxBlockSize() * 4;
|
2010-01-23 19:44:49 +00:00
|
|
|
if (idealBlockLen % windowSize != 0)
|
|
|
|
idealBlockLen += (windowSize - (idealBlockLen % windowSize));
|
|
|
|
|
2014-06-03 20:30:19 +00:00
|
|
|
bool bResult = true;
|
2016-08-24 15:24:26 +00:00
|
|
|
decltype(len) s = 0;
|
2016-04-14 16:35:15 +00:00
|
|
|
Floats buffer{ idealBlockLen };
|
|
|
|
Floats datawindow{ windowSize };
|
2016-09-08 18:28:34 +00:00
|
|
|
while ((len - s) > windowSize / 2)
|
2013-12-15 03:57:36 +00:00
|
|
|
{
|
2016-08-27 02:02:58 +00:00
|
|
|
auto block = limitSampleBufferSize( idealBlockLen, len - s );
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2021-05-23 21:43:38 +00:00
|
|
|
track->GetFloats(buffer.get(), start + s, block);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2016-09-08 18:28:34 +00:00
|
|
|
for (decltype(block) i = 0; i + windowSize / 2 < block; i += windowSize / 2)
|
2013-12-15 03:57:36 +00:00
|
|
|
{
|
2016-09-08 18:28:34 +00:00
|
|
|
auto wcopy = std::min( windowSize, block - i );
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2016-09-08 18:28:34 +00:00
|
|
|
for(decltype(wcopy) j = 0; j < wcopy; j++)
|
2010-01-23 19:44:49 +00:00
|
|
|
datawindow[j] = buffer[i+j];
|
2016-09-08 18:28:34 +00:00
|
|
|
for(auto j = wcopy; j < windowSize; j++)
|
2010-01-23 19:44:49 +00:00
|
|
|
datawindow[j] = 0;
|
|
|
|
|
2016-04-14 16:35:15 +00:00
|
|
|
mbDidSomething |= RemoveClicks(windowSize, datawindow.get());
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2016-09-08 18:28:34 +00:00
|
|
|
for(decltype(wcopy) j = 0; j < wcopy; j++)
|
2010-01-23 19:44:49 +00:00
|
|
|
buffer[i+j] = datawindow[j];
|
|
|
|
}
|
|
|
|
|
2013-12-17 03:07:26 +00:00
|
|
|
if (mbDidSomething) // RemoveClicks() actually did something.
|
2016-04-14 16:35:15 +00:00
|
|
|
track->Set((samplePtr) buffer.get(), floatSample, start + s, block);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
s += block;
|
|
|
|
|
2016-08-25 12:53:59 +00:00
|
|
|
if (TrackProgress(count, s.as_double() /
|
|
|
|
len.as_double())) {
|
2013-12-17 03:07:26 +00:00
|
|
|
bResult = false;
|
2010-01-23 19:44:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-15 03:57:36 +00:00
|
|
|
return bResult;
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2016-04-14 16:35:15 +00:00
|
|
|
bool EffectClickRemoval::RemoveClicks(size_t len, float *buffer)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2014-06-03 20:30:19 +00:00
|
|
|
bool bResult = false; // This effect usually does nothing.
|
2017-12-08 11:26:09 +00:00
|
|
|
size_t i;
|
|
|
|
size_t j;
|
2010-01-23 19:44:49 +00:00
|
|
|
int left = 0;
|
|
|
|
|
|
|
|
float msw;
|
|
|
|
int ww;
|
|
|
|
int s2 = sep/2;
|
2016-04-14 16:35:15 +00:00
|
|
|
Floats ms_seq{ len };
|
|
|
|
Floats b2{ len };
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
for( i=0; i<len; i++)
|
|
|
|
b2[i] = buffer[i]*buffer[i];
|
|
|
|
|
|
|
|
/* Shortcut for rms - multiple passes through b2, accumulating
|
|
|
|
* as we go.
|
|
|
|
*/
|
|
|
|
for(i=0;i<len;i++)
|
|
|
|
ms_seq[i]=b2[i];
|
|
|
|
|
2017-12-08 11:26:09 +00:00
|
|
|
for(i=1; (int)i < sep; i *= 2) {
|
2010-01-23 19:44:49 +00:00
|
|
|
for(j=0;j<len-i; j++)
|
|
|
|
ms_seq[j] += ms_seq[j+i];
|
2018-01-06 23:41:03 +00:00
|
|
|
}
|
2013-12-16 03:36:33 +00:00
|
|
|
|
2018-01-06 23:41:03 +00:00
|
|
|
/* Cheat by truncating sep to next-lower power of two... */
|
|
|
|
sep = i;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2018-01-06 23:41:03 +00:00
|
|
|
for( i=0; i<len-sep; i++ ) {
|
|
|
|
ms_seq[i] /= sep;
|
|
|
|
}
|
|
|
|
/* ww runs from about 4 to mClickWidth. wrc is the reciprocal;
|
|
|
|
* chosen so that integer roundoff doesn't clobber us.
|
|
|
|
*/
|
|
|
|
int wrc;
|
|
|
|
for(wrc=mClickWidth/4; wrc>=1; wrc /= 2) {
|
|
|
|
ww = mClickWidth/wrc;
|
|
|
|
|
|
|
|
for( i=0; i<len-sep; i++ ){
|
|
|
|
msw = 0;
|
|
|
|
for( j=0; (int)j<ww; j++) {
|
|
|
|
msw += b2[i+s2+j];
|
|
|
|
}
|
|
|
|
msw /= ww;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2018-01-06 23:41:03 +00:00
|
|
|
if(msw >= mThresholdLevel * ms_seq[i]/10) {
|
|
|
|
if( left == 0 ) {
|
|
|
|
left = i+s2;
|
|
|
|
}
|
|
|
|
} else {
|
2018-01-23 11:49:15 +00:00
|
|
|
if(left != 0 && ((int)i-left+s2) <= ww*2) {
|
2018-01-06 23:41:03 +00:00
|
|
|
float lv = buffer[left];
|
|
|
|
float rv = buffer[i+ww+s2];
|
|
|
|
for(j=left; j<i+ww+s2; j++) {
|
|
|
|
bResult = true;
|
|
|
|
buffer[j]= (rv*(j-left) + lv*(i+ww+s2-j))/(float)(i+ww+s2-left);
|
|
|
|
b2[j] = buffer[j]*buffer[j];
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
2018-01-06 23:41:03 +00:00
|
|
|
left=0;
|
|
|
|
} else if(left != 0) {
|
2010-01-23 19:44:49 +00:00
|
|
|
left = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-12-16 03:36:33 +00:00
|
|
|
return bResult;
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectClickRemoval::PopulateOrExchange(ShuttleGui & S)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2013-06-21 22:10:50 +00:00
|
|
|
S.AddSpace(0, 5);
|
|
|
|
S.SetBorder(10);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
S.StartMultiColumn(3, wxEXPAND);
|
|
|
|
S.SetStretchyCol(2);
|
|
|
|
{
|
|
|
|
// Threshold
|
2017-10-30 16:23:41 +00:00
|
|
|
mThreshT = S.Id(ID_Thresh)
|
|
|
|
.Validator<IntegerValidator<int>>(
|
|
|
|
&mThresholdLevel, NumValidatorStyle::DEFAULT,
|
|
|
|
MIN_Threshold, MAX_Threshold
|
|
|
|
)
|
2020-05-11 15:28:14 +00:00
|
|
|
.AddTextBox(XXO("&Threshold (lower is more sensitive):"),
|
2017-10-30 16:23:41 +00:00
|
|
|
wxT(""),
|
|
|
|
10);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2017-10-30 16:23:41 +00:00
|
|
|
mThreshS = S.Id(ID_Thresh)
|
2017-10-29 14:27:23 +00:00
|
|
|
.Name(XO("Threshold"))
|
2017-10-31 18:52:01 +00:00
|
|
|
.Style(wxSL_HORIZONTAL)
|
2017-10-30 16:23:41 +00:00
|
|
|
.Validator<wxGenericValidator>(&mThresholdLevel)
|
2018-01-31 20:31:22 +00:00
|
|
|
.MinSize( { 150, -1 } )
|
2017-10-30 16:23:41 +00:00
|
|
|
.AddSlider( {}, mThresholdLevel, MAX_Threshold, MIN_Threshold);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
// Click width
|
2017-10-30 16:23:41 +00:00
|
|
|
mWidthT = S.Id(ID_Width)
|
|
|
|
.Validator<IntegerValidator<int>>(
|
|
|
|
&mClickWidth, NumValidatorStyle::DEFAULT, MIN_Width, MAX_Width)
|
2020-05-11 15:28:14 +00:00
|
|
|
.AddTextBox(XXO("Max &Spike Width (higher is more sensitive):"),
|
2017-10-30 16:23:41 +00:00
|
|
|
wxT(""),
|
|
|
|
10);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2017-10-30 16:23:41 +00:00
|
|
|
mWidthS = S.Id(ID_Width)
|
2017-10-29 14:27:23 +00:00
|
|
|
.Name(XO("Max Spike Width"))
|
2017-10-31 18:52:01 +00:00
|
|
|
.Style(wxSL_HORIZONTAL)
|
2017-10-30 16:23:41 +00:00
|
|
|
.Validator<wxGenericValidator>(&mClickWidth)
|
2018-01-31 20:31:22 +00:00
|
|
|
.MinSize( { 150, -1 } )
|
2017-10-30 16:23:41 +00:00
|
|
|
.AddSlider( {}, mClickWidth, MAX_Width, MIN_Width);
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
S.EndMultiColumn();
|
2015-04-17 03:53:42 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
bool EffectClickRemoval::TransferDataToWindow()
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
if (!mUIParent->TransferDataToWindow())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
bool EffectClickRemoval::TransferDataFromWindow()
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectClickRemoval::OnWidthText(wxCommandEvent & WXUNUSED(evt))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
mWidthT->GetValidator()->TransferFromWindow();
|
|
|
|
mWidthS->GetValidator()->TransferToWindow();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectClickRemoval::OnThreshText(wxCommandEvent & WXUNUSED(evt))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
mThreshT->GetValidator()->TransferFromWindow();
|
|
|
|
mThreshS->GetValidator()->TransferToWindow();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectClickRemoval::OnWidthSlider(wxCommandEvent & WXUNUSED(evt))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
mWidthS->GetValidator()->TransferFromWindow();
|
|
|
|
mWidthT->GetValidator()->TransferToWindow();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectClickRemoval::OnThreshSlider(wxCommandEvent & WXUNUSED(evt))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
mThreshS->GetValidator()->TransferFromWindow();
|
|
|
|
mThreshT->GetValidator()->TransferToWindow();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|