1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-31 16:09:28 +02:00

incremental changes related to bug 309 based on Steve's off-list patch

This commit is contained in:
v.audacity 2013-05-28 01:50:59 +00:00
parent fc0cb41356
commit 16e1958501
2 changed files with 27 additions and 5 deletions

View File

@ -462,9 +462,11 @@ bool ChangePitchDialog::TransferDataFromWindow()
// calculations
void ChangePitchDialog::Calc_ToFrequency()
void ChangePitchDialog::Calc_FromPitchIndex()
{
m_ToFrequency = (m_FromFrequency * (100.0 + m_PercentChange)) / 100.0;
m_FromPitchIndex = (int)(m_ToPitchIndex - m_SemitonesChange) % 12;
if (m_FromPitchIndex < 0)
m_FromPitchIndex += 12;
}
void ChangePitchDialog::Calc_ToPitchIndex()
@ -488,6 +490,11 @@ void ChangePitchDialog::Calc_SemitonesChange_fromPercentChange()
m_SemitonesChange = (12.0 * log((100.0 + m_PercentChange) / 100.0)) / log(2.0);
}
void ChangePitchDialog::Calc_ToFrequency()
{
m_ToFrequency = (m_FromFrequency * (100.0 + m_PercentChange)) / 100.0;
}
void ChangePitchDialog::Calc_PercentChange()
{
m_PercentChange = 100.0 * (pow(2.0, (m_SemitonesChange / 12.0)) - 1.0);
@ -593,8 +600,16 @@ void ChangePitchDialog::OnText_FromFrequency(wxCommandEvent & WXUNUSED(event))
this->Calc_ToFrequency();
this->Calc_ToPitchIndex();
// This is Steve's incremental fix for cross-updating issues related to bug 309.
// It's weird that in prior code (3 lines above this), we set m_FromPitchIndex,
// then call 2 Calc methods for the other members, and then this call to
// recalculate m_FromPitchIndex. Something's wrong there, but I want to figure
// out the overall best scheme, and this is an incremental fix.
this->Calc_FromPitchIndex();
m_bLoopDetect = true;
this->Update_Choice_ToPitch();
this->Update_Choice_FromPitch();
this->Update_Text_ToFrequency();
m_bLoopDetect = false;
@ -723,7 +738,13 @@ void ChangePitchDialog::OnPreview(wxCommandEvent & WXUNUSED(event))
mEffect->m_SemitonesChange = oldSemitonesChange;
}
// helper fns
// helper fns for controls
void ChangePitchDialog::Update_Choice_FromPitch()
{
if (m_pChoice_FromPitch)
m_pChoice_FromPitch->SetSelection(m_FromPitchIndex);
}
void ChangePitchDialog::Update_Choice_ToPitch()
{
@ -731,7 +752,6 @@ void ChangePitchDialog::Update_Choice_ToPitch()
m_pChoice_ToPitch->SetSelection(m_ToPitchIndex);
}
void ChangePitchDialog::Update_Text_SemitonesChange()
{
if (m_pTextCtrl_SemitonesChange) {

View File

@ -95,10 +95,11 @@ class ChangePitchDialog:public EffectDialog {
private:
// calculations
void Calc_ToFrequency(); // Update m_ToFrequency from m_FromFrequency & m_PercentChange.
void Calc_FromPitchIndex(); // Update m_FromPitchIndex from new m_ToPitchIndex.
void Calc_ToPitchIndex(); // Update m_ToPitchIndex from new m_SemitonesChange.
void Calc_SemitonesChange_fromPitches(); // Update m_SemitonesChange from new m_*PitchIndex-es.
void Calc_SemitonesChange_fromPercentChange(); // Update m_SemitonesChange from new m_PercentChange.
void Calc_ToFrequency(); // Update m_ToFrequency from m_FromFrequency & m_PercentChange.
void Calc_PercentChange(); // Update m_PercentChange based on new m_SemitonesChange.
// handlers
@ -116,6 +117,7 @@ class ChangePitchDialog:public EffectDialog {
void OnPreview( wxCommandEvent &event );
// helper fns for controls
void Update_Choice_FromPitch();
void Update_Choice_ToPitch();
void Update_Text_SemitonesChange();