Use a common method for the duration format in generators
This commit is contained in:
parent
c372519e52
commit
0d62be7776
|
@ -94,7 +94,8 @@ public:
|
|||
virtual ~EffectHostInterface() {};
|
||||
|
||||
virtual double GetDefaultDuration() = 0;
|
||||
virtual double GetDuration(bool *isSelection = NULL) = 0;
|
||||
virtual double GetDuration() = 0;
|
||||
virtual wxString GetDurationFormat() = 0;
|
||||
virtual void SetDuration(double seconds) = 0;
|
||||
|
||||
virtual bool Apply() = 0;
|
||||
|
|
|
@ -303,16 +303,13 @@ void EffectDtmf::PopulateOrExchange(ShuttleGui & S)
|
|||
vldAmp.SetRange(MIN_Amplitude, MAX_Amplitude);
|
||||
S.Id(ID_Amplitude).AddTextBox(_("Amplitude (0-1):"), wxT(""), 10)->SetValidator(vldAmp);
|
||||
|
||||
bool isSelection;
|
||||
double duration = GetDuration(&isSelection);
|
||||
|
||||
S.AddPrompt(_("Duration:"));
|
||||
mDtmfDurationT = new
|
||||
NumericTextCtrl(NumericConverter::TIME,
|
||||
S.GetParent(),
|
||||
ID_Duration,
|
||||
isSelection ? _("hh:mm:ss + samples") : _("hh:mm:ss + milliseconds"),
|
||||
duration,
|
||||
GetDurationFormat(),
|
||||
GetDuration(),
|
||||
mProjectRate,
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
|
@ -370,8 +367,8 @@ bool EffectDtmf::TransferDataFromWindow()
|
|||
return false;
|
||||
}
|
||||
|
||||
// dtmfDutyCycle = (double) mDtmfDutyCycleS->GetValue() / SCL_DutyCycle;
|
||||
// SetDuration(mDtmfDurationT->GetValue());
|
||||
dtmfDutyCycle = (double) mDtmfDutyCycleS->GetValue() / SCL_DutyCycle;
|
||||
SetDuration(mDtmfDurationT->GetValue());
|
||||
|
||||
// recalculate to make sure all values are up-to-date. This is especially
|
||||
// important if the user did not change any values in the dialog
|
||||
|
|
|
@ -705,49 +705,21 @@ double Effect::GetDefaultDuration()
|
|||
return 30.0;
|
||||
}
|
||||
|
||||
double Effect::GetDuration(bool *isSelection)
|
||||
double Effect::GetDuration()
|
||||
{
|
||||
if (mT1 > mT0)
|
||||
{
|
||||
// there is a selection: let's fit in there...
|
||||
// MJS: note that this is just for the TTC and is independent of the track rate
|
||||
// but we do need to make sure we have the right number of samples at the project rate
|
||||
double quantMT0 = QUANTIZED_TIME(mT0, mProjectRate);
|
||||
double quantMT1 = QUANTIZED_TIME(mT1, mProjectRate);
|
||||
mDuration = quantMT1 - quantMT0;
|
||||
|
||||
if (isSelection)
|
||||
{
|
||||
*isSelection = true;
|
||||
}
|
||||
|
||||
return mDuration;
|
||||
}
|
||||
|
||||
if (isSelection)
|
||||
{
|
||||
*isSelection = false;
|
||||
}
|
||||
|
||||
GetPrivateConfig(GetCurrentSettingsGroup(), wxT("LastUsedDuration"), mDuration, 0.0);
|
||||
if (mDuration > 0.0)
|
||||
{
|
||||
return mDuration;
|
||||
}
|
||||
|
||||
if (mDuration < 0.0)
|
||||
{
|
||||
mDuration = 0.0;
|
||||
}
|
||||
|
||||
if (GetType() == EffectTypeGenerate)
|
||||
{
|
||||
mDuration = GetDefaultDuration();
|
||||
}
|
||||
|
||||
return mDuration;
|
||||
}
|
||||
|
||||
wxString Effect::GetDurationFormat()
|
||||
{
|
||||
return mDurationFormat;
|
||||
}
|
||||
|
||||
void Effect::SetDuration(double seconds)
|
||||
{
|
||||
if (seconds < 0.0)
|
||||
|
@ -755,14 +727,17 @@ void Effect::SetDuration(double seconds)
|
|||
seconds = 0.0;
|
||||
}
|
||||
|
||||
if (mDuration != seconds)
|
||||
if (GetType() == EffectTypeGenerate)
|
||||
{
|
||||
SetPrivateConfig(GetCurrentSettingsGroup(), wxT("LastUsedDuration"), seconds);
|
||||
}
|
||||
|
||||
mDuration = seconds;
|
||||
mT1 = mT0 + mDuration;
|
||||
mSetDuration = mDuration;
|
||||
|
||||
mIsSelection = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1170,9 +1145,33 @@ bool Effect::DoEffect(wxWindow *parent,
|
|||
mProjectRate = projectRate;
|
||||
mParent = parent;
|
||||
mTracks = list;
|
||||
|
||||
bool isSelection = false;
|
||||
|
||||
mDuration = 0.0;
|
||||
|
||||
if (GetType() == EffectTypeGenerate)
|
||||
{
|
||||
GetPrivateConfig(GetCurrentSettingsGroup(), wxT("LastUsedDuration"), mDuration, GetDefaultDuration());
|
||||
}
|
||||
|
||||
mT0 = selectedRegion->t0();
|
||||
mT1 = selectedRegion->t1();
|
||||
mDuration = GetDuration();
|
||||
if (mT1 > mT0)
|
||||
{
|
||||
// there is a selection: let's fit in there...
|
||||
// MJS: note that this is just for the TTC and is independent of the track rate
|
||||
// but we do need to make sure we have the right number of samples at the project rate
|
||||
double quantMT0 = QUANTIZED_TIME(mT0, mProjectRate);
|
||||
double quantMT1 = QUANTIZED_TIME(mT1, mProjectRate);
|
||||
mDuration = quantMT1 - quantMT0;
|
||||
mT1 = mT0 + mDuration;
|
||||
|
||||
isSelection = true;
|
||||
}
|
||||
|
||||
mDurationFormat = isSelection ? _("hh:mm:ss + samples") : _("hh:mm:ss + milliseconds");
|
||||
|
||||
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|
||||
mF0 = selectedRegion->f0();
|
||||
mF1 = selectedRegion->f1();
|
||||
|
|
|
@ -144,7 +144,8 @@ class AUDACITY_DLL_API Effect : public wxEvtHandler,
|
|||
// EffectHostInterface implementation
|
||||
|
||||
virtual double GetDefaultDuration();
|
||||
virtual double GetDuration(bool *isSelection = NULL);
|
||||
virtual double GetDuration();
|
||||
virtual wxString GetDurationFormat();
|
||||
virtual void SetDuration(double duration);
|
||||
|
||||
virtual bool Apply();
|
||||
|
@ -400,7 +401,9 @@ private:
|
|||
bool mIsLinearEffect;
|
||||
bool mPreviewWithNotSelected;
|
||||
|
||||
bool mIsSelection;
|
||||
double mDuration;
|
||||
wxString mDurationFormat;
|
||||
// mSetDuration should ONLY be set when SetDuration() is called.
|
||||
double mSetDuration;
|
||||
|
||||
|
|
|
@ -224,20 +224,17 @@ void EffectNoise::PopulateOrExchange(ShuttleGui & S)
|
|||
vldAmp.SetRange(MIN_Amp, MAX_Amp);
|
||||
S.AddTextBox(_("Amplitude (0-1):"), wxT(""), 12)->SetValidator(vldAmp);
|
||||
|
||||
bool isSelection;
|
||||
double duration = GetDuration(&isSelection);
|
||||
|
||||
S.AddPrompt(_("Duration:"));
|
||||
mNoiseDurationT = new
|
||||
NumericTextCtrl(NumericConverter::TIME,
|
||||
S.GetParent(),
|
||||
wxID_ANY,
|
||||
isSelection ? _("hh:mm:ss + samples") : _("hh:mm:ss + milliseconds"),
|
||||
duration,
|
||||
mProjectRate,
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
true);
|
||||
S.GetParent(),
|
||||
wxID_ANY,
|
||||
GetDurationFormat(),
|
||||
GetDuration(),
|
||||
mProjectRate,
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
true);
|
||||
mNoiseDurationT->SetName(_("Duration"));
|
||||
mNoiseDurationT->EnableMenu();
|
||||
S.AddWindow(mNoiseDurationT, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL);
|
||||
|
|
|
@ -55,16 +55,13 @@ void EffectSilence::PopulateOrExchange(ShuttleGui & S)
|
|||
{
|
||||
S.StartHorizontalLay();
|
||||
{
|
||||
bool isSelection;
|
||||
double duration = GetDuration(&isSelection);
|
||||
|
||||
S.AddPrompt(_("Duration:"));
|
||||
mDurationT = new
|
||||
NumericTextCtrl(NumericConverter::TIME,
|
||||
S.GetParent(),
|
||||
wxID_ANY,
|
||||
isSelection ? _("hh:mm:ss + samples") : _("hh:mm:ss + milliseconds"),
|
||||
duration,
|
||||
GetDurationFormat(),
|
||||
GetDuration(),
|
||||
mProjectRate,
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
|
|
|
@ -394,20 +394,17 @@ void EffectToneGen::PopulateOrExchange(ShuttleGui & S)
|
|||
t->SetValidator(vldAmplitude);
|
||||
}
|
||||
|
||||
bool isSelection;
|
||||
double duration = GetDuration(&isSelection);
|
||||
|
||||
S.AddPrompt(_("Duration:"));
|
||||
mToneDurationT = new
|
||||
NumericTextCtrl(NumericConverter::TIME,
|
||||
S.GetParent(),
|
||||
wxID_ANY,
|
||||
isSelection ? _("hh:mm:ss + samples") : _("hh:mm:ss + milliseconds"),
|
||||
duration,
|
||||
mProjectRate,
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
true);
|
||||
S.GetParent(),
|
||||
wxID_ANY,
|
||||
GetDurationFormat(),
|
||||
GetDuration(),
|
||||
mProjectRate,
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
true);
|
||||
mToneDurationT->SetName(_("Duration"));
|
||||
mToneDurationT->EnableMenu();
|
||||
S.AddWindow(mToneDurationT, wxALIGN_LEFT | wxALL);
|
||||
|
|
|
@ -3515,17 +3515,14 @@ void VSTEffect::BuildPlain()
|
|||
// Add the duration control for generators
|
||||
if (GetType() == EffectTypeGenerate)
|
||||
{
|
||||
bool isSelection;
|
||||
double duration = mHost->GetDuration(&isSelection);
|
||||
|
||||
wxControl *item = new wxStaticText(scroller, 0, _("Duration:"));
|
||||
gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
|
||||
mDuration = new
|
||||
NumericTextCtrl(NumericConverter::TIME,
|
||||
scroller,
|
||||
ID_Duration,
|
||||
isSelection ? _("hh:mm:ss + samples") : _("hh:mm:ss + milliseconds"),
|
||||
duration,
|
||||
mHost->GetDurationFormat(),
|
||||
mHost->GetDuration(),
|
||||
mSampleRate,
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
|
|
|
@ -1146,17 +1146,14 @@ bool LadspaEffect::PopulateUI(wxWindow *parent)
|
|||
// Add the duration control for generators
|
||||
if (GetType() == EffectTypeGenerate)
|
||||
{
|
||||
bool isSelection;
|
||||
double duration = mHost->GetDuration(&isSelection);
|
||||
|
||||
item = new wxStaticText(w, 0, _("Duration:"));
|
||||
gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
|
||||
mDuration = new
|
||||
NumericTextCtrl(NumericConverter::TIME,
|
||||
w,
|
||||
ID_Duration,
|
||||
isSelection ? _("hh:mm:ss + samples") : _("hh:mm:ss + milliseconds"),
|
||||
duration,
|
||||
mHost->GetDurationFormat(),
|
||||
mHost->GetDuration(),
|
||||
mSampleRate,
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
|
|
|
@ -1579,17 +1579,14 @@ bool LV2Effect::BuildPlain()
|
|||
|
||||
wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
bool isSelection;
|
||||
double duration = mHost->GetDuration(&isSelection);
|
||||
|
||||
wxWindow *item = new wxStaticText(w, 0, _("&Duration:"));
|
||||
sizer->Add(item, 0, wxALIGN_CENTER | wxALL, 5);
|
||||
mDuration = new
|
||||
NumericTextCtrl(NumericConverter::TIME,
|
||||
w,
|
||||
ID_Duration,
|
||||
isSelection ? _("hh:mm:ss + samples") : _("hh:mm:ss + milliseconds"),
|
||||
duration,
|
||||
mHost->GetDurationFormat(),
|
||||
mHost->GetDuration(),
|
||||
mSampleRate,
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
|
|
Loading…
Reference in New Issue