Add-on for transferring audio edits between Blender and Audacity

Help for Audacity on Windows.
Forum rules
ImageThis 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.
tintwotin
Posts: 69
Joined: Tue Sep 09, 2014 7:58 am
Operating System: Please select

Add-on for transferring audio edits between Blender and Audacity

Post by tintwotin » Sat Feb 27, 2021 8:33 am

The resulting add-on: https://github.com/tin2tin/audacity_tools_for_blender

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
Site Admin
Posts: 84713
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Bug: Importing Labels through command line fails

Post by steve » Sat Feb 27, 2021 11:18 am

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).
Learn more about Nyquist programming at audionyq.com

tintwotin
Posts: 69
Joined: Tue Sep 09, 2014 7:58 am
Operating System: Please select

Re: Bug: Importing Labels through command line fails

Post by tintwotin » Sat Feb 27, 2021 1:07 pm

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

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

Re: Bug: Importing Labels through command line fails

Post by steve » Sat Feb 27, 2021 1:50 pm

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.
Learn more about Nyquist programming at audionyq.com

tintwotin
Posts: 69
Joined: Tue Sep 09, 2014 7:58 am
Operating System: Please select

Re: Bug: Importing Labels through command line fails

Post by tintwotin » Sat Feb 27, 2021 2:28 pm

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
Operating System: Please select

Re: Bug: Importing Labels through command line fails

Post by tintwotin » 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, 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
Site Admin
Posts: 84713
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Bug: Importing Labels through command line fails

Post by steve » Sat Feb 27, 2021 4:39 pm

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".
Learn more about Nyquist programming at audionyq.com

tintwotin
Posts: 69
Joined: Tue Sep 09, 2014 7:58 am
Operating System: Please select

Re: Bug: Importing Labels through command line fails

Post by tintwotin » Sat Feb 27, 2021 6:13 pm

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:
Image

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

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
Site Admin
Posts: 84713
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Bug: Importing Labels through command line fails

Post by steve » Sat Feb 27, 2021 6:47 pm

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
Learn more about Nyquist programming at audionyq.com

tintwotin
Posts: 69
Joined: Tue Sep 09, 2014 7:58 am
Operating System: Please select

Re: Bug: Importing Labels through command line fails

Post by tintwotin » Sat Feb 27, 2021 9:13 pm

The first script seems to be working, but the next two makes Blender hang. I don't know why.

Here's the first one:
Image

I have a bit of a hard time to get my head around how this would work for editing sound for video. Do we need to need to export the entire timeline to Audacity, and make the Blender playhead control the Audacity playhead(like jack), or do we have to mirror the UI from Audacity, or how is this feature envisioned?

In the specific case of noise reduction I guess this feature would make it possible to do everything from Blender while Audacity windowless would do all of the hard work, though the user will have a better time doing the tweaking in Audacity. Is there no chance of the Audacity Labels getting a specific extension name, so they can be distinguished from other text files and opened through the Audacity command line?

Post Reply