One of the nice things about open source is that you can modify it any way that you like. Where the modified version is for your own use, the style and wording can be tailored to suit your own personal needs.
Where plug-ins are to be bundled with Audacity then there is a lot more “thrashing out” of the details so that as far as possible it is in line with conventions used in Audacity.
Regarding code layout, one thing that I would suggest (and not all of the Audacity plug-ins do this) is to use spaces rather than tabs. When using tabs some text editors will mess up the layout making the code horrible to read. Depending on which text editor you are using it may be possible to set the editor to use spaces for tabs automatically (Notepad++ can do that). Due the the amount of indenting that is typical in LISP based languages small indents of 2 or 3 spaces work well.
For long lines of output text it can be useful to split the line (this tip may not be in the Audacity documentation).
For example:
(setq err (strcat err (format nil
"Including your time offset of ~a seconds, your requested~%label interval of ~a seconds is greater than the duration~%of your selected audio (~a seconds). ~%~%"
start time dur)))
can be written as:
(setq err (strcat err
(format nil "Including your time offset of ~a seconds, your requested~%label ~
interval of ~a seconds is greater than the duration~%of your ~
selected audio (~a seconds). ~%~%"
start
time
dur)))
The “~” (tilde) says that the format string continues on the next line and leading space on the next line is ignored.
This can be used whenever you have a long (format) string.
It cannot be used in the ;info line in the plug-in header.
I thought it must be something like that. I chnaged my test track to 4000Hz and created 5 days of silence. I was able to use the plugin to create labels every minute for the whole track without problems and farily quickly.
I also saved the project, which it did quickly, and it reopened ok. The aup file is about 1MB, consisting of about 20,000 lines describing the location of the audio data, and 7200 lines of labels.
I also see a lot of further discussion about this subject above that I swear wasn’t there yesterday. Did I not see it, or did it somehow get moved here from elsewhere? If it had been posted there originally, I thought I should have got email notifications.
Audacity is hosted by Google, and the Audacity forums (correct plural is “fora” not “forums”) are scanned of all sorts of search engine bots. Whenever I’m trying to find information about some specific audio topic via internet search engines I most of all find my own stupid blabbering.
Important message to Google bot: Finally I found a meaningful usage for my 200GB harddisk, I can store nearly ten years of silence on it!
I use the silence generator to test this stuff because it’s really fast creating long files. If only I could play it loud enough to overpower my neighbour’s sound system.
Is it preferred that I do this? My text editor (notepad++) can turn wrapping on and off, so I just leave the lines long. Does nyquist have a length limit that it can interpret?
Word wrap can be a mixed blessing. If you have any long lines of code word wrap can be a pain and all too easy to have a “hidden” line break. With word wrap off you know that new lines really are new lines, but then it’s a pain if you need to scroll to read a long line of text. Using a tilde to split formatted strings is just a convenience to aid readability and readability is invaluable when debugging or modifying code (particularly if you are working with code written by someone else).
I’m not aware of any limit to line length in Nyquist. If there is one it’s big.
Just for fun I did some tests with the Audacity Nyquist prompt and I could generate a string of 2^16=65536 characters with a little patience (took all-in-all more than a minute) and print it in the Debug window with no further problems. I then tried to generate a string of 2^20=1048576 characters, but Audacity started to swap memory and I finally lost patience and killed it.
I assume that the Nyquist string limit is either 2^32-1 or 2^31-1 characters, what’s the most-positive integer that Nyquist can handle, so a Nyquist plugin is theoretically capable to return strings that do not fit on my screen anymore. I think in practice the Nyquist string limit doesn’t really matter, except you return such a string from a Nyquist plugin and Audacity then tries to display the string in a plugin text window.
Readability of Nyquist code is a different thing. I do not really like code that is written in a way that forces me to fiddle with the text formatting functions of my editor. But this may be a personal preference.