.aup file reference and .wav instead of .au

Hello everyone,

my long-term goal is developing an Audacity Project (.aup) Export and Import add-on for Blender. The point is: Blender has a not so well-known but very useful non-linear non-destructive video editor with a few video effects built in. The only important thing I miss in everyday use are audio filters such as simple noise reduction. So my add-on shall face that by making it possible to just create a video in Blender and export the audio layers to an Audacity Project in which one can then tune the sound. Blender add-ons are btw. written in Python.

All in all my main questions are for now:

  • Is there anywhere a file reference for .aup files? I did not find any, but hope persists.

  • Is there a way Audacity recognizes projects with different sound file types than .au files? Such as .wav files?
    I am not that familiar with how sound files work and only found a python script that converts .au files to .wav files (audacity.py by davidavdav on Github). For my add-on I also need the functionality the other way or the possibility to bypass the problem by using .wav files instead of .au files.

Thanks very much in advance!
qwertquadrat

Certainly. Audacity can Import and Export (not save) WAV (Microsoft, 16-bit), Stereo or Mono.

Audacity doesn’t save sound files. You’re probably wondering what all those little AU files are. Those are part of an Audacity Project. They’re not all sound files…

http://manual.audacityteam.org/man/audacity_projects.html

Koz

Hm, yeah, that’s sadly what I already knew…

TL;DR:
The interesting part of this concept is not about importing WAV files into Audacity but about packing many (many!) WAV files so that Audacity knows on which layer with which offset and which volume envelope to put them.

Blender can export WAV files and importing them into Audacity as you suggest is what I’ve done so far. Problem is that since projects in Blender get bigger, sound becomes multi-layered with different offsets. Exporting every single layer from the Blender VSE to a WAV file and importing each into Audacity is okay for let’s say 5 sound strips - but since videos get more complex, I have to export from Blender and import to Audacity many more.

For a better understanding on what the other program I want to write that add-on for does: In the Blender VSE (yes, that IS part of the open source 3D animation software Blender and yes, I use its VSE (Visual Sequence Editor) for non-animated - real-life - videos) I already have multi-layered strips exactly as you know them from Audacity or every other multi-layer video or audio editing software. Means: It just seems great to create a script that takes all audio layers and volume envelopes from one blender project and put them into one file (or project) Audacity can read. Since uncompressed Audacity Projects (.aup) seem to be the only multi-layered file (/project) type with layer-based volume envelopes Audacity can read, I obviously have to stick with this project format.

qwertquadrat

Is it possible to set Audacity as external audio editor for Blender?

There is a DTD file https://github.com/audacity/audacity/blob/master/src/xml/audacityproject.dtd.

No. Audacity does not open files directly.

Gale

Not out of the box - but of course one could script an add-on which does that. That is kinda what I already did in my previous projects: First to take every sound strip, edit it in Audacity and then import it in Blender. So one had to edit every sound strip individually - and hope that everything matches later on. That is okay for small projects, but not for large ones, where one want to edit one sound strip dependent on how the others sound.

That is good! Although I miss the “import”-tag in this DTD file that is used in compressed audacity project files - I guess that is the interesting part for my project, because in compressed projects, the import tag can contain the path to files with file types Blender could export out of the box.

Have feared that. But as seen in compressed audacity project files, at least .ogg files (and as I tried out - also .wav-files) can be recognized on project opening, when linked via this “import”-tag. For the “Export from Blender”-part of my add-on, using those “import”-tags could be sufficient. (The “Import to Blender”-part can probably be done using the script by davidavdav mentioned above.)

So all in all, everything I need to know with the “import”-tags in mind is: How does one specify the volume envelope of the audio linked via “import”-tags in the Audacity project file? (Please say that it is possible at all?)

qwertquadrat

The audacityproject.dtd file is badly out of date. It’s not been updated in at least 6 years, quite possibly longer, so some features of the Audacity Project XML format are undocumented.

One such feature is the import element.
I’m not an expert in XML, but it should be something like:

<!ELEMENT import EMPTY>
<!ATTLIST import filename CDATA #REQUIRED>
<!ATTLIST import offset CDATA "0">
<!ATTLIST import mute CDATA "0">
<!ATTLIST import solo CDATA "0">
<!ATTLIST import height CDATA "150">
<!ATTLIST import minimized CDATA "0">
<!ATTLIST import gain CDATA "1">
<!ATTLIST import pan CDATA "0">

or

<!ELEMENT import EMPTY>
<!ATTLIST import filename CDATA #REQUIRED>
<!ATTLIST import offset CDATA #IMPLIED>
<!ATTLIST import mute CDATA #IMPLIED>
<!ATTLIST import solo CDATA #IMPLIED>
<!ATTLIST import height CDATA #IMPLIED>
<!ATTLIST import minimized CDATA #IMPLIED>
<!ATTLIST import gain CDATA #IMPLIED>
<!ATTLIST import pan CDATA #IMPLIED>

(The latter seems to be more “correct” in terms of the current implementation, but of course the implementation could change in future versions of Audacity)

Yes they are “recognised”, but they are still “imported” rather than “opened”.
If a project contains an import tag, that tells Audacity to import the file filename (declared by the “filename” attribute). Audacity then decodes the (usually “Ogg”) file, and copies its audio data as “blockfiles” (“.AU” file extension).

Short answer, you don’t.
As described in my previous post, the import element has no child elements. It is just imported as is. (No support for adding envelope or any other elements).
When saving a compressed copy of a project, any envelopes are applied to the tracks before exporting the track OGG files.

Yes, but that’s fully okay for my purposes.

