mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-24 16:20:05 +02:00
Fix for bug 963
When using FloatingPointValidator and calculating the min / max range as floats or doubles, the validated control value has been rounded to 'n' decimal places, but the min / max range have not been rounded. It is therefore a matter of chance whether the rounded control value, when at the extreme limit of the range, is within the higher precision range or not.
This commit is contained in:
parent
d2a6f8dbc2
commit
1a2486b01a
@ -214,15 +214,15 @@ void EffectAmplify::PopulateOrExchange(ShuttleGui & S)
|
|||||||
// Peak
|
// Peak
|
||||||
S.StartMultiColumn(2, wxCENTER);
|
S.StartMultiColumn(2, wxCENTER);
|
||||||
{
|
{
|
||||||
FloatingPointValidator<double> vldNewPeak(2, &mNewPeak);
|
int precission = 2;
|
||||||
|
FloatingPointValidator<double> vldNewPeak(precission, &mNewPeak);
|
||||||
double minAmp = MIN_Amp + (20.0 * log10(mPeak));
|
double minAmp = MIN_Amp + (20.0 * log10(mPeak));
|
||||||
double maxAmp = MAX_Amp + (20.0 * log10(mPeak));
|
double maxAmp = MAX_Amp + (20.0 * log10(mPeak));
|
||||||
// TODO: This is a hack that should be fixed in the validator:
|
|
||||||
// If MAX_Amp is negative, then the truncated text value will be greater
|
// min and max need same precision as what we're validating (bug 963)
|
||||||
// than the actual float value.
|
minAmp = Internat::CompatibleToDouble(Internat::ToString(minAmp, precission));
|
||||||
// Add 0.05 to the max value, equivalent to rounding the right way.
|
maxAmp = Internat::CompatibleToDouble(Internat::ToString(maxAmp, precission));
|
||||||
if (maxAmp < 0)
|
|
||||||
maxAmp += 0.005;
|
|
||||||
vldNewPeak.SetRange(minAmp, maxAmp);
|
vldNewPeak.SetRange(minAmp, maxAmp);
|
||||||
mNewPeakT = S.Id(ID_Peak).AddTextBox(_("New Peak Amplitude (dB):"), wxT(""), 12);
|
mNewPeakT = S.Id(ID_Peak).AddTextBox(_("New Peak Amplitude (dB):"), wxT(""), 12);
|
||||||
mNewPeakT->SetValidator(vldNewPeak);
|
mNewPeakT->SetValidator(vldNewPeak);
|
||||||
|
@ -207,7 +207,8 @@ void EffectChangeTempo::PopulateOrExchange(ShuttleGui & S)
|
|||||||
//
|
//
|
||||||
S.AddUnits(_("Length (seconds):"));
|
S.AddUnits(_("Length (seconds):"));
|
||||||
|
|
||||||
FloatingPointValidator<double> vldFromLength(2, &m_FromLength, NUM_VAL_TWO_TRAILING_ZEROES);
|
int precission = 2;
|
||||||
|
FloatingPointValidator<double> vldFromLength(precission, &m_FromLength, NUM_VAL_TWO_TRAILING_ZEROES);
|
||||||
m_pTextCtrl_FromLength = S.Id(ID_FromLength)
|
m_pTextCtrl_FromLength = S.Id(ID_FromLength)
|
||||||
.AddTextBox(_("from"), wxT(""), 12);
|
.AddTextBox(_("from"), wxT(""), 12);
|
||||||
m_pTextCtrl_FromLength->SetName(_("From length in seconds"));
|
m_pTextCtrl_FromLength->SetName(_("From length in seconds"));
|
||||||
@ -215,8 +216,14 @@ void EffectChangeTempo::PopulateOrExchange(ShuttleGui & S)
|
|||||||
m_pTextCtrl_FromLength->Enable(false); // Disable because the value comes from the user selection.
|
m_pTextCtrl_FromLength->Enable(false); // Disable because the value comes from the user selection.
|
||||||
|
|
||||||
FloatingPointValidator<double> vldToLength(2, &m_ToLength, NUM_VAL_TWO_TRAILING_ZEROES);
|
FloatingPointValidator<double> vldToLength(2, &m_ToLength, NUM_VAL_TWO_TRAILING_ZEROES);
|
||||||
vldToLength.SetRange((m_FromLength * 100.0) / (100.0 + MAX_Percentage),
|
|
||||||
(m_FromLength * 100.0) / (100.0 + MIN_Percentage));
|
// min and max need same precision as what we're validating (bug 963)
|
||||||
|
double minLength = (m_FromLength * 100.0) / (100.0 + MAX_Percentage);
|
||||||
|
double maxLength = (m_FromLength * 100.0) / (100.0 + MIN_Percentage);
|
||||||
|
minLength = Internat::CompatibleToDouble(Internat::ToString(minLength, precission));
|
||||||
|
maxLength = Internat::CompatibleToDouble(Internat::ToString(maxLength, precission));
|
||||||
|
|
||||||
|
vldToLength.SetRange(minLength, maxLength);
|
||||||
m_pTextCtrl_ToLength = S.Id(ID_ToLength)
|
m_pTextCtrl_ToLength = S.Id(ID_ToLength)
|
||||||
.AddTextBox(_("to"), wxT(""), 12);
|
.AddTextBox(_("to"), wxT(""), 12);
|
||||||
m_pTextCtrl_ToLength->SetName(_("To length in seconds"));
|
m_pTextCtrl_ToLength->SetName(_("To length in seconds"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user