Lists as data type for Plugin "Control" parameter?

I can’t find where it says this now, but I seem to recall reading that only “int” and “float” (and perhaps strings?) are valid as inputs to “;control” headers when using/designing a Nyquist Plugin–in my case a “Generate” one. Is that, in fact, correct?

I suppose a cheap hack is to give several separate control arguments like item1, item2, item3 etc, but just want to confirm that an arbitrary number of arguments can’t be given. If this is indeed the case, is it possible to change this in the future, i.e. is this a valid feature request? :slight_smile:

Happy to clarify my question by illustrating my use case, if that helps.

And, fantastic to see this much activity on this subforum!


Ps. Much thanks to the developers of the Nyquist Generate Prompt! I think I might add to the warning about "format specifiers"here on the wiki that stray semi-colons (say, copied in by accident from lines of code that had comments had the end) will, I believe, produce EOF errors that are similarly hard to debug :}

The ;control headers are not really specifying “data types”, though they do affect the data type of the input.

In brief,

  • Nyquist is an interpreted language.
  • The Nyquist interpreter and runtime have been shoehorned into Audacity.
  • Nyquist does not have any built-in support for graphical interfaces.
  • In Nyquist, the semicolon character indicates the start of a comment.

So as far as Nyquist is concerned, all of the “header” lines are just comments, and are ignored.
However, Audacity scans the Nyquist scripts and looks for lines beginning with a semicolon. If found, Audacity checks to see if the line conforms to a valid header.

So, a line such as:

;command var "Left text" float "Right text" 5 0 10

is an instruction to Audacity (not Nyquist), to tell Audacity to create a gui widget. The keyword “float” in this instance, tells Audacity to create widget with a numeric text entry box and a linked slider.
When the plug-in runs, Audacity assigns the specified value to variable “var”, and passes that to Nyquist.
In this case, “var” will be a floating point value because it came from a floating point widget.

The documentation here lists the available widgets:

In the current 2.3.0 version of Audacity, there is an additional widget type which is not yet documented. This is a button that launches a file browser, and returns a file path as a string. See this post for details:

A list may be passed to Nyquist as a string. For example, to pass a list of number (for a public plug-in, you should validate the input, but here I’ll just demonstrate the list)…

;version 4
;type tool

;; IMPORTANT: Requires Audacity 2.3.0 (or later)

;control numbers "Space separated list of numbers" string "(numbers only)" "4  6.2  101"

(setf list-string (format nil "(list ~a)" numbers))
(setf mylist (eval-string list-string))

;; test it
(setf result 0)
(dolist (item mylist)
  (setf result (+ result item)))

(format nil "The sum of number in the list is ~a" result)

With Audacity 2.3.0, the Nyquist Generate Prompt has become redundant. You can just use the Nyquist Prompt (now in the new “Tools” menu, and add the header:

;type generate

Wow, thanks for all that, Steve! I look forward to processing and digging into all that detail.

The “string to list” trick is neat (and I’ve never seen “eval-string” before, but it seems like a little “Code is Data” Lisp magic).

However, running that whole block of code, which perhaps I’m doing in a clumsy way (from the Nyquist Prompt in the Tools menu, now–thanks for alerting me to the obsolescence of the Generate Prompt plug-in) returns simply

(list 4 6.2 101)

from a Nyquist Worker pop-up, i.e. just the result of evaluating the first expression that assigns “list-string” to the result of the format block. With a bit of commenting out, I can only guess that this first expression alone is the only one being processed?

I’m running Audacity 2.3.0-alpha-Sep 7 2018, which I compiled myself–perhaps I should update? Please let me know if you have any thoughts!

I’ll also try figuring it out using NyquistIDE in the meantime. Thanks again :slight_smile:

“eval-string” is very new and not yet documented, except for in the code:

Audacity 2.3.0 release version is now out Audacity ® | Download for Mac OS