## Add-on for transferring audio edits between Blender and Audacity

Help for Audacity on Windows.
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".

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.
tintwotin
Posts: 69
Joined: Tue Sep 09, 2014 7:58 am

### Add-on for transferring audio edits between Blender and Audacity

Original thread title: "Bug: Importing Labels through command line fails"

I working on adding Audacity as an optional assistant application to Blender, so audio strips from the Video Sequencer can be round tripped in Audacity.

I need to mark the area of the audio file used in the Blender(not always the full file duration) in Audacity, so I wanted to use an Audacity label for this.

So I'll need to open both an audio file and an audacity label file through the command line. Like this:

Code: Select all

C:\Program Files (x86)\Audacity>audacity "C:\Users\45239\Desktop\Billy.wav" "C:\Users\45239\Desktop\label.txt"
Label file:

Code: Select all

126.348822	1758.354445	Billy.wav
But the label file fails at import. "Audacity did not recognize the file type of... "

Is this a bug, an unsupported feature or is there some way I can work around this?

It would be nice if Blender and Audacity could benefit from each other this way.

(Btw. opening "List of Files..." also seems to fail.)
(Btw. btw. Label import through command line also fails in Audacity 3.0 beta)
Last edited by tintwotin on Sun Mar 07, 2021 12:38 pm, edited 1 time in total.

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

### Re: Bug: Importing Labels through command line fails

tintwotin wrote:
Sat Feb 27, 2021 8:33 am
Is this a bug, an unsupported feature or is there some way I can work around this?
If I recall correctly that is an unsupported feature (I'll need to check).

Regarding a workaround, do you have any experience with Python? There's probably a Python solution (again I'd need to check).

tintwotin
Posts: 69
Joined: Tue Sep 09, 2014 7:58 am

### Re: Bug: Importing Labels through command line fails

I do have experience with python, but I'll need to limit the interaction from the Blender side to a command line.

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

### Re: Bug: Importing Labels through command line fails

steve wrote:
Sat Feb 27, 2021 11:18 am
If I recall correctly that is an unsupported feature (I'll need to check).
I've checked and yes it is not a feature. Only audio files can be passed as arguments.

tintwotin wrote:
Sat Feb 27, 2021 8:33 am
I need to mark the area of the audio file used in the Blender(not always the full file duration) in Audacity, so I wanted to use an Audacity label for this.
Do you only need one label ?
Do you only need a "start" position, or an "end" position, or "start and end"?
How are you creating the label track?

There's probably a way to do what you want, but nothing obvious is coming to mind. If you can provide a clearer picture of what you are wanting to do, that may help me to find a solution.

tintwotin
Posts: 69
Joined: Tue Sep 09, 2014 7:58 am

### Re: Bug: Importing Labels through command line fails

If the user ex. needs to do some noise reduction on an audio strip in Blender, then the user could select "Send to Audacity".
Internally Blender would then make a copy of that file(newer use the original), and switch to it internally. Then Audacity should be opened with the file, including markings of the range of the clip used in Blender, so the user can do the noise reduction, and save the file. And when updating the file in Blender it will be with the Audacity noise reduced file.

From the Blender side it would be really simple to just open the file in Audacity through a command line and including some marker file.

If txt as extension is also used for audio files, there is no way Audacity can know if it is a marker file or not. So I guess if Audacity marker files had a different extension it would be easier to open them correct though the command line? I've seen some also use subtitle formatting ex. srt:

Code: Select all

1
00:00:54,319 --> 00:02:53,822
My edit
Or csv:

Code: Select all

00:00:54.319,00:02:53.822,My edit
A range or In and out would work, but just one set for each file.

tintwotin
Posts: 69
Joined: Tue Sep 09, 2014 7:58 am

### Re: Bug: Importing Labels through command line fails

The new pipe stuff looks quite powerful, but it'll demand of users to install and enable things, and that maybe is too much to ask for the common user, and not how "assistant application"/"Open in..." is working in most softwares.

But on the other hand if it is a one-off setting up and enabling, and then if files(load and save), labels and playhead position can be controlled from Blender, that would super cool. So you would have both programs running in parallel, and you would be able to edit whatever audio file in Audacity, more or less instantly.

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

### Re: Bug: Importing Labels through command line fails

tintwotin wrote:
Sat Feb 27, 2021 4:15 pm
The new pipe stuff looks quite powerful, but it'll demand of users to install and enable things
How much do you know about Blender?
I don't know a lot, but I've heard that it has an embedded Python interpreter. Is it possible to use that to communicate with Audacity via mod-script-pipe? The central requirement is to be able to write to a "named pipe".

tintwotin
Posts: 69
Joined: Tue Sep 09, 2014 7:58 am

### Re: Bug: Importing Labels through command line fails

I have been working on the video editor part of Blender including add-ons for a couple of years now. Everything within python should be possible, but I don't know much about piping. Stuff I've done and collected about the VSE: https://blenderartists.org/t/video-sequ ... ns/1188770

What I was original thinking was a built-in solution like the video and image options here:

Where you can set up a path to an app which will open ex. an image like this:

If it needs to be in python, it is possible to make an add-on for that, but add-ons are rarely used.

The closer to a turn-key solution the more will use it. The audio options of Blender are really, really basic, so there is a great need for a better solution.

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

### Re: Bug: Importing Labels through command line fails

There has been some discussion about adding an option to configure Audacity for use as an add-on editor for other apps, but currently Audacity is not ideal for that kind of use. Audacity does not directly edit files, it copies the audio data from a file into the "project" and exports from the project to create a new file. Command line options for Audacity are minimal (as you have discovered).
tintwotin wrote:
Sat Feb 27, 2021 6:13 pm
If it needs to be in python
Imo it's looking like the best option, but I know nothing about Python add-ons in Blender.
If you want to do a feasibility study, you could try creating a minimal test add-on, perhaps just launching Audacity, loading a file and then send the "Play:" command via a named pipe.

Some information about mod-script-pipe and the scripting API:
https://manual.audacityteam.org/man/scripting.html
https://github.com/audacity/audacity/bl ... pe_test.py
https://github.com/audacity/audacity/bl ... ng_test.py
https://github.com/audacity/audacity/bl ... eclient.py

tintwotin
Posts: 69
Joined: Tue Sep 09, 2014 7:58 am