How to specify a list of timepoints for a plugin to operate on?

Using Nyquist scripts in Audacity.
Post and download new plug-ins.
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
steve
Site Admin
Posts: 81900
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: How to specify a list of timepoints for a plugin to operate on?

Post by steve » Wed Jun 16, 2021 11:49 am

Debian Testing (bullseye) and Debian Sid both have Audacity 2.4.2.
Audacity 2.4.2 will be new enough for this.

I do not currently recommend Flatpak, Snap, or AppImage packages, as we are still receiving reports of problems with them.

For the latest Audacity release, the best way to get it is to build from source code. The build process has recently been updated, which makes it pretty easy for anyone that has experience building from source. If you don't have any experience building from source, then I'd recommend Audacity 2.4.2.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

kjo
Posts: 9
Joined: Mon Jun 14, 2021 5:31 pm
Operating System: Linux Debian

Re: How to specify a list of timepoints for a plugin to operate on?

Post by kjo » Thu Jun 17, 2021 11:25 pm

OK, sorry for the delay!

I finally managed to perform the test you posted earlier.

Result: After I clicked on the Debug button, a dialog titled "Nyquist Prompt" popped up with the message "Nyquist returned a list" followed by an "OK" button. After I clicked on this button, another window titled "Nyquist Prompt" popped up, showing the list below:

Code: Select all

((1 ((1.11038 1.11038 "") (2.24923 2.24923 "") (3.58738 3.58738 "") (4.92554 4.92554 "") (6.1498 6.1498 "") (7.54489 7.54489 "") (8.85457 8.85457 "") (9.93648 9.93648 "") (11.5878 11.5878 "") (12.8121 12.8121 "") (13.894 13.894 ""))))
Below are the specs for the system I'm doing this on.

Code: Select all

% uname -srvmpio
Linux 4.19.0-16-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 unknown unknown GNU/Linux

% lsb_release --all
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 10 (buster)
Release:	10
Codename:	buster

% dpkg-query --list audacity
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version       Architecture Description
+++-==============-=============-============-=================================
ii  audacity       2.4.2~dfsg0-4 amd64        fast, cross-platform audio editor
NB: installing Audacity 2.4.2 on my primary (Debian stable) system would have required installing way too many non-stable dependency packages on it, more than I was comfortable with, so instead I installed Audacity 2.4.2 on a VirtualBox VM (also running Debian stable, but with the non-stable dependencies required by Audacity 2.4.2). My question is: if I use the 2.4.2 version of Audacity on this VM to develop the plugin, would I then be able run this plugin on the Audacity 2.2.2 installed on my primary system?

steve
Site Admin
Posts: 81900
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: How to specify a list of timepoints for a plugin to operate on?

Post by steve » Fri Jun 18, 2021 7:21 am

kjo wrote:
Thu Jun 17, 2021 11:25 pm
Result: After I clicked on the Debug button, a dialog titled "Nyquist Prompt" popped up with the message "Nyquist returned a list" followed by an "OK" button. After I clicked on this button, another window titled "Nyquist Prompt" popped up, showing the list below:

Code: Select all

((1 ((1.11038 1.11038 "") (2.24923 2.24923 "") (3.58738 3.58738 "") (4.92554 4.92554 "") (6.1498 6.1498 "") (7.54489 7.54489 "") (8.85457 8.85457 "") (9.93648 9.93648 "") (11.5878 11.5878 "") (12.8121 12.8121 "") (13.894 13.894 ""))))
Super. That's the expected result.

What happens in Audacity 2.2.2?
I'm expecting it will give an error.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

kjo
Posts: 9
Joined: Mon Jun 14, 2021 5:31 pm
Operating System: Linux Debian

Re: How to specify a list of timepoints for a plugin to operate on?

Post by kjo » Fri Jun 18, 2021 1:46 pm

@Steve: I got so caught up with getting Audacity v 2.4.2 installed, that I forgot the pointer you gave me on where to find the Nyquist Prompt on v. 2.2.2!

