|
|
|
Al Dimond
|
Following this discussion on the audacity-nyquist list:
http://n2.nabble.com/Inputting-exact-values-into-Audacity-Nyquist- effects-td3850278.html#a3850278 I've developed a patch improving the behavior of dialog boxes for Nyquist plugin inputs. This solves the bug "P3: Nyquist implementation: Values appearing in effects text boxes are not always the hard-coded/previously entered values", and also makes it easier for users to enter values into the text boxes at higher precision than what's usually displayed (it used to be that they could not touch other sliders without having their custom values rounded to the nearest slider "tick"). - Al [awd_nyquist_exact_inputs_3.patch] Index: src/effects/nyquist/Nyquist.cpp =================================================================== RCS file: /cvsroot/audacity/audacity-src/src/effects/nyquist/Nyquist.cpp,v retrieving revision 1.84 diff -u -r1.84 Nyquist.cpp --- src/effects/nyquist/Nyquist.cpp 18 Sep 2009 08:18:49 -0000 1.84 +++ src/effects/nyquist/Nyquist.cpp 22 Oct 2009 00:48:37 -0000 @@ -1049,22 +1049,48 @@ wxASSERT(slider && text); int val = slider->GetValue(); - ctrl->val = (val / (double)ctrl->ticks)* + + double newVal = (val / (double)ctrl->ticks)* (ctrl->high - ctrl->low) + ctrl->low; - + + // Determine precision for displayed number + int precision = ctrl->high - ctrl->low < 1 ? 3 : + ctrl->high - ctrl->low < 10 ? 2 : + ctrl->high - ctrl->low < 100 ? 1 : + 0; + + // If the value is at least one tick different from the current value + // change it (this prevents changes from manually entered values unless + // the slider actually moved) + if (fabs(newVal - ctrl->val) >= (1 / (double)ctrl->ticks) * + (ctrl->high - ctrl->low) && + fabs(newVal - ctrl->val) >= pow(0.1, precision) / 2 ) + { + // First round to the appropriate precision + newVal *= pow(10, precision); + newVal = floor(newVal + 0.5); + newVal /= pow(10, precision); + + ctrl->val = newVal; + } + wxString valStr; if (ctrl->type == NYQ_CTRL_REAL) { - if (ctrl->high - ctrl->low < 1) { - valStr = Internat::ToDisplayString(ctrl->val, 3); - } - else if (ctrl->high - ctrl->low < 10) { - valStr = Internat::ToDisplayString(ctrl->val, 2); - } - else if (ctrl->high - ctrl->low < 100) { - valStr = Internat::ToDisplayString(ctrl->val, 1); - } - else { - valStr.Printf(wxT("%d"), (int)floor(ctrl->val + 0.5)); + // If this is a user-typed value, allow unlimited precision + if (ctrl->val != newVal) + { + valStr = Internat::ToDisplayString(ctrl->val); + } + else + { + if (precision == 0) + { + valStr.Printf(wxT("%d"), (int)floor(ctrl->val + 0.5)); + } + else + { + valStr = Internat::ToDisplayString(ctrl->val, precision); + } } } else if (ctrl->type == NYQ_CTRL_INT) { ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ audacity-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/audacity-devel |
||||||||||||||||
|
Gale (Audacity Team)
|
| From Al Dimond <[hidden email]> | Thu, 22 Oct 2009 12:19:25 -0600 | Subject: [Audacity-nyquist] Patch improving Nyquist input behavior > Following this discussion on the audacity-nyquist list: > > http://n2.nabble.com/Inputting-exact-values-into-Audacity-Nyquist- > effects-td3850278.html#a3850278 > > I've developed a patch improving the behavior of dialog boxes for > Nyquist plugin inputs. This solves the bug "P3: Nyquist > implementation: Values appearing in effects text boxes are not always > the hard-coded/previously entered values", and also makes it easier > for users to enter values into the text boxes at higher precision than > what's usually displayed (it used to be that they could not touch > other sliders without having their custom values rounded to the > nearest slider "tick"). Hi Al On VisualStudio, I got the following compile error after running this patch: Nyquist.cpp ..\..\..\src\effects\nyquist\Nyquist.cpp(1070) : error C2668: 'pow' : ambiguous call to overloaded function C:\Program Files\Microsoft Visual Studio 9.0\VC\include\math.h(575): could be 'long double pow(long double,int)' C:\Program Files\Microsoft Visual Studio 9.0\VC\include\math.h(527): or 'float pow(float,int)' C:\Program Files\Microsoft Visual Studio 9.0\VC\include\math.h(489): or 'double pow(double,int)' while trying to match the argument list '(int, int)' ..\..\..\src\effects\nyquist\Nyquist.cpp(1072) : error C2668: 'pow' : ambiguous call to overloaded function C:\Program Files\Microsoft Visual Studio 9.0\VC\include\math.h(575): could be 'long double pow(long double,int)' C:\Program Files\Microsoft Visual Studio 9.0\VC\include\math.h(527): or 'float pow(float,int)' C:\Program Files\Microsoft Visual Studio 9.0\VC\include\math.h(489): or 'double pow(double,int)' while trying to match the argument list '(int, int)' Gale ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ audacity-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/audacity-devel |
||||||||||||||||
|
Al Dimond
|
On Friday 23 October 2009 02:27:50 Gale Andrews wrote:
> Hi Al > > On VisualStudio, I got the following compile error after running > this patch: > > Nyquist.cpp > ..\..\..\src\effects\nyquist\Nyquist.cpp(1070) : error C2668: 'pow' > : ambiguous call to overloaded function C:\Program Files\Microsoft > Visual Studio 9.0\VC\include\math.h(575): could be 'long double > pow(long double,int)' C:\Program Files\Microsoft Visual Studio > 9.0\VC\include\math.h(527): or 'float pow(float,int)' > C:\Program Files\Microsoft Visual Studio > 9.0\VC\include\math.h(489): or 'double pow(double,int)' > while trying to match the argument list '(int, int)' > ..\..\..\src\effects\nyquist\Nyquist.cpp(1072) : error C2668: > 'pow' : ambiguous call to overloaded function C:\Program > Files\Microsoft Visual Studio 9.0\VC\include\math.h(575): could be > 'long double pow(long double,int)' C:\Program Files\Microsoft > Visual Studio 9.0\VC\include\math.h(527): or 'float > pow(float,int)' C:\Program Files\Microsoft Visual Studio > 9.0\VC\include\math.h(489): or 'double pow(double,int)' > while trying to match the argument list '(int, int)' > Really!?!?! OK. On each of those lines the first argument to pow() is the literal 10. Does it build if you cast each of them to a double? Or change them to 10.0... although that's probably just as ambiguous. - Al ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ audacity-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/audacity-devel |
||||||||||||||||
|
Vaughan Johnson
|
Al Dimond wrote: > On Friday 23 October 2009 02:27:50 Gale Andrews wrote: >> Hi Al >> >> On VisualStudio, I got the following compile error after running >> this patch: >> >> Nyquist.cpp >> ..\..\..\src\effects\nyquist\Nyquist.cpp(1070) : error C2668: 'pow' >> : ambiguous call to overloaded function C:\Program Files\Microsoft >> Visual Studio 9.0\VC\include\math.h(575): could be 'long double >> pow(long double,int)' C:\Program Files\Microsoft Visual Studio >> 9.0\VC\include\math.h(527): or 'float pow(float,int)' >> C:\Program Files\Microsoft Visual Studio >> 9.0\VC\include\math.h(489): or 'double pow(double,int)' >> while trying to match the argument list '(int, int)' >> ..\..\..\src\effects\nyquist\Nyquist.cpp(1072) : error C2668: >> 'pow' : ambiguous call to overloaded function C:\Program >> Files\Microsoft Visual Studio 9.0\VC\include\math.h(575): could be >> 'long double pow(long double,int)' C:\Program Files\Microsoft >> Visual Studio 9.0\VC\include\math.h(527): or 'float >> pow(float,int)' C:\Program Files\Microsoft Visual Studio >> 9.0\VC\include\math.h(489): or 'double pow(double,int)' >> while trying to match the argument list '(int, int)' >> > > Really!?!?! OK. On each of those lines the first argument to pow() is > the literal 10. Does it build if you cast each of them to a double? > Or change them to 10.0... although that's probably just as ambiguous. > You just need to change them to 10.0 (e.g.) or 10.0f or whatever you're actually intending. This happens pretty often due to compile differences. - V ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ audacity-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/audacity-devel |
||||||||||||||||
|
Al Dimond
|
On Friday 23 October 2009 12:57:24 Vaughan Johnson wrote:
> Al Dimond wrote: > > On Friday 23 October 2009 02:27:50 Gale Andrews wrote: > >> Hi Al > >> > >> On VisualStudio, I got the following compile error after running > >> this patch: > >> > >> Nyquist.cpp > >> ..\..\..\src\effects\nyquist\Nyquist.cpp(1070) : error C2668: > >> 'pow' > >> > >> : ambiguous call to overloaded function C:\Program > >> : Files\Microsoft > >> > >> Visual Studio 9.0\VC\include\math.h(575): could be 'long double > >> pow(long double,int)' C:\Program Files\Microsoft Visual Studio > >> 9.0\VC\include\math.h(527): or 'float pow(float,int)' > >> C:\Program Files\Microsoft Visual Studio > >> 9.0\VC\include\math.h(489): or 'double pow(double,int)' > >> while trying to match the argument list '(int, int)' > >> ..\..\..\src\effects\nyquist\Nyquist.cpp(1072) : error C2668: > >> 'pow' : ambiguous call to overloaded function C:\Program > >> Files\Microsoft Visual Studio 9.0\VC\include\math.h(575): could > >> be 'long double pow(long double,int)' C:\Program Files\Microsoft > >> Visual Studio 9.0\VC\include\math.h(527): or 'float > >> pow(float,int)' C:\Program Files\Microsoft Visual Studio > >> 9.0\VC\include\math.h(489): or 'double pow(double,int)' > >> while trying to match the argument list '(int, int)' > > > > Really!?!?! OK. On each of those lines the first argument to > > pow() is the literal 10. Does it build if you cast each of them > > to a double? Or change them to 10.0... although that's probably > > just as ambiguous. > > You just need to change them to 10.0 (e.g.) or 10.0f or whatever > you're actually intending. This happens pretty often due to > compile differences. > using forms like 10.0 all over the place when 10 usually suffices for me. For anyone looking to build with VC, a new patch that hopefully builds there straightaway is attached (I don't have an installation to test on ATM). - Al [awd_nyquist_exact_inputs_3a.patch] Index: src/effects/nyquist/Nyquist.cpp =================================================================== RCS file: /cvsroot/audacity/audacity-src/src/effects/nyquist/Nyquist.cpp,v retrieving revision 1.84 diff -u -r1.84 Nyquist.cpp --- src/effects/nyquist/Nyquist.cpp 18 Sep 2009 08:18:49 -0000 1.84 +++ src/effects/nyquist/Nyquist.cpp 22 Oct 2009 00:48:37 -0000 @@ -1049,22 +1049,48 @@ wxASSERT(slider && text); int val = slider->GetValue(); - ctrl->val = (val / (double)ctrl->ticks)* + + double newVal = (val / (double)ctrl->ticks)* (ctrl->high - ctrl->low) + ctrl->low; - + + // Determine precision for displayed number + int precision = ctrl->high - ctrl->low < 1 ? 3 : + ctrl->high - ctrl->low < 10 ? 2 : + ctrl->high - ctrl->low < 100 ? 1 : + 0; + + // If the value is at least one tick different from the current value + // change it (this prevents changes from manually entered values unless + // the slider actually moved) + if (fabs(newVal - ctrl->val) >= (1 / (double)ctrl->ticks) * + (ctrl->high - ctrl->low) && + fabs(newVal - ctrl->val) >= pow(0.1, precision) / 2 ) + { + // First round to the appropriate precision + newVal *= pow(10.0, precision); + newVal = floor(newVal + 0.5); + newVal /= pow(10.0, precision); + + ctrl->val = newVal; + } + wxString valStr; if (ctrl->type == NYQ_CTRL_REAL) { - if (ctrl->high - ctrl->low < 1) { - valStr = Internat::ToDisplayString(ctrl->val, 3); - } - else if (ctrl->high - ctrl->low < 10) { - valStr = Internat::ToDisplayString(ctrl->val, 2); - } - else if (ctrl->high - ctrl->low < 100) { - valStr = Internat::ToDisplayString(ctrl->val, 1); - } - else { - valStr.Printf(wxT("%d"), (int)floor(ctrl->val + 0.5)); + // If this is a user-typed value, allow unlimited precision + if (ctrl->val != newVal) + { + valStr = Internat::ToDisplayString(ctrl->val); + } + else + { + if (precision == 0) + { + valStr.Printf(wxT("%d"), (int)floor(ctrl->val + 0.5)); + } + else + { + valStr = Internat::ToDisplayString(ctrl->val, precision); + } } } else if (ctrl->type == NYQ_CTRL_INT) { ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ audacity-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/audacity-devel |
||||||||||||||||
|
Gale (Audacity Team)
|
| From Al Dimond <[hidden email]> | Fri, 23 Oct 2009 13:33:38 -0600 | Subject: [Audacity-devel] [Audacity-nyquist] Patch improving Nyquist input behavior > On Friday 23 October 2009 12:57:24 Vaughan Johnson wrote: > > Al Dimond wrote: > > > On Friday 23 October 2009 02:27:50 Gale Andrews wrote: > > >> Hi Al > > >> > > >> On VisualStudio, I got the following compile error after running > > >> this patch: > > >> > > >> Nyquist.cpp > > >> ..\..\..\src\effects\nyquist\Nyquist.cpp(1070) : error C2668: > > >> 'pow' > > >> > > >> : ambiguous call to overloaded function C:\Program > > >> : Files\Microsoft > > >> > > >> Visual Studio 9.0\VC\include\math.h(575): could be 'long double > > >> pow(long double,int)' C:\Program Files\Microsoft Visual Studio > > >> 9.0\VC\include\math.h(527): or 'float pow(float,int)' > > >> C:\Program Files\Microsoft Visual Studio > > >> 9.0\VC\include\math.h(489): or 'double pow(double,int)' > > >> while trying to match the argument list '(int, int)' > > >> ..\..\..\src\effects\nyquist\Nyquist.cpp(1072) : error C2668: > > >> 'pow' : ambiguous call to overloaded function C:\Program > > >> Files\Microsoft Visual Studio 9.0\VC\include\math.h(575): could > > >> be 'long double pow(long double,int)' C:\Program Files\Microsoft > > >> Visual Studio 9.0\VC\include\math.h(527): or 'float > > >> pow(float,int)' C:\Program Files\Microsoft Visual Studio > > >> 9.0\VC\include\math.h(489): or 'double pow(double,int)' > > >> while trying to match the argument list '(int, int)' > > > > > > Really!?!?! OK. On each of those lines the first argument to > > > pow() is the literal 10. Does it build if you cast each of them > > > to a double? Or change them to 10.0... although that's probably > > > just as ambiguous. > > > > You just need to change them to 10.0 (e.g.) or 10.0f or whatever > > you're actually intending. This happens pretty often due to > > compile differences. > > > > Ah, that must be why I see so much code (in Audacity and elsewhere) > using forms like 10.0 all over the place when 10 usually suffices for > me. For anyone looking to build with VC, a new patch that hopefully > builds there straightaway is attached (I don't have an installation to > test on ATM). Thanks, Al. I'd already modified: newVal *= pow(10, precision); newVal /= pow(10, precision); in the old patch to read "10.0" in both cases and that did the trick for me. I tested the patch cursorily on Windows XP in High Pass and Low Pass to make sure that typing values in the boxes is now respected when you reopen the effect. I also changed the default value in Low Pass to verify that changed default was used when launching Audacity afresh. I tried Pluck, though I don't think it was affected by this bug. > makes it easier for users to enter values into the text boxes at > higher precision than what's usually displayed (it used to be > that they could not touch other sliders without having their > custom values rounded to the nearest slider "tick"). That works for me in High Pass and Low Pass. Gale ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ audacity-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/audacity-devel |
||||||||||||||||
| Free Embeddable Forum Powered by Nabble | Help |