So, I wanted to create a script to generate tones for embedded µCU to use and getting way too fanatical about getting it done “properly” it as usual. There would’ve been easier ways to do this, but I got annoyed I didn’t get “mixing two frequencies creates their sum and difference” as expected and things went downhill from there. I digress.
If I run this without a track present, it crashes. According to documentation it should instead create a new track with the generated audio?
Okay, I decided to be clever and create a track, this must work, surely? Nope. Adding this after header creates two audio tracks and selects the second one, which is not quite what I expected. Also crashes.
What does work is the 1st version if you make a new mono track and select it. If you have a track selected with the second version, it doesn’t crash, but neither do you get the expected output.
TIL to hate LISP. SAL I learned to hate a bit less.
Macro scripting commands should not be mixed with Nyquist commands that modify the project.
Nyquist is a separate application from Audacity. When a Nyquist plug-in is launched, a “snapshot” of project properties is taken and passed to Nyquist. This snapshot includes the “property lists” documented here: Nyquist Plug-ins Reference - Audacity Wiki
AUD-DO Macro commands can modify project properties (in this case the Project Rate may be modified) but Nyquist cannot track these changes, so there can be a mismatch between current project properties and the project properties that were passed to Nyquist in the “snapshot”.
Nyquist only knows about the project properties that were passed when the project was launched, and is not able to access the project after being launched.
There appears to be another bug as well. I’ll investigate further…
I can confirm this behaviour, without the control window, it crashes. Win11, ver 3.74 from yesterday if I’m reading that right.
Program build date:
Mar 13 2025
Commit Id:
6d5dff of Thu Mar 13 13:55:02 2025 +0300
Build type:
CMake Release build (debug level 1), 64 bits
Compiler:
MSVC 19.43.34808.00
As far as modifying the samplerate goes, the project rate appears to take effect after the new track is created with the 44.1kHz rate, so that’s not a workable idea. Does Nyquist adjust its internal samplerate to the project rate automagically or it does extra resampling if they don’t match?
It’s useful to have the SAL version of aud-do call for posterity here, though, I’ve seen only LISP version of it.
Eh. My script has aud-do in a SAL script. Works too with an example of how to do parameter strings.
It’s interesting how almost all google searches come up with just LISP, it’s so much easier to do things with SAL. Pretty much the only major gotcha is the need to separate operators with spaces, that’ll trip you up easily.
I misunderstood what you meant. Yes you can send Macro commands as “magic strings” (as you have done).
SAL is a relatively recent addition to Nyquist. Nyquist was shoehorned into Audacity years before SAL existed. I started documenting Audacity’s implementation of Nyquist using LISP syntax when LISP was the only option. Some of the later documentation included SAL syntax, but no new documentation has been added since Muse Group took over.
Personally I prefer the LISP syntax, which is probably mostly because I first started with Nyquist before SAL existed. The SAL interpreter was added by Rodger Dannenberg to the standalone version of Nyquist to make Nyquist feel more familiar to students that are used to C-like syntax. SAL provides a “translation” from the C-like syntax to LISP, which is then passed to the Nyquist interpreter in the normal way. The LISP syntax is “native” to the Nyquist language. I think there may still be a few corners of the language that are not available to SAL.
Details about the relationship between the two syntaxes are described in the Nyquist manual: SAL