Ough, that is sad. So I either can’t export the volume envelope from Blender or I can’t use the “import”-tags which means I would have to somehow add the possibility via Python to export to .au files in Blender. I actually hoped for such a workaround as the following (not working) try.

	<import filename="testproject2.wav"/>
	<wavetrack name="testproject2">
		<waveclip>
			<envelope numpoints="3">
				<controlpoint t="0.011609977324" val="0.750000000000"/>
				<controlpoint t="0.290249433107" val="1.000000000000"/>
				<controlpoint t="0.661768707483" val="0.708333313465"/>
			</envelope>
		</waveclip>
	</wavetrack>

All in all, I think, unless it was planned to add support for exporting compressed project files with preserved envelopes, the best solution is to export a compressed Audacity project file from Blender, open that in Audacity so that it turns the imports to .au files and then re-open that file in Blender via my add-on and add the envelopes to the Audacity project. That is not very user friendly - but the best I can imagine right now; Unless someone writes a standalone .wav to .au file converter or adds command line control to Audacity (which would be really great btw.!).

Thank you all very much for your help for now! If anyone has a great idea on how Audacity can be integrated better in the Blender VSE, I would be happy to read about it!

How does Blender handle audio?
Can you not just use Audacity in the normal way to edit and export the audio?

Sorry, I’m not sure if I understand what you want to suggest. Is the following answer given above not also applicable for your question?

Or is your suggestion to mixdown the audio from Blender and import that in Audacity? Then you can’t edit every sound layer independently - Which means that you can’t tune for example only the music or only the sound effects or only the voice of an actor or the narrator etc… And if you are looking for a low-pass filter for the music for a scene, where the camera dives into water, you do not necessairly want to low-pass filter also the narrators voice.

Via the Python API you have access to “sound sequences” that are quite similar to the sequences from Audacity. Their graphical representation is similar to that in any other non-linear editor, like Audacity also is. Internally FFmpeg is used to handle audio (as far as I know). Via the API you have access to the class described here:
https://www.blender.org/api/blender_python_api_2_78a_release/bpy.types.SoundSequence.html

Can these sound strips be exported as multichannel WAV files? Audacity can import such a file one track per channel.


Gale

Sadly not out of the box :confused: (and I am not aware of any add-on that implements such a feature)
Would that mean btw. that every channel would then be mono? And would you still have to apply the envelopes? Or does WAV support them?
If that preserves stereo, it would of course be an idea to develop a multichannel WAV export add-on for Blender instead.

I was going to ask what a “sound strip” is, but I’ve found it: https://www.blender.org/manual/de/editors/sequencer/strips/types/audio.html
So in Audacity terminology, your “Blender project” contains many “audio clips”.
How / where are those audio clips stored?
What is your project? Are you creating an animation in Blender, or editing a video that you shot with a video camera, or something else?

Oh, okay, did not expect that this would lead to confusion. Sorry for that.

In Blender most of the used files can be stored anywhere, because Blender only links to the files by default. One can include linked files in the Blender project file, but for video editing, files can easily get large - so that is mostly not a good idea. Usually one will end up creating a project folder manually and storing every used media file in this folder.
That is made because in contrast to Audacity, Blender has no destructive operations. Every filter is only applied for the preview in cache and on final render (= mixdown = export), so there is no need to save altered versions of a file - and converting every file to a specific file type would only cost time and storage space.

My projects vary, some are animated, but most are shot with a video camera and a sound recorder. Some contain visual effects and motion graphics (especially for the credits) made in Blender.

Thanks, that what I thought.

So if the files that you are using in Blender are in a lossless format (WAV), then you could just import a track into Audacity, process it (but do not do anything that will change the length), then export as WAV and overwrite the original WAV file. (I don’t usually recommend overwriting the source file as it’s too easy to mess up :wink: Take whatever precautions you feel necessary.)

To overwrite the original file, you should have “Make a copy” selected as the Import option: Import / Export Preferences - Audacity Manual

I’m not sure what the new point is, so I answer again with the citation in which I thought I already answered to this question (again perhaps “sound strip” should be replaced by “audio clip” for a better understanding):

Just to mention an important feature that one can’t use if one edit every sound file individually is the “Playback Meter” of Audacity. An important and basic point in editing audio for video is to ensure the volume of each clip matches. As Blender does support audio only very roughly, there is no playback meter in Blender. So even the fine tuning of the volume envelopes would be done much easier in Audacity than in Blender - If one can edit the whole audio at once and not only one clip at a time.

Any multi-channel file that might be saved by Blender would be a mixdown according to the channel allocation of the format. For WAV 5.1 the first channel would be front left, the second front right, third front right and so on. So panning would already be baked in but could be changed in Audacity.

Do I assume from your further post though that your clips are all stereo and not part of a mix. Are they simply strung out in time?


Gale

Mostly yes. Some sound effects are mono. And depending on the project, there is also a narrators voice that is mono.

No. For example an actors voice, sound effects, music and ambient sound are played at the same time. Although they do not necessairly start at the same time btw.

Are each of those (actor’s voice, sound effects…) in their own line going from left to right? Is there only one clip in that line, or multiple clips in each line? Can you save multiple clips in one line as one file?


Gale

Depends obviously on how one arranges them. In the past I did that roughly, but sometimes multiple sound effects or two music clips fading in each other occur so one has to break the scheme and use an extra channel for them. For sound recorded on set one wants to sync it with the video, so it is handy to use channels for this audio that are close to the ones that are used for the video - Because on moving the video clip one can then easily also grab the related sound and ensure they stay in sync.

Not directly. One could of course copy each clip in one channel to an empty project and mix down the audio.