Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't disable *TRACK* in ";type tool" plugins #3907

Open
SteveDaulton opened this issue Nov 9, 2022 · 0 comments
Open

Don't disable *TRACK* in ";type tool" plugins #3907

SteveDaulton opened this issue Nov 9, 2022 · 0 comments
Labels
Enhancement Request Or feature requests. Open-ended requests are better suited for discussions. macros / scripting Bugs related to macros and scripts

Comments

@SteveDaulton
Copy link
Member

Your idea

If a Nyquist script / plugin has the header:
;type tool
then the variable TRACK is disabled by Audacity.

Although TRACK only represents a snapshot of the selected audio at the time that the Nyquist script is launched, it can still be very useful. Working around the absence of TRACK can be very complicated.

Problem to be solved

It is often much easier to get information about the initial state of a project by using the properties of TRACK than by other means, but often it is necessary to use complicated "other means" just to work around this restriction.

Example:
To split a selected track exactly in half.
This code would work if TRACK was available in a ;type tool plugin:

;type tool
(let* ((start (get '*track* 'start-time))
       (end (get '*track* 'end-time))
       (mid (/ (- end start) 2.0)))
  (aud-do-command "SelectTime:"
                  :start mid
                  :end mid
                  :relativeto "SelectionStart")
  "")

but because TRACK is disabled, it's necessary to use two Nyquist scripts plus two additional scripting commands, wrapped up in a macro:
(scroll the code block to see the full code)

SelTrackStartToEnd:
NyquistPrompt:Command=";type analyze\n(setf *scratch* (list (get '*track* 'start-time)\n                     (get '*track* 'end-time)))\n\"\"" Parameters=""
SelTrackStartToEnd:
NyquistPrompt:Command=";type tool\n(let ((mid (/ (- (second *scratch*) (first *scratch*)) 2.0)))\n   (setf *scratch* '*unbound*)\n   (aud-do-command \"SelectTime:\"\n                   :start mid\n                   :end mid\n                   :relativeto \"SelectionStart\")\n   (aud-do \"Split:\")\n   \"\")" Parameters=""

Prior art

No response

Additional context

No response

@SteveDaulton SteveDaulton added the Enhancement Request Or feature requests. Open-ended requests are better suited for discussions. label Nov 9, 2022
@LWinterberg LWinterberg added the macros / scripting Bugs related to macros and scripts label Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Request Or feature requests. Open-ended requests are better suited for discussions. macros / scripting Bugs related to macros and scripts
Projects
Status: Out of scope - technical
Development

No branches or pull requests

2 participants