Add Labels Macro Command
Forum rules
This forum is for Audacity on Windows.
Please state which version of Windows you are using,
and the exact three-section version number of Audacity from "Help menu > About Audacity".
Audacity 1.2.x and 1.3.x are obsolete and no longer supported. If you still have those versions, please upgrade at https://www.audacityteam.org/download/.
The old forums for those versions are now closed, but you can still read the archives of the 1.2.x and 1.3.x forums.
Please state which version of Windows you are using,
and the exact three-section version number of Audacity from "Help menu > About Audacity".
Audacity 1.2.x and 1.3.x are obsolete and no longer supported. If you still have those versions, please upgrade at https://www.audacityteam.org/download/.
The old forums for those versions are now closed, but you can still read the archives of the 1.2.x and 1.3.x forums.
Add Labels Macro Command
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.
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.
Re: Add Labels Macro Command
The "Add label at selection" command seems to work for me. It does leave focus in the label text, but only if it is the last macro command.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
Re: Add Labels Macro Command
When I tried to use that to create a bunch of labels it pops up a dialog for user to enter each label's text.
I'd rather have the set label command be able to create if doesn't exist.
What I'm doing now that seems to work is this:
Concert_Title_Edit.txt
Any pitfalls with doing like this?
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.
I'd rather have the set label command be able to create if doesn't exist.
What I'm doing now that seems to work is this:
Concert_Title_Edit.txt
Code: Select all
NewLabelTrack:
TrackMoveTop:
PasteNewLabel:
PasteNewLabel:
PasteNewLabel:
...
SelectTracks:Mode="Set" Track="1" TrackCount="1"
SelTrackStartToEnd:
Copy:
NewStereoTrack:
Paste:
...
SetLabel:End="642.135028" Label="1" Selected="0" Start="444.585715" Text="If I Stand"
SelectTime:End="640.850000" RelativeTo="ProjectStart" Start="638.850000"
FadeOut:Use_Preset="<Factory Defaults>"
SetLabel:End="1369.192910" Label="2" Selected="0" Start="1090.329910" Text="Calling Out Your Name"
SelectTime:End="1090.670000" RelativeTo="ProjectStart" Start="1090.329910"
FadeIn:Use_Preset="<Factory Defaults>"
SetLabel:End="1918.640000" Label="3" Selected="0" Start="1695.985488" Text="The Color Green"
SelectTime:End="1696.340000" RelativeTo="ProjectStart" Start="1695.985488"
FadeIn:Use_Preset="<Factory Defaults>"
...
SelectTracks:Mode="Set" Track="0" TrackCount="1"
SetLabel:End="0" Label="0" Selected="1" Start="0" Text="empty"
Delete:
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.
Re: Add Labels Macro Command
1) How are you running these commands? Are you creating a "macro" (https://manual.audacityteam.org/man/manage_macros.html), 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"?Al Stu wrote: ↑Sat Oct 20, 2018 3:38 amCode: Select all
NewLabelTrack: TrackMoveTop: PasteNewLabel: PasteNewLabel: PasteNewLabel: ...
2) No need for the "NewLabelTrack:" command unless the project already contains other label tracks.
Yes, of course it does. The long name of that command is "Paste Text to New Label"
https://alphamanual.audacityteam.org/ma ... it:_Labels
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:"
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
Re: Add Labels Macro Command
1) Running the commands as a macro; C:\Users\AHS\AppData\Roaming\audacity\Macros\macro_name.txt
2) Thanks for the tip. Though will probably keep that for self documenting clarity sake.
3) 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.
2) Thanks for the tip. Though will probably keep that for self documenting clarity sake.
3) 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.
Re: Add Labels Macro Command
The way I would do that would be:
1) Set the selection to a time before zero (so that the label created in the next step will always be the first label)
2) Add a label at the selection
3) 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".
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
Re: Add Labels Macro Command
But step 2 of that pops up a "New Label" dialog box for user to input the label text.steve wrote: ↑Sun Oct 21, 2018 1:49 amThe way I would do that would be:
1) Set the selection to a time before zero (so that the label created in the next step will always be the first label)
2) Add a label at the selection
3) 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".
Re: Add Labels Macro Command
Try it:
Code: Select all
Select:End="0" Mode="Set" RelativeTo="ProjectStart" Start="0"
AddLabel:
SetLabel: Label="0" Start="7" End="10" Text="Audacity"
Select:End="0 Mode="Set" RelativeTo="ProjectStart" Start="0"
AddLabel:
SetLabel: Label="0" Start="4" End="5" Text="Foo Bar"
Select:End="0" Mode="Set" RelativeTo="ProjectStart" Start="0"
AddLabel:
SetLabel: Label="0" Start="1" End="2" Text="Hello World"
Select: Start="0" End="10" Mode="Set" RelativeTo="ProjectStart"
TrackMoveTop:
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
Re: Add Labels Macro Command
Pops up dialog box, prompting for label name/text, for each AddLabel command. So in this case; 3 times.steve wrote: ↑Sun Oct 21, 2018 2:14 amTry it:Code: Select all
Select:End="0" Mode="Set" RelativeTo="ProjectStart" Start="0" AddLabel: SetLabel: Label="0" Start="7" End="10" Text="Audacity" Select:End="0 Mode="Set" RelativeTo="ProjectStart" Start="0" AddLabel: SetLabel: Label="0" Start="4" End="5" Text="Foo Bar" Select:End="0" Mode="Set" RelativeTo="ProjectStart" Start="0" AddLabel: SetLabel: Label="0" Start="1" End="2" Text="Hello World" Select: Start="0" End="10" Mode="Set" RelativeTo="ProjectStart" TrackMoveTop:
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.
Re: Add Labels Macro Command
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.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)