All credit to you for having a go
Yes, it’s a bit tricky.
Firstly, the difference between (aud-do “GetInfo: …”) and (aud-get-info …)
;type tool
(setf info (aud-do "GetInfo: Type=Tracks Format=LISP"))
(print info)
In the Debug window, that will print something like:
("(((name "Audio Track") (focused 1) (selected 1) (kind "wave") (start 0) (end 30) (pan 0) (gain 1) (channels 1) (solo 0) (mute 0) (VZoomMin -1) (VZoomMax 1)))" . T)
Observe the double quotes.
(aud-do “GetInfo: …”) returns a dotted list with two elements:
("a long string value that looks like a list" . T)
“GetInfo” was initially designed to return JSON data for Python scripting, where JSON is a way of encoding JavaScript data as a string.
The “Format=LISP” argument tells Audacity to format the JSON data in a way that is easier for Nyquist to handle (Nyquist does not directly support JSON).
The important thing here is that although the first part of the list “looks” like a LISP list, it is actually just a string (“text”).
;type tool
(setf info (aud-do "GetInfo: Type=Tracks Format=LISP"))
(print info)
(if (stringp (car info)) ;ist the first part of 'info' a string?
"Yes it's a string"
"No it is not a string")
;; Returns "Yes it's a string".
Now try (aud-get-info …)
;type tool
(setf info (aud-get-info "tracks"))
(print info)
returns something like:
(((NAME "Audio Track") (FOCUSED 1) (SELECTED 1) (KIND "wave") (START 0) (END 30) (PAN 0) (GAIN 1) (CHANNELS 1) (SOLO 0) (MUTE 0) (VZOOMMIN -1) (VZOOMMAX 1)))
“AUD-GET-INFO” is a wrapper around “AUD-DO” that parses the returned string and evaluates it as a LISP expression.
Using aud-get-info with two tracks:
(((NAME "Audio Track") (FOCUSED 1) (SELECTED 1) (KIND "wave") (START 0) (END 30) (PAN 0) (GAIN 1) (CHANNELS 1) (SOLO 0) (MUTE 0) (VZOOMMIN -1) (VZOOMMAX 1)) ((NAME "Audio Track") (FOCUSED 0) (SELECTED 1) (KIND "wave") (START 0) (END 30) (PAN 0) (GAIN 1) (CHANNELS 1) (SOLO 0) (MUTE 0) (VZOOMMIN -1) (VZOOMMAX 1)))
It’s a bit tricky to see, but if we reformat that we can see:
((<fist-strack-info>) (<second-track-info))
Where is comprised of a list of 2 element lists:
(list (symbol1 value1) (symbol2 value2)…)
This post is already quite long, so I’ll end here and write a new post about how to handle the lists returned by “AUD-GET-INFO”.