If I make a selection in a track dragging from left to right is it possible to change the selection from right to left from where the selection starts or left to right from where the selection ends? Could I do this with two different macros?
Selections may be adjusted using “Shift + Click and Drag”:
1.Make a selection (Click and drag) and release the mouse button.
2. Move the mouse pointer near to the start or end of the selection - whichever you want to adjust - no need to be exact.
3. Press and hold the Shift key
4. While holding down the Shift key, Click and drag.
Thank you for your explanation. I didn’t realise you can hold down Shift to enable the hand to change a selection. Is it possible though to swap the selection to the left or right of the cursor? If I select a section of a track and make a change, I was wondering if I could run a macro so that I deselect the selection and I am able to drag in the opposite direction? At the moment, once I’ve selected and made a change, I need to click on the track to deselect and then make a new selection dragging in the opposite direction. Is it possible to create a macro so I don’t need that extra click so the selected area swaps to the right or left of the cursor?
If the pointer is close enough to the edge of the selection, then the Shift key is not required, but when holding down the shift key you don’t need to be so precise. Without the Shift key, if you are not close enough to the edge of the selection, the selection may be lost.
I’m not sure what you are asking for here. If I select, for example the audio between 4 and 5 seconds and amplify, then I can then drag the cursor between say 3 and 4 seconds without needing an extra click.
However, if you want to select the one second of audio prior to your current selection:
On the Extras Menu (View > Extras Menu) > Scriptables II > Select. Then you could specify Start Time = -1, and Relative to Selection Start. Be sure to check those items you want and deselect those you don’t want, as this is not done automatically for you.
For a macro, you would issue the Select command and specify the same parameters.
Thanks for the advice as always, Steve. I’ve had a look at the link you shared https://wiki.audacityteam.org/wiki/Nyquist_Plug-ins_Reference Could you clarify how I can make these two NYQUIST plug-ins using your commands? How do I make an .ny file and where do I find the Plug in widgets dialogue box?
Make that ;version 4 (all new plug-ins should be written in the latest version).
It is usual to have an empty line between the header and the code - that’s not required, but it helps readability to have a bit of space between blocks.
It is also recommended (but not required) to include:
;author (your name)
;copyright (the license, usually GPLv2+)
;release (a release version number for the plug-in)
So putting that all together would look similar to:
;nyquist plug-in
;name "Change direction"
;type tool
;version 4
;author "Your name here"
;copyright "GPL v2 or later"
;release 0.0.1
(let ((start (get '*selection* 'start))
(end (get '*selection* 'end)))
(setf dur (- end start))
(aud-do-command "SelectTime:" :start end :end (+ end dur))
"")
A plug-in will have a dialogue box if it has any widgets to display.
The widgets are defined in the plug-in as “;control” header lines.
You could, for example, add a “choice” widget to select whether to move the selection to the left or to the right:
;control direction "Move selection to" choice "Right,Left" 0
and then modify the code so that it moves the selection in the direction selected by the user:
;nyquist plug-in
;name "Change direction"
;type tool
;version 4
;author "Your name here"
;copyright "GPL v2 or later"
;release 0.0.1
;control direction "Move selection to" choice "Right,Left" 0
(let ((start (get '*selection* 'start))
(end (get '*selection* 'end)))
(setf dur (- end start))
(if (= direction 0) ;right
(aud-do-command "SelectTime:" :start end :end (+ end dur))
(aud-do-command "SelectTime:" :start (max 0 (- start dur)) :end start))
"")
However I suspect that it would be a better workflow to have two plug-ins, one to move the selection to the left, and one to move it to the right. You will then be able to assign a separate keyboard shortcut to each.
Thanks for the advice. How do I save as a .ny file in Notepad++? I’ve searched through the drop down menu of options under Save as type and can’t see the ny / Nyquist option. Can you clarify too what code I would need to move the selection to the opposite direction too? Thank you.
It’s been a long time since I’ve used NotePad++ (I’m on Linux), but if I recall correctly, you can just type the full name including file extension.
See the code in my previous post.
The “direction” variable is set by the “;control” line to a value of 0 (default: Right) or 1 (Left).
Later on in the code you will see:
(if (= direction 0) ...
which selects the first option if “direction” is equal to 0, otherwise the second option.
So I followed your advice and have been able to make an .ny file. I put it in the Audacity plug in folder along with the other plugins, but when I open the plugin manager, my new plugin doesn’t appear in the list. Any suggestions why?
I like your idea of creating two plugins, one to change direction from right to left and one from left to right. I’m just now sure of what code I need to do this.
I’ve really enjoyed learning new Audacity skills with you, btw.
“aud-do-command” is a Nyquist command that sends a macro/scripting command from Nyquist to Audacity.
Macro / scripting commands each have:
A name, followed by a colon “:”
None or more keyword parameters (a “name / value” pair)
In this case, the command name is “SelectTime:” and it has key word parameters “start” and “end”.
The keyword names are written with a colon prefix, so they are:
These two lines set variables “start” and “end” to the start and end time of the current selection as it exists when the code is launched. The names “start”, “end” and “dur” are not magical, they could have been anything, for example we could have had:
The important thing is that in the macro/scripting command to move the selection to the right, we set
“:start” to
and
“:end” to plus
The duration of the original selection is calculate as
minus
Obviously what we need to do to move the selection to the left is to set:
The important thing is that in the macro/scripting command, we set
“:start” to minus
and
“:end” to
I think you have enough information to work out how to write the “to the left” version. Have a go and post what you come up with.