Elementary question, include files

Can I put frequently used functions in a common file that is included by my custom analyzers and effects?

If it is for your own use only, then yes, you can add your own functions to nyquist.lsp or dspprims.ny.
dspprims.ny is used for “DSP primitives”, so that would be a good place to put any signal processing functions.
Or you can create a new file for your functions (and/or macros), give it a .lsp extension and list the file in nyinit.lsp

Example for adding an included file in nyinit.lsp

(load "myfunctions.lsp" :verbose NIL)

There isn’t a convenient way of adding “includes” in plug-ins for distribution - they really need to be self contained in one file. (There are some “hacks” that can be done, but it’s tricky getting it to work reliably cross-platform).

I will likely put the tricks for finding zero crossings that others have suggested, in there.

Do you use a text editor that supports “snippets”? This can be useful for quickly pasting commonly used bits of code into your plug-ins.

The init.lsp file is recommended for this Task:

; init.lsp -- default Nyquist startup file
(load "nyinit.lsp" :verbose nil)

; add your customizations here:
;    e.g. (setf *default-sf-dir* "...")
; (load "test.lsp")

It works for me if my extra stuff is in an .lsp file in Plug-Ins, and my .ny file loads the .lsp file by name (no folder path needed). The .lsp file has no effect on the generate, analyze, or effect menus. Why is this not an approved procedure for distributed plug-ins?

Could you give an example of exactly how you are doing that.

On Windows 7, my .ny files live at
C:Program Files (x86)AudacityPlug-Ins
I simply drop a .lsp file in the same folder, then my .ny files can say

(load "Zero Crossings.lsp")

So what’s the catch?

and then what? You can use functions in your .ny file that are defined in your .lsp files?

Yes. Is that surprising?

I put the load statement after all ;control comments.

Yes, because I’ve tried it on XP and on Linux and it does not work. The functions are not found.
I’m also surprised that they are found in Windows 7 as I previously thought that “includes” needed to be included when Nyquist launched rather than at the plug-in run time.

I do it in a similar way. But I put the files into the Nyquist Folder.
They are not found in the Plug-Ins Folder.
But I use those files anyway only in the Nyquist prompt.

And for no apparent reason this seemed to quit working today and now I must write global paths… weird.