Preface: Please do not read this as part of another endless series of lamentations, I already have solutions for all these things on store, but would first like to ask here in the forum before I send patches to the Audacity developers list. Only to prevent misunderstandings, I’m talking about the text input widget of the Audacity Nyquist user interface that appears if a Nyquist plugin header contains a line like:
;control <variable-name> "text-left" string "text-right" "initial-string"
Known problems with the current implementation of the Adacity text input widget:
Single backslashes will not be doubled, so the Audacity user [who is usually not a Lisp programmer] has to type double-backslashes in the input field of the text widget in the Audacity Nyquist interface or will inadvertibly run into trouble:
Audacity text widget Lisp string
c:\programs\audacity => "c:\programs\audacity" ; works but needs double-backslashes
c:programsaudacity => "c:programsaudacity" ; bad
c:programsaudacity => error: unexpected end of file ; even worse :(
Double-quotes are converted to single-quotes by the Audacity Nyquist interface, what is a pretty idiotic idea, because the Lisp single-quote read-macro serves the purpose to prevent evaluation:
Audacity text widget Lisp string
"hello" => "'hello'" ; what a nonsense
Suggested solutions:
With my Audacity 1.3.13-alpha version at home I have modified the C/C++ code of the Audacity Nyquist interface.
Backslashes now automatically get doubled and double-quotes automatically get quoted:
Audacity text widget Lisp string
c:programsaudacity => "c:\programs\audacity" ; backslashes automatically get doubled
c:programsaudacity => "c:\programs\audacity\" ; backslashes do not cause Lisp errors anymore
"hello" => ""hello"" ; double-quotes are quoted and retained, so the
non"sense"example => "non"sense"example" ; Lisp string reflects the original user input
The modification of the C/C++ code is pretty simple. In case you want to try it yourself, here is what I did.
In the file “src/effects/Nyquist.cpp” in the function “EffectNyquist::ProcessOne()”, around line 650, you’ll find the following code fragment:
else if (mControls[j].type == NYQ_CTRL_STRING) {
wxString str = mControls[j].valStr;
str.Replace(wxT("""), wxT("'")); // <- replace this line with the two lines below
cmd += wxString::Format(wxT("(setf %s "%s")n"),
mControls[j].var.c_str(),
str.c_str());
}
Here is the modified version:
else if (mControls[j].type == NYQ_CTRL_STRING) {
wxString str = mControls[j].valStr;
str.Replace(wxT("\"), wxT("\\")); // <- double all backslashes
str.Replace(wxT("""), wxT("\"")); // <- quote all double-quotes
cmd += wxString::Format(wxT("(setf %s "%s")n"),
mControls[j].var.c_str(),
str.c_str());
}
The remaining question is: Are there more problems known or do I have forgotten something?
Thanks - edgar