getting access to change pitch techinque

Hi,
The built-in effect Change Pitch is different than the Nyquist primitive of the same function.
I want to use the superior functionality of the built-in effect inside of one of my Self Made Plugins.
But I don’t want to use the Macro function method afforded under the Audacity Tools Tab.
(that is mainly because one cannot use the same Built In Effect with two different settings…)

  1. How do I find the coding for that Built-In effect inside the Audacity stuff.
  2. What language is it written in?
  3. Is there a way for a nyquist plugin that I write ~ to invoke a Built-In effect, along with the parameters I chose for that instance of use?

Thanks for being there for these sort of questions.
Dalagar

Nyquist plug-ins are written in the “Nyquist” programming language (an extended version of XLisp).

Audacity’s built-in effects are written in C++.

The code for Audacity’s Change Pitch effect is here:
https://github.com/audacity/audacity/blob/master/src/effects/ChangePitch.cpp
https://github.com/audacity/audacity/blob/master/src/effects/ChangePitch.h
Note that the built-in effect has a lot of dependencies, including WxWidgets and time-stretch libraries. It is an integral part of Audacity and can’t be used as a standalone effect.

Nyquist is able to access Audacity’s built-in effects using the syntax:

(aud-do  <scripting-command>)

where “” is one of: https://manual.audacityteam.org/man/scripting_reference.html
Note that these are the same commands used by Audacity’s “Macros”.

A Nyquist plug-in that uses Audacity’s scripting/macro commands is called a “Nyquist Macro”.
Nyquist Macros, including some examples, are documented here: https://manual.audacityteam.org/man/nyquist_macros.html

Note that a Nyquist plug-in may directly modify a project (“pure” Nyquist) or modify the project with macro/scripting commands. It is NOT possible to do both in the same plug-in. If you need to do both, then you could create multiple plug-ins and combine them using a normal Audacity macro to run them in sequence.

Thanks, Steve
I have got that to work in my Nyquist plugin.
But upon completion of the ChangePitch task, my Nyquist program terminates.
I was hoping to be able to imbed the AUD-DO into my program and then to be able to process the result.
I was even hoping to be able to call that function again from the same program multiple times.
Is there some way to use the AUD-DO and then have control return to the rest of my program.

Dalagar

As I wrote recently:

Nyquist can only access audio that is selected at the time that the effect is launched.

and

So it is possible to continue processing the results with other macro scripting commands, but not directly with Nyquist.

Say you have one selected track in the project. When you launch the Nyquist plug-in, Audacity sends a pointer to the selected audio to Nyquist.
Now say that you apply “Change Pitch” using AUD-DO. The selected audio is then modified and the original audio no longer exists in the project. Nyquist has a pointer to the original audio (which no longer exist), but not to the new (pitch changed) audio. Nyquist doesn’t even know that the new audio exists because it only knows about the project as it was when the plug-in was launched.

Example:
This will work

;type tool
(aud-do "SelectAll")
(aud-do "ChangePitch:Percentage=100 SBSMS=0")
(aud-do "Amplify:Ratio=0.8")
""

but this won’t

;type tool
(aud-do "SelectAll")
(aud-do "ChangePitch:Percentage=100 SBSMS=0")
(mult *track* 0.8)

Thanks, Steve
I understand that limitation.
So now I want to add a command at the bottom of the list
(aud-do “ExportasWave: Filename=c:\AudibleScratch\testsecond.wav”)
How do I correct the syntax of the above to make it work?
I tried many versions and none of them work
Thanks,
~Dalagar

To export to a specified location, use “Export2:”
See: Scripting Reference - Audacity Manual

Unfortunately Bill Gates had the stupid idea of using the backslash (“") character as the file path separator, but that same character is also used as the “escape character” in strings. In short, the file-path “c:\AudibleScratch\testsecond.wav” probably won’t work.
I’m not able to test right now (I’m on Linux, not Windows), but you will probably need to use either forward slashes (”/“) or double backslashes (”\") as the file-path delimiter.

Note that the file name should be quoted, and quotes within a string need to be escaped with a backslash.

Example:

(aud-do "Export2: Filename=\"c:/AudibleScratch/testsecond.wav\" NumChannels=2")