Nyquist macro fails to run audacity macro with built-in nyquist macro

Trying my first steps with Nyquist I tried to run the build-in rhythmtrack.ny using the audacity macro function (aud-do):

;nyquist plug-in
;version 4
;type tool generate
;name "MyTest"

(aud-do "RhythmTrack:bars=\"33\" click-track-dur=\"0\" click-type=\"Metronome\" high=\"84\" low=\"80\" offset=\"0\" swing=\"0\" tempo=\"120\" timesig=\"4\" ")

Unfortunately it always returns an empty audio-track. I tried also the code without " but failed as well. When I include the source code of rhythmtrack.ny in my macro it works as expected. But as soon as I add a further line at the end with an aud-do command the new created audio track is empty again.

Any suggestions what I’m doing wrong or missing?

Nyquist plug-ins are not “reentrant”, which means that you can’t call a new Nyquist process from within Nyquist.

The Rhythm Track plug-in is a Nyquist plug-in, so (because Nyquist plug-ins are not reentrant) you can’t call it from within Nyquist.

From the “Pros and Cons” section of this page: Nyquist-Macros - Audacity Manual

Macros may include any built-in or plugin effects, but Nyquist-Macros cannot use Nyquist effects.

Thanks for this quick and clear answer. So, I will insert the Nyquist source code of rhythmtrack.ny in my macro and try to include further code to solve my little project.

That’s one option.

Depending on what you are doing, another option might be to use a (normal) macro to tie together your new Nyquist code and other plug-ins.

If you need to pass parameters from the new code to the existing plug-in, you could modify the existing plug-in to read values from SCRATCH (see: Missing features - Audacity Support). For example, if the plug-in has a “value” parameter that is set by a ;control

;control value "Enter a value between 0 and 10" int "" 5 0 10

Then you could modify that to something like:

;control value "Enter a value between 0 and 10" int "" 5 0 10

(if (get '*scratch* 'value)
    (setf value (get '*scratch* 'value)))

and in your new Nyquist code you would PUTPROP the required VALUE onto SCRATCH.

Thanks again for this hint, which is a smarter way to move information from one nyquist macro to another as I have done right now. As a newbie to nyquist I did’nt know about that and I will try to use it.
Up to now I create a rythmtrack with 132 beats in my first nyquist-macro and added in the second macro a Label track using regular intervall labels, to get vertical lines on every beat of my instrument records when I move around with my mouse (playing american oldtime music with my banjo). For the second nyquist macro I needed the bpm number selected in my first macro. I calculated bpm in my second macro by using the length of my selected audio clip (that starts at 0) knowing that I had a fixed number of 132 beats given:

(setf end (get '*selection* 'end))
(setf bpm (* (/ 60.0 end) 132.0))

That worked well for me, but I was thinking about how to move more information from first to second nyquist macro to split the metronome audio track at several measures (oldtime music consist mostly of an A and B part with 8 measures each and repeated once (plus 4 beat for intro)).

Most likely, adding ‘properties’ to SCRATCH is the way to go.

Note (1) that the value of a property may be almost anything; a number, a string, a list, an array, …

Note (2) that any data added to the scratch property list will remain in memory until Audacity is closed, or until you remove the property. It’s best practice to ensure that plug-ins / macros clean up after themselves, so you should ensure that the plug-in / macro removes the data after it has been used.