diff --git a/src/effects/ChangePitch.cpp b/src/effects/ChangePitch.cpp index 9112793d9..d86c685fb 100644 --- a/src/effects/ChangePitch.cpp +++ b/src/effects/ChangePitch.cpp @@ -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) { diff --git a/src/effects/ChangePitch.h b/src/effects/ChangePitch.h index 9ebb69bbd..885a66dbb 100644 --- a/src/effects/ChangePitch.h +++ b/src/effects/ChangePitch.h @@ -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();