2010-01-23 19:44:49 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
TimeScale.cpp
|
|
|
|
|
|
|
|
Clayton Otey
|
|
|
|
|
|
|
|
*******************************************************************//**
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
\class EffectTimeScale
|
|
|
|
\brief An EffectTimeScale does high quality sliding time scaling/pitch shifting
|
|
|
|
|
|
|
|
*//*******************************************************************/
|
|
|
|
|
|
|
|
#include "../Audacity.h" // for USE_SBSMS
|
|
|
|
|
|
|
|
#if USE_SBSMS
|
2015-06-18 14:24:36 +00:00
|
|
|
#include "TimeScale.h"
|
2019-01-17 23:31:08 +00:00
|
|
|
#include "LoadEffects.h"
|
2015-06-18 14:24:36 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
#include <math.h>
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
#include <wx/intl.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"
|
2015-06-18 14:24:36 +00:00
|
|
|
#include "../ShuttleGui.h"
|
2015-04-17 03:53:42 +00:00
|
|
|
#include "../widgets/valnum.h"
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
ID_RatePercentChangeStart = 10000,
|
|
|
|
ID_RatePercentChangeEnd,
|
|
|
|
ID_PitchHalfStepsStart,
|
|
|
|
ID_PitchHalfStepsEnd,
|
|
|
|
ID_PitchPercentChangeStart,
|
|
|
|
ID_PitchPercentChangeEnd
|
|
|
|
};
|
|
|
|
|
|
|
|
// 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( RatePercentStart, double, wxT("RatePercentChangeStart"), 0.0, -90.0, 500, 1 );
|
|
|
|
Param( RatePercentEnd, double, wxT("RatePercentChangeEnd"), 0.0, -90.0, 500, 1 );
|
|
|
|
Param( HalfStepsStart, double, wxT("PitchHalfStepsStart"), 0.0, -12.0, 12.0, 1 );
|
|
|
|
Param( HalfStepsEnd, double, wxT("PitchHalfStepsEnd"), 0.0, -12.0, 12.0, 1 );
|
|
|
|
Param( PitchPercentStart, double, wxT("PitchPercentChangeStart"), 0.0, -50.0, 100.0, 1 );
|
|
|
|
Param( PitchPercentEnd, double, wxT("PitchPercentChangeEnd"), 0.0, -50.0, 100.0, 1 );
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// EffectTimeScale
|
|
|
|
//
|
|
|
|
|
2019-01-17 22:33:49 +00:00
|
|
|
const ComponentInterfaceSymbol EffectTimeScale::Symbol
|
|
|
|
{ wxT("Sliding Stretch"), XO("Sliding Stretch") };
|
|
|
|
|
2019-01-17 23:31:08 +00:00
|
|
|
namespace{ BuiltinEffectsModule::Registration< EffectTimeScale > reg; }
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
BEGIN_EVENT_TABLE(EffectTimeScale, wxEvtHandler)
|
|
|
|
EVT_TEXT(ID_RatePercentChangeStart, EffectTimeScale::OnText_RatePercentChangeStart)
|
|
|
|
EVT_TEXT(ID_RatePercentChangeEnd, EffectTimeScale::OnText_RatePercentChangeEnd)
|
|
|
|
EVT_TEXT(ID_PitchHalfStepsStart, EffectTimeScale::OnText_PitchHalfStepsStart)
|
|
|
|
EVT_TEXT(ID_PitchHalfStepsEnd, EffectTimeScale::OnText_PitchHalfStepsEnd)
|
|
|
|
EVT_TEXT(ID_PitchPercentChangeStart, EffectTimeScale::OnText_PitchPercentChangeStart)
|
|
|
|
EVT_TEXT(ID_PitchPercentChangeEnd, EffectTimeScale::OnText_PitchPercentChangeEnd)
|
|
|
|
EVT_SLIDER(ID_RatePercentChangeStart, EffectTimeScale::OnSlider_RatePercentChangeStart)
|
|
|
|
EVT_SLIDER(ID_RatePercentChangeEnd, EffectTimeScale::OnSlider_RatePercentChangeEnd)
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2011-07-06 09:49:59 +00:00
|
|
|
EffectTimeScale::EffectTimeScale()
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
m_RatePercentChangeStart = DEF_RatePercentStart;
|
|
|
|
m_RatePercentChangeEnd = DEF_RatePercentEnd;
|
|
|
|
m_PitchHalfStepsStart = DEF_HalfStepsStart;
|
|
|
|
m_PitchHalfStepsEnd = DEF_HalfStepsEnd;
|
|
|
|
m_PitchPercentChangeStart = DEF_PitchPercentStart;
|
|
|
|
m_PitchPercentChangeEnd = DEF_PitchPercentEnd;
|
2015-05-15 11:47:51 +00:00
|
|
|
|
2016-01-26 18:19:19 +00:00
|
|
|
slideTypeRate = SlideLinearOutputRate;
|
|
|
|
slideTypePitch = SlideLinearOutputRate;
|
|
|
|
bPreview = false;
|
|
|
|
previewSelectedDuration = 0.0;
|
|
|
|
|
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
|
|
|
EffectTimeScale::~EffectTimeScale()
|
|
|
|
{
|
2014-06-03 20:30:19 +00:00
|
|
|
}
|
2010-01-23 19:44:49 +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 EffectTimeScale::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 EffectTimeScale::GetDescription()
|
2015-04-17 03:53:42 +00:00
|
|
|
{
|
2019-12-08 18:53:48 +00:00
|
|
|
return XO("Allows continuous changes to the tempo and/or pitch");
|
2015-04-17 03:53:42 +00:00
|
|
|
}
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2017-05-20 13:40:09 +00:00
|
|
|
wxString EffectTimeScale::ManualPage()
|
|
|
|
{
|
2018-04-28 20:16:41 +00:00
|
|
|
return wxT("Sliding_Stretch");
|
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
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
EffectType EffectTimeScale::GetType()
|
|
|
|
{
|
|
|
|
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 EffectTimeScale::DefineParams( ShuttleParams & S ){
|
|
|
|
S.SHUTTLE_PARAM( m_RatePercentChangeStart, RatePercentStart );
|
|
|
|
S.SHUTTLE_PARAM( m_RatePercentChangeEnd, RatePercentEnd );
|
|
|
|
S.SHUTTLE_PARAM( m_PitchHalfStepsStart, HalfStepsStart );
|
|
|
|
S.SHUTTLE_PARAM( m_PitchHalfStepsEnd, HalfStepsEnd );
|
|
|
|
S.SHUTTLE_PARAM( m_PitchPercentChangeStart, PitchPercentStart );
|
|
|
|
S.SHUTTLE_PARAM( m_PitchPercentChangeEnd, PitchPercentEnd );
|
|
|
|
return true;
|
|
|
|
}
|
2015-04-17 03:53:42 +00:00
|
|
|
|
2018-02-21 14:24:25 +00:00
|
|
|
bool EffectTimeScale::GetAutomationParameters(CommandParameters & parms)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
parms.Write(KEY_RatePercentStart, m_RatePercentChangeStart);
|
|
|
|
parms.Write(KEY_RatePercentEnd, m_RatePercentChangeEnd);
|
|
|
|
parms.Write(KEY_HalfStepsStart, m_PitchHalfStepsStart);
|
|
|
|
parms.Write(KEY_HalfStepsEnd, m_PitchHalfStepsEnd);
|
|
|
|
parms.Write(KEY_PitchPercentStart, m_PitchPercentChangeStart);
|
|
|
|
parms.Write(KEY_PitchPercentEnd, m_PitchPercentChangeEnd);
|
|
|
|
|
2011-07-02 18:35:18 +00:00
|
|
|
return true;
|
2010-06-07 06:41:32 +00:00
|
|
|
}
|
|
|
|
|
2018-02-21 14:24:25 +00:00
|
|
|
bool EffectTimeScale::SetAutomationParameters(CommandParameters & parms)
|
2011-01-29 22:32:39 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
ReadAndVerifyDouble(RatePercentStart);
|
|
|
|
ReadAndVerifyDouble(RatePercentEnd);
|
|
|
|
ReadAndVerifyDouble(HalfStepsStart);
|
|
|
|
ReadAndVerifyDouble(HalfStepsEnd);
|
|
|
|
ReadAndVerifyDouble(PitchPercentStart);
|
|
|
|
ReadAndVerifyDouble(PitchPercentEnd);
|
|
|
|
|
|
|
|
m_RatePercentChangeStart = RatePercentStart;
|
|
|
|
m_RatePercentChangeEnd = RatePercentEnd;
|
|
|
|
m_PitchHalfStepsStart = HalfStepsStart;
|
|
|
|
m_PitchHalfStepsEnd = HalfStepsEnd;
|
|
|
|
m_PitchPercentChangeStart = PitchPercentStart;
|
|
|
|
m_PitchPercentChangeEnd = PitchPercentEnd;
|
|
|
|
|
|
|
|
return true;
|
2011-01-29 22:32:39 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
// Effect implementation
|
2010-06-07 06:41:32 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
bool EffectTimeScale::Init()
|
2010-06-07 06:41:32 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
return true;
|
2010-06-07 06:41:32 +00:00
|
|
|
}
|
|
|
|
|
2016-01-26 18:19:19 +00:00
|
|
|
double EffectTimeScale::CalcPreviewInputLength(double previewLength)
|
|
|
|
{
|
|
|
|
double inputLength = Effect::GetDuration();
|
|
|
|
if(inputLength == 0.0) {
|
|
|
|
return 0.0;
|
|
|
|
} else {
|
2018-10-10 18:44:31 +00:00
|
|
|
double rateStart1 = PercentChangeToRatio(m_RatePercentChangeStart);
|
|
|
|
double rateEnd1 = PercentChangeToRatio(m_RatePercentChangeEnd);
|
2016-01-26 18:19:19 +00:00
|
|
|
double tOut = previewLength/inputLength;
|
2018-10-10 18:44:31 +00:00
|
|
|
double t = EffectSBSMS::getInvertedStretchedTime(rateStart1,rateEnd1,slideTypeRate,tOut);
|
2016-01-26 18:19:19 +00:00
|
|
|
return t * inputLength;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectTimeScale::Preview(bool dryOnly)
|
|
|
|
{
|
|
|
|
previewSelectedDuration = Effect::GetDuration();
|
2016-12-15 12:30:14 +00:00
|
|
|
auto cleanup = valueRestorer( bPreview, true );
|
2016-01-26 18:19:19 +00:00
|
|
|
Effect::Preview(dryOnly);
|
|
|
|
}
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
bool EffectTimeScale::Process()
|
|
|
|
{
|
2018-10-10 18:44:31 +00:00
|
|
|
double pitchStart1 = PercentChangeToRatio(m_PitchPercentChangeStart);
|
|
|
|
double pitchEnd1 = PercentChangeToRatio(m_PitchPercentChangeEnd);
|
|
|
|
double rateStart1 = PercentChangeToRatio(m_RatePercentChangeStart);
|
|
|
|
double rateEnd1 = PercentChangeToRatio(m_RatePercentChangeEnd);
|
2016-01-26 18:19:19 +00:00
|
|
|
|
|
|
|
if(bPreview) {
|
|
|
|
double t = (mT1-mT0) / previewSelectedDuration;
|
2018-10-10 18:44:31 +00:00
|
|
|
rateEnd1 = EffectSBSMS::getRate(rateStart1,rateEnd1,slideTypeRate,t);
|
|
|
|
pitchEnd1 = EffectSBSMS::getRate(pitchStart1,pitchEnd1,slideTypePitch,t);
|
2016-01-26 18:19:19 +00:00
|
|
|
}
|
|
|
|
|
2018-10-10 18:44:31 +00:00
|
|
|
EffectSBSMS::setParameters(rateStart1,rateEnd1,pitchStart1,pitchEnd1,slideTypeRate,slideTypePitch,false,false,false);
|
2015-04-17 03:53:42 +00:00
|
|
|
return EffectSBSMS::Process();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectTimeScale::PopulateOrExchange(ShuttleGui & S)
|
2011-07-02 18:35:18 +00:00
|
|
|
{
|
2010-01-23 19:44:49 +00:00
|
|
|
S.SetBorder(5);
|
2013-06-21 22:10:50 +00:00
|
|
|
S.AddSpace(0, 5);
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
S.StartMultiColumn(2, wxALIGN_CENTER);
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
// Rate Start
|
2019-12-22 19:58:36 +00:00
|
|
|
S.StartStatic(XO("Initial Tempo Change (%)"));
|
2010-06-07 06:41:32 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
S.StartMultiColumn(1, wxCENTER);
|
|
|
|
{
|
|
|
|
m_pTextCtrl_RatePercentChangeStart = S.Id(ID_RatePercentChangeStart)
|
2017-10-30 16:23:41 +00:00
|
|
|
.Validator<FloatingPointValidator<double>>(
|
|
|
|
3, &m_RatePercentChangeStart,
|
|
|
|
NumValidatorStyle::NO_TRAILING_ZEROES,
|
|
|
|
MIN_RatePercentStart, MAX_RatePercentStart
|
|
|
|
)
|
2017-09-28 01:20:14 +00:00
|
|
|
.AddTextBox( {}, wxT(""), 12);
|
2015-04-17 03:53:42 +00:00
|
|
|
}
|
|
|
|
S.EndMultiColumn();
|
|
|
|
S.StartHorizontalLay(wxEXPAND, 0);
|
|
|
|
{
|
|
|
|
m_pSlider_RatePercentChangeStart = S.Id(ID_RatePercentChangeStart)
|
2017-10-31 18:52:01 +00:00
|
|
|
.Style(wxSL_HORIZONTAL)
|
2017-09-28 01:20:14 +00:00
|
|
|
.AddSlider( {}, DEF_RatePercentStart, MAX_RatePercentStart, MIN_RatePercentStart);
|
2015-04-17 03:53:42 +00:00
|
|
|
}
|
|
|
|
S.EndHorizontalLay();
|
2010-06-07 06:41:32 +00:00
|
|
|
}
|
2015-04-17 03:53:42 +00:00
|
|
|
S.EndStatic();
|
2010-06-07 06:41:32 +00:00
|
|
|
|
2019-12-22 19:58:36 +00:00
|
|
|
S.StartStatic(XO("Final Tempo Change (%)"));
|
2014-06-03 20:30:19 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
S.StartMultiColumn(1, wxCENTER);
|
|
|
|
{
|
|
|
|
m_pTextCtrl_RatePercentChangeEnd = S.Id(ID_RatePercentChangeEnd)
|
2017-10-30 16:23:41 +00:00
|
|
|
.Validator<FloatingPointValidator<double>>(
|
|
|
|
3, &m_RatePercentChangeEnd,
|
|
|
|
NumValidatorStyle::NO_TRAILING_ZEROES,
|
|
|
|
MIN_RatePercentEnd, MAX_RatePercentEnd
|
|
|
|
)
|
2017-09-28 01:20:14 +00:00
|
|
|
.AddTextBox( {}, wxT(""), 12);
|
2015-04-17 03:53:42 +00:00
|
|
|
}
|
|
|
|
S.EndMultiColumn();
|
|
|
|
S.StartHorizontalLay(wxEXPAND, 0);
|
|
|
|
{
|
|
|
|
m_pSlider_RatePercentChangeEnd = S.Id(ID_RatePercentChangeEnd)
|
2017-10-31 18:52:01 +00:00
|
|
|
.Style(wxSL_HORIZONTAL)
|
2017-09-28 01:20:14 +00:00
|
|
|
.AddSlider( {}, DEF_RatePercentEnd, MAX_RatePercentEnd, MIN_RatePercentEnd);
|
2015-04-17 03:53:42 +00:00
|
|
|
}
|
|
|
|
S.EndHorizontalLay();
|
2010-06-07 06:41:32 +00:00
|
|
|
}
|
2015-04-17 03:53:42 +00:00
|
|
|
S.EndStatic();
|
2010-06-07 06:41:32 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
// Pitch Start
|
2019-12-22 19:58:36 +00:00
|
|
|
S.StartStatic(XO("Initial Pitch Shift"));
|
2010-06-07 06:41:32 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
S.StartMultiColumn(2, wxCENTER);
|
|
|
|
{
|
|
|
|
m_pTextCtrl_PitchHalfStepsStart = S.Id(ID_PitchHalfStepsStart)
|
2017-10-30 16:23:41 +00:00
|
|
|
.Validator<FloatingPointValidator<double>>(
|
|
|
|
3, &m_PitchHalfStepsStart,
|
|
|
|
NumValidatorStyle::NO_TRAILING_ZEROES,
|
|
|
|
MIN_HalfStepsStart, MAX_HalfStepsStart
|
|
|
|
)
|
2020-03-27 10:41:30 +00:00
|
|
|
.AddTextBox(XO("(&semitones) [-12 to 12]:"), wxT(""), 12);
|
2015-04-17 03:53:42 +00:00
|
|
|
|
2017-10-30 16:23:41 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
m_pTextCtrl_PitchPercentChangeStart = S.Id(ID_PitchPercentChangeStart)
|
2017-10-30 16:23:41 +00:00
|
|
|
.Validator<FloatingPointValidator<double>>(
|
|
|
|
3, &m_PitchPercentChangeStart,
|
|
|
|
NumValidatorStyle::NO_TRAILING_ZEROES,
|
|
|
|
MIN_PitchPercentStart, MAX_PitchPercentStart
|
|
|
|
)
|
2019-12-22 21:26:56 +00:00
|
|
|
.AddTextBox(XO("(%) [-50 to 100]:"), wxT(""), 12);
|
2015-04-17 03:53:42 +00:00
|
|
|
}
|
|
|
|
S.EndMultiColumn();
|
2010-06-07 06:41:32 +00:00
|
|
|
}
|
2015-04-17 03:53:42 +00:00
|
|
|
S.EndStatic();
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
// Pitch End
|
2019-12-22 19:58:36 +00:00
|
|
|
S.StartStatic(XO("Final Pitch Shift"));
|
2010-06-07 06:41:32 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
S.StartMultiColumn(2, wxCENTER);
|
|
|
|
{
|
|
|
|
m_pTextCtrl_PitchHalfStepsEnd = S.Id(ID_PitchHalfStepsEnd)
|
2017-10-30 16:23:41 +00:00
|
|
|
.Validator<FloatingPointValidator<double>>(
|
|
|
|
3, &m_PitchHalfStepsEnd,
|
|
|
|
NumValidatorStyle::NO_TRAILING_ZEROES,
|
|
|
|
MIN_HalfStepsEnd, MAX_HalfStepsEnd
|
|
|
|
)
|
2020-03-27 10:41:30 +00:00
|
|
|
.AddTextBox(XO("(s&emitones) [-12 to 12]:"), wxT(""), 12);
|
2015-04-17 03:53:42 +00:00
|
|
|
|
|
|
|
m_pTextCtrl_PitchPercentChangeEnd = S.Id(ID_PitchPercentChangeEnd)
|
2017-10-30 16:23:41 +00:00
|
|
|
.Validator<FloatingPointValidator<double>>(
|
|
|
|
3, &m_PitchPercentChangeEnd,
|
|
|
|
NumValidatorStyle::NO_TRAILING_ZEROES,
|
|
|
|
MIN_PitchPercentStart, MAX_PitchPercentStart)
|
2019-12-22 21:26:56 +00:00
|
|
|
.AddTextBox(XO("(%) [-50 to 100]:"), wxT(""), 12);
|
2015-04-17 03:53:42 +00:00
|
|
|
}
|
|
|
|
S.EndMultiColumn();
|
2010-06-07 06:41:32 +00:00
|
|
|
}
|
2015-04-17 03:53:42 +00:00
|
|
|
S.EndStatic();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
2011-07-06 09:49:59 +00:00
|
|
|
S.EndMultiColumn();
|
2013-02-23 04:33:20 +00:00
|
|
|
|
|
|
|
return;
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
bool EffectTimeScale::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
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
Update_Slider_RatePercentChangeStart();
|
|
|
|
Update_Slider_RatePercentChangeEnd();
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
bool EffectTimeScale::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
|
|
|
inline double EffectTimeScale::PercentChangeToRatio(double percentChange)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
return 1.0 + percentChange / 100.0;
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
inline double EffectTimeScale::HalfStepsToPercentChange(double halfSteps)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
return 100.0 * (pow(2.0,halfSteps/12.0) - 1.0);
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
inline double EffectTimeScale::PercentChangeToHalfSteps(double percentChange)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
return 12.0 * log2(PercentChangeToRatio(percentChange));
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectTimeScale::Update_Text_RatePercentChangeStart()
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
m_pTextCtrl_RatePercentChangeStart->GetValidator()->TransferToWindow();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectTimeScale::Update_Text_RatePercentChangeEnd()
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
m_pTextCtrl_RatePercentChangeEnd->GetValidator()->TransferToWindow();
|
2010-06-07 06:41:32 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectTimeScale::Update_Slider_RatePercentChangeStart()
|
2010-06-07 06:41:32 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
m_pSlider_RatePercentChangeStart->SetValue((int)(m_RatePercentChangeStart + 0.5));
|
2010-06-07 06:41:32 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectTimeScale::Update_Slider_RatePercentChangeEnd()
|
2010-06-07 06:41:32 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
m_pSlider_RatePercentChangeEnd->SetValue((int)(m_RatePercentChangeEnd + 0.5));
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectTimeScale::Update_Text_PitchHalfStepsStart()
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
m_pTextCtrl_PitchHalfStepsStart->GetValidator()->TransferToWindow();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectTimeScale::Update_Text_PitchHalfStepsEnd()
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
m_pTextCtrl_PitchHalfStepsEnd->GetValidator()->TransferToWindow();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectTimeScale::Update_Text_PitchPercentChangeStart()
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
m_pTextCtrl_PitchPercentChangeStart->GetValidator()->TransferToWindow();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectTimeScale::Update_Text_PitchPercentChangeEnd()
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
m_pTextCtrl_PitchPercentChangeEnd->GetValidator()->TransferToWindow();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectTimeScale::OnText_RatePercentChangeStart(wxCommandEvent & WXUNUSED(evt))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
if (!EnableApply(mUIParent->TransferDataFromWindow()))
|
|
|
|
{
|
|
|
|
return;
|
2010-06-07 06:41:32 +00:00
|
|
|
}
|
2015-04-17 03:53:42 +00:00
|
|
|
|
|
|
|
Update_Slider_RatePercentChangeStart();
|
2010-06-07 06:41:32 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectTimeScale::OnText_RatePercentChangeEnd(wxCommandEvent & WXUNUSED(evt))
|
2010-06-07 06:41:32 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
if (!EnableApply(mUIParent->TransferDataFromWindow()))
|
|
|
|
{
|
|
|
|
return;
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
2015-04-17 03:53:42 +00:00
|
|
|
|
|
|
|
Update_Slider_RatePercentChangeEnd();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectTimeScale::OnSlider_RatePercentChangeStart(wxCommandEvent & evt)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
m_RatePercentChangeStart = (double) evt.GetInt();
|
|
|
|
|
|
|
|
Update_Text_RatePercentChangeStart();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectTimeScale::OnSlider_RatePercentChangeEnd(wxCommandEvent & evt)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
m_RatePercentChangeEnd = (double) evt.GetInt();
|
|
|
|
|
|
|
|
Update_Text_RatePercentChangeEnd();
|
2010-06-07 06:41:32 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectTimeScale::OnText_PitchHalfStepsStart(wxCommandEvent & WXUNUSED(evt))
|
2010-06-07 06:41:32 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
if (!EnableApply(mUIParent->TransferDataFromWindow()))
|
|
|
|
{
|
|
|
|
return;
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
2015-04-17 03:53:42 +00:00
|
|
|
|
|
|
|
m_PitchPercentChangeStart = HalfStepsToPercentChange(m_PitchHalfStepsStart);
|
|
|
|
Update_Text_PitchPercentChangeStart();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectTimeScale::OnText_PitchHalfStepsEnd(wxCommandEvent & WXUNUSED(evt))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
if (!EnableApply(mUIParent->TransferDataFromWindow()))
|
|
|
|
{
|
|
|
|
return;
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
2015-04-17 03:53:42 +00:00
|
|
|
|
|
|
|
m_PitchPercentChangeEnd = HalfStepsToPercentChange(m_PitchHalfStepsEnd);
|
|
|
|
Update_Text_PitchPercentChangeEnd();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectTimeScale::OnText_PitchPercentChangeStart(wxCommandEvent & WXUNUSED(evt))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
if (!EnableApply(mUIParent->TransferDataFromWindow()))
|
|
|
|
{
|
|
|
|
return;
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
2015-04-17 03:53:42 +00:00
|
|
|
|
|
|
|
m_PitchHalfStepsStart = PercentChangeToHalfSteps(m_PitchPercentChangeStart);
|
|
|
|
Update_Text_PitchHalfStepsStart();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void EffectTimeScale::OnText_PitchPercentChangeEnd(wxCommandEvent & WXUNUSED(evt))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-04-17 03:53:42 +00:00
|
|
|
if (!EnableApply(mUIParent->TransferDataFromWindow()))
|
|
|
|
{
|
|
|
|
return;
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
2015-04-17 03:53:42 +00:00
|
|
|
|
|
|
|
m_PitchHalfStepsEnd = PercentChangeToHalfSteps(m_PitchPercentChangeEnd);
|
|
|
|
Update_Text_PitchHalfStepsEnd();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|