Appending batch calculated plugin data to file or text window

I’ve written a macro that calls a mildly modified Nyquist plugin. The output from the plugin is an SNR value for a sound file.

I’d like to be able to batch calculate SNR values for number of sound files in a file folder, but see no way of appending the calculated SNR data to…well, anything really.

If batch calculated SNR values and corresponding file names were all appended to one and the same text window, that would be a solution. During batch processing each file generates a single window where an individual calculated SNR value is presented, and the window shuts before processing continues with the next file, so no.

Appending successive file names and corresponding calculated SNR values to a text file would do it, but Nyquist cannot write to text files from inside Audacity.

I thought appending calculated SNR values to labels in a label track would help, but the label track seems to be deleted at the end of batch calculation.

Appending the calculated weighted SNR value for each file to the name of the file and then saving the file would do it, but Nyquist isn’t allowed to modify file names.

How do I go about acheiving batch calculating SNR values for number of sound files? I presently handle this file by file, manually adding each calculated SNR value to the metadata of each file.

A presentation of the intended application for the macro and an associated Plugin can be found at The macro and the associated Plugin can be downloaded from the same site.

I use Windows 10.

This may be true - I am not a Nyquist expert - but see this post: How to use system(), where is it documented? - #6 by steve

“Sample Data Export” is an example of a Nyquist plug-in that writes a text file.
See: \" (_ \"Sample Data Export\") \"

Heureka! The problem was that Nyquist allows writing only to certain folders, so C:/ seems to be prohibited.

I tried this, and it generates a .txt file named like the sound file name. I tried calling this from a macro and the batch process a number of files, but it outputs pnly one .txt file name like the first (or last?) .wav file in the batch of files. If I only got that right, I could get batch processing started. Why doesn’t this (called from a macro) generate a number of .txt files, each named as the corresponding .wav file?

(setf track-name (get 'TRACK 'NAME))
(setf adress (strcat “C:/Users/ulfel/Documents/Audacity/macro-output/” track-name “test” “1” “.txt”))
(setf myfile adress)
(setf fp (open myfile :direction :output))
(format fp track-name)
(format fp " testing")
(close fp)

Nothing should write to C:/ without administrative permissions.

A better way to write that line is with the FORMAT command, using “~a” as placeholdera for the variablea:

(setf myfile (format nil "C:/Users/ulfel/Documents/Audacity/macro-output/~a test~a.txt" track-name 1))

Because your script returns “NIL”, which Audacity sees as an error.
As you don’t actually want to return anything from Nyquist, add an empty string (two double quotes) to the end of the script, Audacity treats an empty string as a no-op (“no operation” = “do nothing”)

(setf track-name (get '*TRACK* 'NAME))
(setf myfile
   (format nil "C:/Users/ulfel/Documents/Audacity/macro-output/~a test~a.txt"
           track-name 1))
(setf fp (open myfile :direction :output))
(format fp track-name)
(format fp " testing")
(close fp)

I would never ever, ever, ever, ever, ever have figured that out, thank you Steve!

Tried it and it generates a set of file, with file names as requested.