Looking for a way for a macro to add/create new labels with start, end, and text, without prompting for the label text.
Is this possible? The add label macro commands I see prompt for the label text to be entered. Hampers the use of macros for automation.
One thing I don’t like about using the PasteNewLabel command in this way is that it creates all the labels initialized with whatever happens to currently be in the clipboard.
How are you running these commands? Are you creating a “macro” (Macro Manager - Audacity Manual), or using the scripting interface? If using the scripting interface, are you doing so with mod-script-pipe and Python (or some other language), or with Nyquist “AUD-DO”?
No need for the “NewLabelTrack:” command unless the project already contains other label tracks.
As I wrote previously, if you want an empty label, use the “Add label at selection” (Scripting Id: “AddLabel:”, Description: “Creates a new, empty label at the cursor or at the selection region.”)
Potential pitfall: If you need a label at time=0, then that should be created last because if there are multiple labels at time=0, then you probably can’t be sure which label will be picked by “SetLabel:”
Running the commands as a macro; C:\Users\AHS\AppData\Roaming\audacity\Macros\macro_name.txt
Thanks for the tip. Though will probably keep that for self documenting clarity sake.
Don’t want an empty label. Want a bunch of labels with various start, end, and text. And want to set them at various places within the macro.
So we set a label at a specific start and end with some meaningful text like song title. Then perform edits for that section. The label text field sort of doubles as providing a human readable reference for the section that the macro is editing.
Initially I was using the “Add label at selection” (AddLabel) command. But each of them pops up a dialog prompt for user to enter the label text. I want the label text to be populated by the macro. To accomplish this I create a bunch of labels. Then set each of them with the desired position and text. Would be nicer if the set label command would create the label if the specified label doesn’t exist.
Using “Paste Text to New Label” is a work around for the pop up dialog.
Set the selection to a time before zero (so that the label created in the next step will always be the first label)
Add a label at the selection
Set the label “index” 0, with the required start time, end time and text/
Repeat 1 to 3 as required.
Note that macros can only run a simple list of commands. They can’t do conditional logic, or pass information from one command to another - for that you need to use “scripting”.
Pops up dialog box, prompting for label name/text, for each AddLabel command. So in this case; 3 times.
Oh also, what to add to the end (append) not the beginning (prepend).
Also the Select command seems to be irrelevant since the start and end times are being set with the SetLabel command anyway.
I’m unable to reproduce that on Linux or Windows 10.
I don’t have Windows 8.
You need to know the label index for SetLabel:
Adding a label before any other labels “should” guarantee that it is the zero index label.
The same should work, but note that currently the labels are not re-sorted after adding a label with a macro, so the label indexes will be in reverse order. This may also cause the labels to be staggered vertically until some other action causes the labels to be sorted.
Using the Label Editor does. Probably other things too.
I can reproduce this by enabling “Use dialog for the name of new label” in Preferences. If you turn that off then the labels should appear without prompting for a name. Does that work for you?
Macros are a new feature with dozens of new commands and thousands of ways of using and combining them. I’ve only been testing these new features for a few weeks longer than you, plus fixing some problems as they have arisen. I can’t be expected to know everything
I do know that using the Label Editor re-sorts the labels, so I shared that information with you.
I also know that reversing the project and reversing it back again will re-sort the labels.
If you find any quick and convenient way to resort the labels, please let me know.
When I get time I shall be looking into this to see if sorting could be added automatically when adding a new label with a macro, without imposing too much of a performance penalty if the project contains a lot of labels. If that can’t be done, then we may need an additional macro command to sort labels.
If you have better ideas, please say.
So first AddLabel is index 0, next one is at index 1, next one is at index 2, etc. Rather then each new one being at index 0, and index of all the previous being incremented.
So that new labels go after the last one, rather than before the first one.
Labels “should” be kept in order in the label track so that tabbing from tab to tab goes left to right (Shift + Tab for right to left). This is important for a lot of people that use labels for navigating through large projects (such as audiobooks).
(1) I gather from the posts in this topic that the native macro-capability is fairly new. If so, is there a plan to upgrade the macro-capability at all, apart from adding new Audacity commands as they are implemented?
(2) I installed NyQuist and copied a supplied macro. I have a feeling that NyQuist should be the target of my studies if i want to do semi-serious macro stuff. This topic interested me because I wanted to write a macro that generated labels with the time-stamp (mm:ss) of the Selection point, but as far as I know, Audacity macros do not support any sort of variable data, incremental, random or whatever. Is this correct?
“Macros” was originally called “Chains”. It was greatly extended and renamed as “Macros” a few years ago.
There are plans to improve the Macro Manager interface, but Macros themselves are unlikely to change significantly.
“Nyquist”
Yes.
You can do that with normal Nyquist (no need for Macro commands).
This code may be run in the Nyquist Prompt (see: Nyquist Prompt - Audacity Manual) and will create a label at the selection, with the time range (in seconds) in the label text.