2010-01-23 19:44:49 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
ChangeTempo.cpp
|
|
|
|
|
2014-06-03 20:30:19 +00:00
|
|
|
Vaughan Johnson,
|
2010-01-23 19:44:49 +00:00
|
|
|
Dominic Mazzoni
|
|
|
|
|
|
|
|
*******************************************************************//**
|
|
|
|
|
|
|
|
\class EffectChangeTempo
|
2014-06-03 20:30:19 +00:00
|
|
|
\brief An EffectSoundTouch provides speeding up or
|
2010-01-23 19:44:49 +00:00
|
|
|
slowing down tempo without changing pitch.
|
|
|
|
|
|
|
|
*//*******************************************************************/
|
|
|
|
|
2021-05-09 15:16:56 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
#if USE_SOUNDTOUCH
|
2018-11-10 19:47:12 +00:00
|
|
|
#include "ChangeTempo.h"
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2016-08-15 00:27:44 +00:00
|
|
|
#if USE_SBSMS
|
|
|
|
#include <wx/valgen.h>
|
|
|
|
#endif
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include <wx/intl.h>
|
2018-11-11 22:30:55 +00:00
|
|
|
#include <wx/checkbox.h>
|
2018-11-11 21:18:23 +00:00
|
|
|
#include <wx/slider.h>
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2019-02-06 18:44:52 +00:00
|
|
|
#include "../Shuttle.h"
|
2010-01-23 19:44:49 +00:00
|
|
|
#include "../ShuttleGui.h"
|
2015-04-17 03:53:42 +00:00
|
|
|
#include "../widgets/valnum.h"
|
2010-01-23 19:44:49 +00:00
|
|
|
#include "TimeWarper.h"
|
|
|
|
|
2019-01-17 23:31:08 +00:00
|
|
|
#include "LoadEffects.h"
|
|
|
|
|
2018-07-23 18:27:44 +00:00
|
|
|
// Soundtouch defines these as well, which are also in generated configmac.h
|
|
|
|
// and configunix.h, so get rid of them before including,
|
|
|
|
// to avoid compiler warnings, and be sure to do this
|
|
|
|
// after all other #includes, to avoid any mischief that might result
|
|
|
|
// from doing the un-definitions before seeing any wx headers.
|
|
|
|
#undef PACKAGE_NAME
|
|
|
|
#undef PACKAGE_STRING
|
|
|
|
#undef PACKAGE_TARNAME
|
|
|
|
#undef PACKAGE_VERSION
|
|
|
|
#undef PACKAGE_BUGREPORT
|
|
|
|
#undef PACKAGE
|
|
|
|
#undef VERSION
|
|
|
|
#include "SoundTouch.h"
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
ID_PercentChange = 10000,
|
|
|
|
ID_FromBPM,
|
|
|
|
ID_ToBPM,
|
|
|
|
ID_FromLength,
|
|
|
|
ID_ToLength
|
|
|
|
};
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
// Soundtouch is not reasonable below -99% or above 3000%.
|
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-19 03:49:05 +00:00
|
|
|
// Name Type Key Def Min Max Scale
|
2018-03-24 12:13:20 +00:00
|
|
|
Param( Percentage, double, wxT("Percentage"), 0.0, -95.0, 3000.0, 1 );
|
2017-10-03 22:07:04 +00:00
|
|
|
Param( UseSBSMS, bool, wxT("SBSMS"), false, false, true, 1 );
|
2015-04-17 03:53:42 +00:00
|
|
|
|
|
|
|
// We warp the slider to go up to 400%, but user can enter higher values.
|
|
|
|
static const double kSliderMax = 100.0; // warped above zero to actually go up to 400%
|
|
|
|
static const double kSliderWarp = 1.30105; // warp power takes max from 100 to 400.
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// EffectChangeTempo
|
|
|
|
//
|
|
|
|
|
2019-01-17 22:33:49 +00:00
|
|
|
const ComponentInterfaceSymbol EffectChangeTempo::Symbol
|
|
|
|
{ XO("Change Tempo") };
|
|
|
|
|
2019-01-17 23:31:08 +00:00
|
|
|
namespace{ BuiltinEffectsModule::Registration< EffectChangeTempo > reg; }
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
BEGIN_EVENT_TABLE(EffectChangeTempo, wxEvtHandler)
|
|
|
|
EVT_TEXT(ID_PercentChange, EffectChangeTempo::OnText_PercentChange)
|
|
|
|
EVT_SLIDER(ID_PercentChange, EffectChangeTempo::OnSlider_PercentChange)
|
|
|
|
EVT_TEXT(ID_FromBPM, EffectChangeTempo::OnText_FromBPM)
|
|
|
|
EVT_TEXT(ID_ToBPM, EffectChangeTempo::OnText_ToBPM)
|
|
|
|
EVT_TEXT(ID_ToLength, EffectChangeTempo::OnText_ToLength)
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
EffectChangeTempo::EffectChangeTempo()
|
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
m_PercentChange = DEF_Percentage;
|
2013-06-28 03:20:33 +00:00
|
|
|
m_FromBPM = 0.0; // indicates not yet set
|
|
|
|
m_ToBPM = 0.0; // indicates not yet set
|
2013-02-23 04:33:20 +00:00
|
|
|
m_FromLength = 0.0;
|
|
|
|
m_ToLength = 0.0;
|
2015-04-17 03:53:42 +00:00
|
|
|
|
|
|
|
m_bLoopDetect = false;
|
2015-05-15 11:47:51 +00:00
|
|
|
|
2016-08-15 00:27:44 +00:00
|
|
|
#if USE_SBSMS
|
|
|
|
mUseSBSMS = DEF_UseSBSMS;
|
|
|
|
#else
|
|
|
|
mUseSBSMS = false;
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
EffectChangeTempo::~EffectChangeTempo()
|
2013-02-15 00:24:43 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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 EffectChangeTempo::GetSymbol()
|
2015-04-17 03:53:42 +00:00
|
|
|
{
|
2019-01-17 22:33:49 +00:00
|
|
|
return Symbol;
|
2014-06-03 20:30:19 +00:00
|
|
|
}
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2019-12-08 18:53:48 +00:00
|
|
|
TranslatableString EffectChangeTempo::GetDescription()
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2019-12-08 18:53:48 +00:00
|
|
|
return XO("Changes the tempo of a selection without changing its pitch");
|
2015-04-17 03:53:42 +00:00
|
|
|
}
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2021-06-06 16:18:35 +00:00
|
|
|
ManualPageID EffectChangeTempo::ManualPage()
|
2017-05-20 13:40:09 +00:00
|
|
|
{
|
2021-06-06 16:18:35 +00:00
|
|
|
return L"Change_Tempo";
|
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
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
EffectType EffectChangeTempo::GetType()
|
|
|
|
{
|
|
|
|
return EffectTypeProcess;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectChangeTempo::SupportsAutomation()
|
|
|
|
{
|
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
|
|
|
// 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 EffectChangeTempo::DefineParams( ShuttleParams & S ){
|
|
|
|
S.SHUTTLE_PARAM( m_PercentChange, Percentage );
|
|
|
|
S.SHUTTLE_PARAM( mUseSBSMS, UseSBSMS );
|
|
|
|
return true;
|
|
|
|
}
|
2015-04-17 03:53:42 +00:00
|
|
|
|
2018-02-21 14:24:25 +00:00
|
|
|
bool EffectChangeTempo::GetAutomationParameters(CommandParameters & parms)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
parms.Write(KEY_Percentage, m_PercentChange);
|
2016-08-15 00:27:44 +00:00
|
|
|
parms.Write(KEY_UseSBSMS, mUseSBSMS);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-02-21 14:24:25 +00:00
|
|
|
bool EffectChangeTempo::SetAutomationParameters(CommandParameters & parms)
|
2014-06-03 20:30:19 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
ReadAndVerifyDouble(Percentage);
|
|
|
|
m_PercentChange = Percentage;
|
|
|
|
|
2016-08-15 00:27:44 +00:00
|
|
|
#if USE_SBSMS
|
|
|
|
ReadAndVerifyBool(UseSBSMS);
|
|
|
|
mUseSBSMS = UseSBSMS;
|
|
|
|
#else
|
|
|
|
mUseSBSMS = false;
|
|
|
|
#endif
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Effect implementation
|
|
|
|
|
|
|
|
double EffectChangeTempo::CalcPreviewInputLength(double previewLength)
|
|
|
|
{
|
|
|
|
return previewLength * (100.0 + m_PercentChange) / 100.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectChangeTempo::CheckWhetherSkipEffect()
|
|
|
|
{
|
|
|
|
return (m_PercentChange == 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectChangeTempo::Init()
|
|
|
|
{
|
|
|
|
// The selection might have changed since the last time EffectChangeTempo
|
|
|
|
// was invoked, so recalculate the Length parameters.
|
|
|
|
m_FromLength = mT1 - mT0;
|
|
|
|
m_ToLength = (m_FromLength * 100.0) / (100.0 + m_PercentChange);
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectChangeTempo::Process()
|
|
|
|
{
|
2016-08-15 00:27:44 +00:00
|
|
|
bool success = false;
|
|
|
|
|
|
|
|
#if USE_SBSMS
|
|
|
|
if (mUseSBSMS)
|
|
|
|
{
|
|
|
|
double tempoRatio = 1.0 + m_PercentChange / 100.0;
|
|
|
|
EffectSBSMS proxy;
|
2016-08-16 13:54:02 +00:00
|
|
|
proxy.mProxyEffectName = XO("High Quality Tempo Change");
|
2016-08-15 00:27:44 +00:00
|
|
|
proxy.setParameters(tempoRatio, 1.0);
|
2020-04-16 16:33:48 +00:00
|
|
|
success = Delegate(proxy, *mUIParent, nullptr);
|
2016-08-15 00:27:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2020-09-06 08:37:57 +00:00
|
|
|
auto initer = [&](soundtouch::SoundTouch *soundtouch)
|
|
|
|
{
|
|
|
|
soundtouch->setTempoChange(m_PercentChange);
|
|
|
|
};
|
2016-08-15 00:27:44 +00:00
|
|
|
double mT1Dashed = mT0 + (mT1 - mT0)/(m_PercentChange/100.0 + 1.0);
|
2016-12-16 17:37:15 +00:00
|
|
|
RegionTimeWarper warper{ mT0, mT1,
|
|
|
|
std::make_unique<LinearTimeWarper>(mT0, mT0, mT1, mT1Dashed ) };
|
2020-09-18 04:22:00 +00:00
|
|
|
success = EffectSoundTouch::ProcessWithTimeWarper(initer, warper, false);
|
2016-08-15 00:27:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(success)
|
2010-01-23 19:44:49 +00:00
|
|
|
mT1 = mT0 + (mT1 - mT0)/(m_PercentChange/100 + 1.);
|
2016-08-15 00:27:44 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectChangeTempo::PopulateOrExchange(ShuttleGui & S)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2018-01-31 01:03:46 +00:00
|
|
|
enum { precision = 2 };
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
S.StartVerticalLay(0);
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
S.AddSpace(0, 5);
|
2019-12-22 23:14:40 +00:00
|
|
|
S.AddTitle(XO("Change Tempo without Changing Pitch"));
|
2015-04-17 03:53:42 +00:00
|
|
|
S.SetBorder(5);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
//
|
2015-04-17 03:53:42 +00:00
|
|
|
S.StartMultiColumn(2, wxCENTER);
|
|
|
|
{
|
|
|
|
m_pTextCtrl_PercentChange = S.Id(ID_PercentChange)
|
2017-10-30 16:23:41 +00:00
|
|
|
.Validator<FloatingPointValidator<double>>(
|
|
|
|
3, &m_PercentChange, NumValidatorStyle::THREE_TRAILING_ZEROES,
|
|
|
|
MIN_Percentage, MAX_Percentage
|
|
|
|
)
|
2020-05-11 15:28:14 +00:00
|
|
|
.AddTextBox(XXO("Percent C&hange:"), wxT(""), 12);
|
2015-04-17 03:53:42 +00:00
|
|
|
}
|
|
|
|
S.EndMultiColumn();
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
//
|
2015-04-17 03:53:42 +00:00
|
|
|
S.StartHorizontalLay(wxEXPAND);
|
|
|
|
{
|
|
|
|
m_pSlider_PercentChange = S.Id(ID_PercentChange)
|
2017-10-29 14:27:23 +00:00
|
|
|
.Name(XO("Percent Change"))
|
2017-10-31 18:52:01 +00:00
|
|
|
.Style(wxSL_HORIZONTAL)
|
2017-09-28 01:20:14 +00:00
|
|
|
.AddSlider( {}, 0, (int)kSliderMax, (int)MIN_Percentage);
|
2015-04-17 03:53:42 +00:00
|
|
|
}
|
|
|
|
S.EndHorizontalLay();
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2019-12-22 19:58:36 +00:00
|
|
|
S.StartStatic(XO("Beats per minute"));
|
2016-08-15 00:27:44 +00:00
|
|
|
{
|
|
|
|
S.StartHorizontalLay(wxALIGN_CENTER);
|
|
|
|
{
|
|
|
|
m_pTextCtrl_FromBPM = S.Id(ID_FromBPM)
|
2020-05-28 20:23:40 +00:00
|
|
|
/* i18n-hint: changing tempo "from" one value "to" another */
|
2017-10-29 14:27:23 +00:00
|
|
|
.Name(XO("Beats per minute, from"))
|
2017-10-30 16:23:41 +00:00
|
|
|
.Validator<FloatingPointValidator<double>>(
|
|
|
|
3, &m_FromBPM,
|
|
|
|
NumValidatorStyle::THREE_TRAILING_ZEROES
|
|
|
|
| NumValidatorStyle::ZERO_AS_BLANK)
|
2020-05-28 20:23:40 +00:00
|
|
|
/* i18n-hint: changing tempo "from" one value "to" another */
|
|
|
|
.AddTextBox(XXC("&from", "change tempo"), wxT(""), 12);
|
2016-08-15 00:27:44 +00:00
|
|
|
|
|
|
|
m_pTextCtrl_ToBPM = S.Id(ID_ToBPM)
|
2020-05-28 20:23:40 +00:00
|
|
|
/* i18n-hint: changing tempo "from" one value "to" another */
|
2017-10-29 14:27:23 +00:00
|
|
|
.Name(XO("Beats per minute, to"))
|
2017-10-30 16:23:41 +00:00
|
|
|
.Validator<FloatingPointValidator<double>>(
|
|
|
|
3, &m_ToBPM,
|
|
|
|
NumValidatorStyle::THREE_TRAILING_ZEROES
|
|
|
|
| NumValidatorStyle::ZERO_AS_BLANK)
|
2020-05-28 20:23:40 +00:00
|
|
|
/* i18n-hint: changing tempo "from" one value "to" another */
|
|
|
|
.AddTextBox(XXC("&to", "change tempo"), wxT(""), 12);
|
2016-08-15 00:27:44 +00:00
|
|
|
}
|
|
|
|
S.EndHorizontalLay();
|
|
|
|
}
|
|
|
|
S.EndStatic();
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
//
|
2019-12-22 19:58:36 +00:00
|
|
|
S.StartStatic(XO("Length (seconds)"));
|
2015-04-17 03:53:42 +00:00
|
|
|
{
|
2016-08-15 00:27:44 +00:00
|
|
|
S.StartHorizontalLay(wxALIGN_CENTER);
|
|
|
|
{
|
|
|
|
m_pTextCtrl_FromLength = S.Id(ID_FromLength)
|
2019-11-19 16:34:36 +00:00
|
|
|
.Disable() // Disable because the value comes from the
|
|
|
|
// user selection.
|
2017-10-30 16:23:41 +00:00
|
|
|
.Validator<FloatingPointValidator<double>>(
|
|
|
|
precision, &m_FromLength,
|
|
|
|
NumValidatorStyle::TWO_TRAILING_ZEROES)
|
2020-05-28 20:23:40 +00:00
|
|
|
/* i18n-hint: changing tempo "from" one value "to" another */
|
|
|
|
.AddTextBox(XXC("from", "change tempo"), wxT(""), 12);
|
2016-08-15 00:27:44 +00:00
|
|
|
m_pTextCtrl_ToLength = S.Id(ID_ToLength)
|
2017-10-30 16:23:41 +00:00
|
|
|
.Validator<FloatingPointValidator<double>>(
|
|
|
|
2, &m_ToLength, NumValidatorStyle::TWO_TRAILING_ZEROES,
|
|
|
|
// min and max need same precision as what we're validating (bug 963)
|
|
|
|
RoundValue( precision,
|
2020-02-10 10:44:03 +00:00
|
|
|
(m_FromLength * 100.0) / (100.0 + MAX_Percentage) ),
|
2017-10-30 16:23:41 +00:00
|
|
|
RoundValue( precision,
|
2020-02-10 10:44:03 +00:00
|
|
|
(m_FromLength * 100.0) / (100.0 + MIN_Percentage) )
|
2017-10-30 16:23:41 +00:00
|
|
|
)
|
2020-05-28 20:23:40 +00:00
|
|
|
/* i18n-hint: changing tempo "from" one value "to" another */
|
|
|
|
.AddTextBox(XXC("t&o", "change tempo"), wxT(""), 12);
|
2016-08-15 00:27:44 +00:00
|
|
|
}
|
|
|
|
S.EndHorizontalLay();
|
|
|
|
}
|
|
|
|
S.EndStatic();
|
|
|
|
|
|
|
|
#if USE_SBSMS
|
|
|
|
S.StartMultiColumn(2);
|
|
|
|
{
|
2017-10-30 16:23:41 +00:00
|
|
|
mUseSBSMSCheckBox = S.Validator<wxGenericValidator>(&mUseSBSMS)
|
2020-05-11 15:28:14 +00:00
|
|
|
.AddCheckBox(XXO("&Use high quality stretching (slow)"),
|
2018-02-02 02:37:34 +00:00
|
|
|
mUseSBSMS);
|
2015-04-17 03:53:42 +00:00
|
|
|
}
|
|
|
|
S.EndMultiColumn();
|
2016-08-15 00:27:44 +00:00
|
|
|
#endif
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
2015-04-17 03:53:42 +00:00
|
|
|
S.EndVerticalLay();
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
bool EffectChangeTempo::TransferDataToWindow()
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-22 18:03:35 +00:00
|
|
|
// Reset from length because it can be changed by Preview
|
|
|
|
m_FromLength = mT1 - mT0;
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
m_bLoopDetect = true;
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
if (!mUIParent->TransferDataToWindow())
|
|
|
|
{
|
|
|
|
return false;
|
2013-02-23 04:33:20 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
// percent change controls
|
|
|
|
Update_Slider_PercentChange();
|
2015-04-22 18:03:35 +00:00
|
|
|
Update_Text_ToBPM();
|
|
|
|
Update_Text_ToLength();
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
m_bLoopDetect = false;
|
|
|
|
|
2016-08-16 12:57:19 +00:00
|
|
|
// Set the accessibility name here because we need m_pTextCtrl_FromLength to have had its value set
|
2018-01-04 01:47:56 +00:00
|
|
|
m_pTextCtrl_ToLength->SetName(
|
|
|
|
wxString::Format( _("Length in seconds from %s, to"),
|
|
|
|
m_pTextCtrl_FromLength->GetValue() ) );
|
2016-08-16 12:57:19 +00:00
|
|
|
|
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 EffectChangeTempo::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
|
|
|
}
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
// handler implementations for EffectChangeTempo
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectChangeTempo::OnText_PercentChange(wxCommandEvent & WXUNUSED(evt))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
if (m_bLoopDetect)
|
|
|
|
return;
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
m_pTextCtrl_PercentChange->GetValidator()->TransferFromWindow();
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
m_bLoopDetect = true;
|
|
|
|
Update_Slider_PercentChange();
|
|
|
|
Update_Text_ToBPM();
|
|
|
|
Update_Text_ToLength();
|
|
|
|
m_bLoopDetect = false;
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectChangeTempo::OnSlider_PercentChange(wxCommandEvent & WXUNUSED(evt))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
if (m_bLoopDetect)
|
|
|
|
return;
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
m_PercentChange = (double)(m_pSlider_PercentChange->GetValue());
|
|
|
|
// Warp positive values to actually go up faster & further than negatives.
|
|
|
|
if (m_PercentChange > 0.0)
|
|
|
|
m_PercentChange = pow(m_PercentChange, kSliderWarp);
|
|
|
|
|
|
|
|
m_bLoopDetect = true;
|
|
|
|
Update_Text_PercentChange();
|
|
|
|
Update_Text_ToBPM();
|
|
|
|
Update_Text_ToLength();
|
|
|
|
m_bLoopDetect = false;
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectChangeTempo::OnText_FromBPM(wxCommandEvent & WXUNUSED(evt))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
if (m_bLoopDetect)
|
|
|
|
return;
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
m_pTextCtrl_FromBPM->GetValidator()->TransferFromWindow();
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
m_bLoopDetect = true;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
Update_Text_ToBPM();
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
m_bLoopDetect = false;
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectChangeTempo::OnText_ToBPM(wxCommandEvent & WXUNUSED(evt))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
if (m_bLoopDetect)
|
|
|
|
return;
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
m_pTextCtrl_ToBPM->GetValidator()->TransferFromWindow();
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
m_bLoopDetect = true;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2016-02-13 15:43:16 +00:00
|
|
|
// If FromBPM has already been set, then there's a NEW percent change.
|
2015-04-17 03:53:42 +00:00
|
|
|
if (m_FromBPM != 0.0 && m_ToBPM != 0.0)
|
|
|
|
{
|
|
|
|
m_PercentChange = ((m_ToBPM * 100.0) / m_FromBPM) - 100.0;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
Update_Text_PercentChange();
|
|
|
|
Update_Slider_PercentChange();
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
Update_Text_ToLength();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
2015-04-17 03:53:42 +00:00
|
|
|
|
|
|
|
m_bLoopDetect = false;
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectChangeTempo::OnText_ToLength(wxCommandEvent & WXUNUSED(evt))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
if (m_bLoopDetect)
|
|
|
|
return;
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
m_pTextCtrl_ToLength->GetValidator()->TransferFromWindow();
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
if (m_ToLength != 0.0)
|
|
|
|
{
|
2013-02-23 04:33:20 +00:00
|
|
|
m_PercentChange = ((m_FromLength * 100.0) / m_ToLength) - 100.0;
|
2015-04-17 03:53:42 +00:00
|
|
|
}
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
m_bLoopDetect = true;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
Update_Text_PercentChange();
|
|
|
|
Update_Slider_PercentChange();
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
Update_Text_ToBPM();
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
m_bLoopDetect = false;
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// helper fns
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectChangeTempo::Update_Text_PercentChange()
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
m_pTextCtrl_PercentChange->GetValidator()->TransferToWindow();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectChangeTempo::Update_Slider_PercentChange()
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
double unwarped = m_PercentChange;
|
|
|
|
if (unwarped > 0.0)
|
|
|
|
// Un-warp values above zero to actually go up to kSliderMax.
|
|
|
|
unwarped = pow(m_PercentChange, (1.0 / kSliderWarp));
|
|
|
|
|
|
|
|
// Add 0.5 to unwarped so trunc -> round.
|
|
|
|
m_pSlider_PercentChange->SetValue((int)(unwarped + 0.5));
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectChangeTempo::Update_Text_ToBPM()
|
2016-02-13 15:43:16 +00:00
|
|
|
// Use m_FromBPM & m_PercentChange to set NEW m_ToBPM & control.
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2013-06-28 03:20:33 +00:00
|
|
|
m_ToBPM = (((m_FromBPM * (100.0 + m_PercentChange)) / 100.0));
|
2015-04-17 03:53:42 +00:00
|
|
|
m_pTextCtrl_ToBPM->GetValidator()->TransferToWindow();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectChangeTempo::Update_Text_ToLength()
|
2016-02-13 15:43:16 +00:00
|
|
|
// Use m_FromLength & m_PercentChange to set NEW m_ToLength & control.
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2013-02-23 04:33:20 +00:00
|
|
|
m_ToLength = (m_FromLength * 100.0) / (100.0 + m_PercentChange);
|
2015-04-17 03:53:42 +00:00
|
|
|
m_pTextCtrl_ToLength->GetValidator()->TransferToWindow();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2017-10-19 17:08:04 +00:00
|
|
|
#endif // USE_SOUNDTOUCH
|