From 6a313a35bfaedc4be56bed95dd5d281e4311e4cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Marinier?= Date: Thu, 28 Jul 2016 00:12:28 +0200 Subject: [PATCH 1/5] Optimize the refresh of the selection bar while Audacity is playing. This saves 3-4% CPU while Audacity is playing on Linux/64bits. This is done by avoiding the update of NumerixTextCtrls that stay unchanged. --- src/widgets/NumericTextCtrl.cpp | 13 ++++++++++++- src/widgets/NumericTextCtrl.h | 11 +++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/widgets/NumericTextCtrl.cpp b/src/widgets/NumericTextCtrl.cpp index b5857d84c..807aad27c 100644 --- a/src/widgets/NumericTextCtrl.cpp +++ b/src/widgets/NumericTextCtrl.cpp @@ -1814,8 +1814,19 @@ void NumericTextCtrl::Updated(bool keyup /* = false */) void NumericTextCtrl::ValueToControls() { + const wxString previousValueString = mValueString; NumericConverter::ValueToControls(mValue); - Refresh(false); + if (mValueString != previousValueString) { + // Doing this only when needed is an optimization. + // NumerixTextCtrls are used in the selection bar at the bottom + // of Audacity, and are updated at high frequency through + // SetValue() when Audacity is playing. This consumes a + // significant amount of CPU. Typically, when a track is + // playing, only one of the NumericTextCtrl actually changes + // (the audio position). We save CPU by updating the control + // only when needed. + Refresh(false); + } } diff --git a/src/widgets/NumericTextCtrl.h b/src/widgets/NumericTextCtrl.h index cc863af29..e817f73e5 100644 --- a/src/widgets/NumericTextCtrl.h +++ b/src/widgets/NumericTextCtrl.h @@ -65,9 +65,16 @@ public: virtual ~NumericConverter(); + // ValueToControls() formats a raw value (either provided as + // argument, or mValue, depending on the version of the function + // called). The result is stored to mValueString. virtual void ValueToControls(); virtual void ValueToControls(double rawValue, bool nearest = true); + + // Converts the stored formatted string (mValueString) back to a + // raw value (mValue). virtual void ControlsToValue(); + virtual void ParseFormatString(const wxString & format); void PrintDebugInfo(); @@ -114,6 +121,7 @@ protected: wxString mPrefix; wxString mValueTemplate; wxString mValueMask; + // Formatted mValue, by ValueToControls(). wxString mValueString; double mScalingFactor; @@ -180,6 +188,9 @@ private: void OnFocus(wxFocusEvent &event); void OnContext(wxContextMenuEvent &event); + // Formats mValue into mValueString, using the method of the base class. + // Triggers a refresh of the wx window only when the value actually + // changed since last time a refresh was triggered. void ValueToControls() override; void ControlsToValue() override; From 5a8801fcd6865d07e7e1d21384345f5bd8eb6237 Mon Sep 17 00:00:00 2001 From: Gale Andrews Date: Mon, 15 Aug 2016 23:10:50 +0100 Subject: [PATCH 2/5] Mark Young's change to download Audacity as step 2 And update copyright date --- win/compile.txt | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/win/compile.txt b/win/compile.txt index 8bf7a33d1..23a8192f7 100644 --- a/win/compile.txt +++ b/win/compile.txt @@ -1,5 +1,5 @@ Building Audacity(R) for Microsoft Windows(R) -Copyright (c) 1999-2015 Audacity Team +Copyright (c) 1999-2016 Audacity Team Authors: Asger Ottar Alstrup @@ -48,10 +48,18 @@ wxWidgets from http://www.wxwidgets.org/. ------------------------------------------------------------------------ -MSVC++ STEP 2: Build wxWidgets +MSVC++ STEP 2: Download source code for Audacity ------------------------------------------------------------------------ -2.1. Open "C:\wxWidgets-3.0.2\build\msw\wx_dll.dsw" with +Checkout the latest Audacity code from our GitHub repository +at https://github.com/audacity/audacity/ (see GitHub for help). + + +------------------------------------------------------------------------ +MSVC++ STEP 3: Build wxWidgets +------------------------------------------------------------------------ + +3.1. Open "C:\wxWidgets-3.0.2\build\msw\wx_dll.dsw" with Microsoft Visual Studio. Make sure to use wx_dll.dsw, not wx.dsw, because wx.dsw does not have the correct dependencies for the DLL builds. @@ -61,7 +69,7 @@ MSVC++ STEP 2: Build wxWidgets "C\wxWidgets-3.0.2\build\msw\wx_dll.sln" instead of wx_dll.dsw. -2.2. We have patched wxWidgets with four patches. You should apply all +3.2. We have patched wxWidgets with four patches. You should apply all four. You can do this in one step by copying the folder "audacity\win\wxWidgets_additions\wxWidgets-3.0.2\" over your: @@ -91,7 +99,7 @@ MSVC++ STEP 2: Build wxWidgets features. -2.3. Build wxWidgets for all configurations of Audacity that you want. +3.3. Build wxWidgets for all configurations of Audacity that you want. * Use the "DLL Release" configuration to use in a "Release" version of Audacity. @@ -132,13 +140,6 @@ MSVC++ STEP 2: Build wxWidgets wxbase30*_odbc*.* dbgrid. ------------------------------------------------------------------------- -MSVC++ STEP 3: Download source code for Audacity ------------------------------------------------------------------------- - -Checkout the latest Audacity code from our GitHub repository -at https://github.com/audacity/audacity/ (see GitHub for help). - ------------------------------------------------------------------------ MSVC++ STEP 4: Set wxWidgets location for Audacity ------------------------------------------------------------------------ From 15a60bde4bc8a20f743f19f90782e21df18488e1 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 15 Aug 2016 21:19:50 -0400 Subject: [PATCH 3/5] Fix linux debug complaints of missing thread shut-down... ... caused by commit b47bcb548e7866c1a44a4600ffbeff0ae0445516 --- src/AudacityApp.cpp | 2 ++ src/AudioIO.cpp | 5 +++++ src/AudioIO.h | 1 + 3 files changed, 8 insertions(+) diff --git a/src/AudacityApp.cpp b/src/AudacityApp.cpp index 5aaa1e4ce..df3fd429a 100644 --- a/src/AudacityApp.cpp +++ b/src/AudacityApp.cpp @@ -2025,6 +2025,8 @@ int AudacityApp::OnExit() DeinitFFT(); + DeinitAudioIO(); + // Terminate the PluginManager (must be done before deleting the locale) PluginManager::Get().Terminate(); diff --git a/src/AudioIO.cpp b/src/AudioIO.cpp index 5194eb5f8..c46061a04 100644 --- a/src/AudioIO.cpp +++ b/src/AudioIO.cpp @@ -943,6 +943,11 @@ void InitAudioIO() gPrefs->Flush(); } +void DeinitAudioIO() +{ + ugAudioIO.reset(); +} + wxString DeviceName(const PaDeviceInfo* info) { wxString infoName = wxSafeConvertMB2WX(info->name); diff --git a/src/AudioIO.h b/src/AudioIO.h index 007f47f83..059d535e4 100644 --- a/src/AudioIO.h +++ b/src/AudioIO.h @@ -62,6 +62,7 @@ using WaveTrackArray = std::vector < WaveTrack* >; extern AUDACITY_DLL_API AudioIO *gAudioIO; void InitAudioIO(); +void DeinitAudioIO(); wxString DeviceName(const PaDeviceInfo* info); wxString HostName(const PaDeviceInfo* info); bool ValidateDeviceNames(); From 19fa6d2833273d8997a3c9609d8a6ee312bd092b Mon Sep 17 00:00:00 2001 From: David Bailes Date: Tue, 16 Aug 2016 13:57:19 +0100 Subject: [PATCH 4/5] Improvements to accessibility names in Change Tempo effect. The change tempo effect was modified in commit 8e0089c. The most significant change is to include the "from" length in the accessibility name of the "to" length textctrl. (The nvda screen reader cannot access the value of the "from" length textctrl, and it's not straightforward using Jaws. Note that this issue existed before the recent change of Change Tempo.) There remains a minor issue of Jaws, but not NVDA reading the names of wxStaticBoxes, and so some repetition in what is read by Jaws. --- src/effects/ChangeTempo.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/effects/ChangeTempo.cpp b/src/effects/ChangeTempo.cpp index 1868ba3c4..e39d8d88d 100644 --- a/src/effects/ChangeTempo.cpp +++ b/src/effects/ChangeTempo.cpp @@ -229,13 +229,13 @@ void EffectChangeTempo::PopulateOrExchange(ShuttleGui & S) FloatingPointValidator vldFromBPM(3, &m_FromBPM, NUM_VAL_THREE_TRAILING_ZEROES | NUM_VAL_ZERO_AS_BLANK); m_pTextCtrl_FromBPM = S.Id(ID_FromBPM) .AddTextBox(_("from"), wxT(""), 12); - m_pTextCtrl_FromBPM->SetName(_("From beats per minute")); + m_pTextCtrl_FromBPM->SetName(_("Beats per minute, from")); m_pTextCtrl_FromBPM->SetValidator(vldFromBPM); FloatingPointValidator vldToBPM(3, &m_ToBPM, NUM_VAL_THREE_TRAILING_ZEROES | NUM_VAL_ZERO_AS_BLANK); m_pTextCtrl_ToBPM = S.Id(ID_ToBPM) .AddTextBox(_("to"), wxT(""), 12); - m_pTextCtrl_ToBPM->SetName(_("To beats per minute")); + m_pTextCtrl_ToBPM->SetName(_("Beats per minute, to")); m_pTextCtrl_ToBPM->SetValidator(vldToBPM); } S.EndHorizontalLay(); @@ -251,7 +251,6 @@ void EffectChangeTempo::PopulateOrExchange(ShuttleGui & S) FloatingPointValidator vldFromLength(precission, &m_FromLength, NUM_VAL_TWO_TRAILING_ZEROES); m_pTextCtrl_FromLength = S.Id(ID_FromLength) .AddTextBox(_("from"), wxT(""), 12); - m_pTextCtrl_FromLength->SetName(_("From length in seconds")); m_pTextCtrl_FromLength->SetValidator(vldFromLength); m_pTextCtrl_FromLength->Enable(false); // Disable because the value comes from the user selection. @@ -266,7 +265,6 @@ void EffectChangeTempo::PopulateOrExchange(ShuttleGui & S) vldToLength.SetRange(minLength, maxLength); m_pTextCtrl_ToLength = S.Id(ID_ToLength) .AddTextBox(_("to"), wxT(""), 12); - m_pTextCtrl_ToLength->SetName(_("To length in seconds")); m_pTextCtrl_ToLength->SetValidator(vldToLength); } S.EndHorizontalLay(); @@ -308,6 +306,10 @@ bool EffectChangeTempo::TransferDataToWindow() m_bLoopDetect = false; + // Set the accessibility name here because we need m_pTextCtrl_FromLength to have had its value set + m_pTextCtrl_ToLength->SetName(_("Length in seconds from") + wxT(" ") + m_pTextCtrl_FromLength->GetValue() + +wxT(", ") + _("to")); + return true; } From 7b14e68b373f2d98374fdf4c63e6b8ea3929e880 Mon Sep 17 00:00:00 2001 From: Steve Daulton Date: Tue, 16 Aug 2016 14:54:02 +0100 Subject: [PATCH 5/5] Pass name of proxy effect to EffectSBSMS Allows progress bar to show meaningful title when using SBSMS time stretching in Change Pitch/Tempo. --- src/effects/ChangePitch.cpp | 1 + src/effects/ChangeTempo.cpp | 1 + src/effects/SBSMSEffect.h | 8 ++++++++ 3 files changed, 10 insertions(+) diff --git a/src/effects/ChangePitch.cpp b/src/effects/ChangePitch.cpp index bc8da84ee..39519578d 100644 --- a/src/effects/ChangePitch.cpp +++ b/src/effects/ChangePitch.cpp @@ -185,6 +185,7 @@ bool EffectChangePitch::Process() double pitchRatio = 1.0 + m_dPercentChange / 100.0; SelectedRegion region(mT0, mT1); EffectSBSMS proxy; + proxy.mProxyEffectName = XO("High Quality Pitch Change"); proxy.setParameters(1.0, pitchRatio); return proxy.DoEffect(mUIParent, mProjectRate, mTracks, mFactory, ®ion, false); diff --git a/src/effects/ChangeTempo.cpp b/src/effects/ChangeTempo.cpp index e39d8d88d..525a3544d 100644 --- a/src/effects/ChangeTempo.cpp +++ b/src/effects/ChangeTempo.cpp @@ -173,6 +173,7 @@ bool EffectChangeTempo::Process() double tempoRatio = 1.0 + m_PercentChange / 100.0; SelectedRegion region(mT0, mT1); EffectSBSMS proxy; + proxy.mProxyEffectName = XO("High Quality Tempo Change"); proxy.setParameters(tempoRatio, 1.0); success = proxy.DoEffect(mUIParent, mProjectRate, mTracks, mFactory, ®ion, false); } diff --git a/src/effects/SBSMSEffect.h b/src/effects/SBSMSEffect.h index fd5da4648..9cfb7543a 100644 --- a/src/effects/SBSMSEffect.h +++ b/src/effects/SBSMSEffect.h @@ -31,6 +31,11 @@ public: void setParameters(double tempoRatio, double pitchRatio); // Constant ratio (tempoRatio, pitchRatio) static double getInvertedStretchedTime(double rateStart, double rateEnd, SlideType slideType, double outputTime); static double getRate(double rateStart, double rateEnd, SlideType slideType, double t); + +protected: + wxString mProxyEffectName { XO("SBSMS Time / Pitch Stretch") }; + wxString GetName() override { return mProxyEffectName; }; + private: bool ProcessLabelTrack(Track *track); double rateStart, rateEnd, pitchStart, pitchEnd; @@ -41,6 +46,9 @@ private: double mCurT0; double mCurT1; float mTotalStretch; + + friend class EffectChangeTempo; + friend class EffectChangePitch; }; #endif