On v 2.2.2, after I click on Debug, an alert dialog (titled Nyquist Prompt) pops up with the following error message:

Code: Select all

Debug Output:

error: unbound function - AUD-GET-INFO
if continued: try evaluating symbol again
1> 

...followed by an "OK" button.

I think I should be able to use the Audacity 2.4.2 installed in the VM I mentioned in my previous message.

steve
Site Admin
Posts: 81900
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: How to specify a list of timepoints for a plugin to operate on?

Post by steve » Fri Jun 18, 2021 1:58 pm

kjo wrote:
Fri Jun 18, 2021 1:46 pm

Code: Select all

error: unbound function - AUD-GET-INFO
That shows that the command is not implemented in Audacity 2.2.2, so to answer your previous question ...
kjo wrote:
Thu Jun 17, 2021 11:25 pm
I use the 2.4.2 version of Audacity on this VM to develop the plugin, would I then be able run this plugin on the Audacity 2.2.2 installed on my primary system?
No, you would not be able to use it in 2.2.2 because the "AUD-GET-INFO" command does not exist in 2.2.2.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

steve
Site Admin
Posts: 81900
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: How to specify a list of timepoints for a plugin to operate on?

Post by steve » Fri Jun 18, 2021 2:25 pm

Back on topic:

As we have seen in:

Code: Select all

;version 4
(print (aud-get-info "Labels"))
(aud-get-info "Labels") returns a nested list of labels.

Say you have two label tracks.
labels.png
labels.png (8.35 KiB) Viewed 1159 times
and (print (aud-get-info "Labels")) returns:

Code: Select all

((0 ((1 1 "A") (5 5 "2"))) (1 ((2 4 "C"))))
The outer list contains two lists, one per track:

Code: Select all

(0 ((1 1 "A") (5 5 "2")))
and

Code: Select all

(1 ((2 4 "C")))
The "0" as the first element of the first list indicates that this is "track zero" (the topmost track in the project)
The "1" as the first element of the second list indicates that this is "track 1" (the second track in the project).

Looking at the first list:
The second element is a list containing the labels:

Code: Select all

((1 1 "A") (5 5 "2"))) (1 ((2 4 "C"))
Each label has a start time, an end time, and the label text,
so the first label:
  • start time = 1
  • end time = 1
  • Label text = "A"
If we are interested in the first label track only, then:

Code: Select all

(setf all-label-tracks (aud-get-info "Labels"))
(print all-label-tracks)
;prints: ((0 ((1 1 "A") (5 5 "2"))) (1 ((2 4 "C"))))

(setf first-label-track (first all-label-tracks))
(print first-label-track)
;prints: (0 ((1 1 "A") (5 5 "2")))

;; Print the track index of the first label track
(print (first first-label-track))
;prints: 0

;; Print the list of labels from the first label track
(setf labels-in-first-track (second first-label-track))
(print labels-in-first-track)
;prints: ((1 1 "A") (5 5 "2"))

;; Print each label from the first label track
(dolist (label labels-in-first-track)
  (print label))
;prints:
; (1 1 "A")
; (5 5 "2")

Putting that all together, we can print to the debug window:

Code: Select all

(let ((first-track-labels (second (first (aud-get-info "Labels")))))
  (dolist (label first-track-labels)
    (format t "Start: ~a  End: ~a  Text: ~s~%"
            (first label)
            (second label)
            (third label)))
  "See Debug window")

which gives this output in the debug window:

Code: Select all

Start: 1  End: 1  Text: "A"
Start: 5  End: 5  Text: "2"

9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

kjo
Posts: 9
Joined: Mon Jun 14, 2021 5:31 pm
Operating System: Linux Debian

Re: How to specify a list of timepoints for a plugin to operate on?

Post by kjo » Sat Jun 19, 2021 1:06 am

@Steve: Thank you much! I will be studying your code for some time. I thought I had enough experience with LISP-like languages, but your code has features I had never seen before (notably the dolist form)...

Post Reply