Audacity Bug Summary
••• Introduction •••
••• Keywords •••
    Audacity 3.0.3 development began 19th April 2021

Audacity Bugzilla



Bug 1269 - "backslash percent" not saved in effect presets
"backslash percent" not saved in effect presets
Status: RESOLVED FIXED
Product: Audacity
Classification: Unclassified
Component: Built-in FX
2.1.2
Per OS All
: P4 RepeatableAll
Assigned To: Default Assignee for New Bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-11-28 12:23 UTC by Steve Daulton
Modified: 2019-08-09 10:19 UTC (History)
5 users (show)

See Also:
Steps To Reproduce:
1) In the Nyquist prompt, enter the code: (print "\\%") 2) This should (and does) print "\%" 3) Save it as a preset. 4) Retrieve the preset 5) it is restored as: (print "%")
Release Note:
First Git SHA:
Group: ---
Workaround:
Closed: 2019-08-09 00:00:00
petersampsonaudacity: Test‑OK‑Win+
stevethefiddle: Test‑OK‑Mac+
stevethefiddle: Test‑OK‑Lin+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Daulton 2015-11-28 12:23:50 UTC
If an effect preset is saved using the "Manage" button and the setting include one or more backslashes before a percent character, then the backslashes are missing in the saved settings (which unsurprisingly may lead to additional errors).

Example:
In the Nyquist prompt, enter the code:
(print "\\%")

This should (and does) print "\%"

Save it as a preset.

Retrieve the preset and it is restored as:
(print "%")

Tested on Debian Stable.
Comment 1 Gale Andrews 2015-11-29 14:48:37 UTC
Same on Windows and Mac.
Comment 2 Peter Sampson 2019-06-13 08:06:11 UTC
Testing on W10 with audacity-2.3.3-alpha-267-f320612f10e44f212c28175a57172a5811d30608

This appears to work properly
a) the reloaded preset is restored with the double backslash
b) it works to print "\%" as expected
c) opening up the .ny file with Wordpad shows the double backslash to be present
Comment 3 Peter Sampson 2019-06-13 08:12:20 UTC
Testing on macOS 10.14.5 with 2.3.3 alpha jc001

as with Windows this appears to work properly:
a) the reloaded preset is restored with the double backslash
b) it works to print "\%" as expected
c) opening up the .ny file with TextEdit shows the double backslash to be present
Comment 4 Steve Daulton 2019-06-13 08:23:04 UTC
(In reply to Peter Sampson from comment #2)
Not fixed on Linux. The bug is still as described in the Description.
Comment 5 Steve Daulton 2019-06-13 08:29:23 UTC
(In reply to Steve Daulton from comment #4)
Not fixed in Audacity 2.3.2 on Windows.
Comment 6 Peter Sampson 2019-06-13 08:36:04 UTC
(In reply to Steve Daulton from comment #5)
>Not fixed in Audacity 2.3.2 on Windows.

I just tested on W10 with 2,3,2 - and that works for me - so I'm puzzled
Comment 7 Peter Sampson 2019-06-13 08:42:38 UTC
Ah - but on W10 with 2.3.2 or 2.3.3 alpha

adding to the steps
6) close Audacity
7) relaunch Audacity
8) Tools Nyquist Prompt
9) command shows as (print "%")
BUT ...
10) Load the preset saved at Step 3
11) command shows as (print "\\%")

So the bug as described works for me

but do Steps 6-9 represent a bug ?
Comment 8 Peter Sampson 2019-06-13 08:50:14 UTC
Ah now I see what the problem is

As with Equalization we have two ways of managing presets - and they don't play nice together

1) The Save and LOAD buttons do work, restoring (print "\\%")
this save the preset in a .ny file

2) The Manage button with user presets  wrongly restores(print "%")
I don't know where this gets stored

So it's the newer Manage regime that shows this bug

But we should not be having the two non-interacting ways of handling presets !
Comment 9 Peter Sampson 2019-06-13 08:54:46 UTC
(In reply to Peter Sampson from comment #7)
The Manual says here https://alphamanual.audacityteam.org/man/Nyquist_Prompt#Buttons

>OK: Applies the code to the waveform selection without debug output. 
>Your entered code will be retained next time you open Nyquist Prompt 
>in the Audacity session.

so this implies that Steps 6-9 in Comment #7 is a bug (part of this bug - or maybe a new bug)
Comment 10 Steve Daulton 2019-06-13 09:43:04 UTC
I've just tested with 4cc35b145b53ca0a0dda7f061f090e04342216a8 on Windows 10 (latest commit at time of writing).

1) Delete pluginregistry.cfg and pluginsettings.cfg
2) Launch Audacity
3) Add new track and make a selection
4) Launch "Nyquist Prompt" from Tool menu
5) In the Nyquist Prompt text box, type:
(print "\\%")

6) Click the "Manage" button.
7) Select "Save Preset", type "test" (without quotes) as the name and click the OK button.
8) Delete the contents of the Nyquist Prompt text box.
9) "Manage button > User Presets > test"

The Nyquist Prompt text box now contains:
(print "%")

The Nyquist Prompt text box "should" have been restored as:
(print "\\%")
but the backslashes have "apparently" not been saved in the effect preset. 

If we now close Audacity and look in pluginsettings.cfg, we see the line:

Parameters=Command="(print \\"\\\\%\\")" Version="4"

Given that backslashes have to be escaped with a backslash, this looks correct at first glance, but note that the quotes are not escaped with a single backslash but a double backslash.

\\" produces "

The first backslash is to ensure that the second backslash survives, and the second backslash is required to escape the quote character.

Now for the case of a backslash character:
The backslash must be escaped with a backslash, so we need two backslashes, but for each of those to survive, they must themselves be escaped. Thus for each backslash character, the saved setting must have 4 backslashes. Thus:

\\\\ produces \
\\\\\\\\ produces \\

However, if we then add a % character after the back slashes, it gets treated as and escape sequence, so we actually need to add four more backslashes before the % character:

Parameters=Command="(print \\"\\\\\\\\\\\\%\\")" Version="4"

(my head is now spinning)
Comment 12 Peter Sampson 2019-07-18 08:09:51 UTC
(In reply to James Crook from comment #11)
Testing on W10 with audacity-2.3.3-alpha-296-13348841c038bdd7614ae9e401ad0a419f7fb44a

This now works properly on Windows
Comment 13 Peter Sampson 2019-07-25 08:00:27 UTC
Testing on macOS 10.14.5 with mac 2.3.3 alpha jc004 of 25Jul19

Now works properly on Mac too
Comment 14 Steve Daulton 2019-08-09 10:19:57 UTC
Working correctly on Linux.

Peter wrote in #13 that it was working correctly on Mac, so closing as fixed.