Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

View Poll Results: Did you find this script
useful? 2 100.00%
not useful? 0 0%
irrelevant to my needs? 0 0%
Voters: 2. You may not vote on this poll

Reply
 
Thread Tools Display Modes
Old 10-02-2014, 04:23 PM   #1
sdog
Human being with feelings
 
sdog's Avatar
 
Join Date: Aug 2010
Location: Crawford, CO
Posts: 43
Default mono to poly channel file combiner

I had need of a script that would recombine poly files which had been split into mono files by evil, nasty, picture editing software. I had two major requirements: First the audio in the files had to retain their relationship to the Reaper timeline (unlike 3rd party poly-channel combiners - what better place to accomplish this than inside Reaper). And second, the channel combiner had to retain the handles (audio information outside the slip edits).

One can almost accomplish this with Reaper's glue, except that glue loses everything beyond the slip edits.

I imagine this script being most useful to my fellow audio-for-picture engineers, but I hope others may find it useful as well.

The script is here:

https://stash.reaper.fm/21978/mono2poly.py

The script's documentation header is below as it will give you a pretty good sense of what the script does (so you can decide whether you want to bother with it or not):

"""
mono2poly.py - (C) 2014 Doug Gallob
v1.0

Consolidate selected items with mono audio source files into items with
poly-channel source files.

NOTE: Presently uses a 3rd party executable approach with sox. You will
need to have the audio utility sox installed on your machine in order
to use this script.

As of this writing, you could find sox here:
http://sox.sourceforge.net/

TODO: Someday look into using more integrated audio manipulation libraries.
__________________________________________________ ____________________________
APPLICATION:

My primary need for this script was to re-join stereo files split into
separate mono files by video editing software (OMF/AAF exports - sometimes
hundreds of split stereo clips) - WITHOUT losing the audio in the handles
(i.e. audio in the source files, but outside the slip edits) and WITHOUT
losing the audio's location on the timeline.

There are plenty of 3rd party tools to rejoin split stereo files, but because
they are outside of Reaper, they are not suitable for retaining the Reaper
timeline location.

There are also tools within Reaper for recombining stereo files, like "glue",
but glue does not retain the audio in the handles, an absolute necessity for
sound-for-picture work.

This script should allow you to re-assemble stereo files so that they can be
popped open in an external editor like Izotope RX and cleaned up as stereo
files.

Given that application, I generalized this script for the broader problem of
re-combining mono items into poly files of any number of channels.

Although the most common case will be to combine audio that starts and ends
at the same point in time, this script attempts to avoid that restriction
and allows combination of sources that may begin and end at different times
(provided they overlap somewhere in time).
__________________________________________________ ____________________________
BASIC USAGE:

Install sox and modify this script to point to your sox executable. search for
"sox = " in the code to find the right line to modify (or just scroll down -
I tried to keep that statement near the top few lines of code.)

Select several items that overlap in time and run this script.

You can select items across several areas of overlap. For example, selecting
all 4 of the following items,

tr1: |mono item 1| |mono item 3|
tr2: |mono item 2| |mono item 4|

would create two new items, each containing a 2-channel source file. One would
contain audio from mono 1 and mono 2. The second, audio from mono 3 and mono 4.

On the other hand, if all 4 of those items overlap in time, like this:

tr1: |mono item 1| |mono item 3|
tr2: --- |mono item 2| |mono item 4|

then this script would consolidate all 4 items into a single 4-channel poly
file (padding appropriately with silence where necessary so that each element
of audio retains its original relationship to the timeline).
__________________________________________________ ____________________________
ADDITIONAL DETAILS ON BEHAVIOR:

There is much this script will NOT do. I tried to document as many of its
limitations as I could foresee. If not here in this header, then throughout
the code. Search for "TODO"s and "NOTE"s and "WARNING"s below.

- The new poly items will be created on a new track above the first selected
original item.

- Original items will not be deleted.

- Restores earliest leading slip edit and latest trailing slip edit of
originally selected mono items to new poly item.

- Ignores fades, envelopes, and pans. This is not glue!! I could not identify
the most intuitive behavior for item level volume information while still
respecting my primary objective for the typical case of simply re-combining
underlying sources originally split elsewhere. I am open to suggestions for
preferred behavior.

- BWF metadata preservation is not guaranteed in the new poly files. I did
not test what sox does to input BWF chunks when combining BWF files.

TODO - Theoretically, BWF metadata can be exported (preserved) and imported
(restored) by the command line version of BWF Metaedit. Look into this
sometime.

- Works on Windows. Untested on Mac! sox uses an odd piped/quoted command
line syntax for padding and combining input files. By the time I got the
proper quote escaping that worked for python and for sox and for the OS, my
brain was bleeding. If it doesn't work for you on the Mac, you may need to
play with the command line quoting a bit yourself.


__________________________________________________ ____________________________
LICENSE:

The script is free to use personally or commercially. However, if you find it
useful, I would appreciate a note in this forum letting me know.

This script may not be modified for commercial purposes without my permission.

You may modify this script to improve its behavior (or to make it more
"Pythonic", or more "Reaperish") for your own use or to share with the Reaper
community, BUT if you do, you must:
1. Give me just a bit of credit for the original script.
2. Share a copy of the improved script with me.

If you have a better approach to anything I'm doing here, I would be extremely
grateful if you would share it.

"""
__________________
Doug Gallob - Composer/Audio Engineer
Aural Hygiene - "Dangerous Music for Dangerous Movies"
sdog is offline   Reply With Quote
Old 10-03-2014, 06:17 PM   #2
sdog
Human being with feelings
 
sdog's Avatar
 
Join Date: Aug 2010
Location: Crawford, CO
Posts: 43
Default

Well imagine that: 42 seconds after I uploaded v1.0, I discovered a logic error.

v1.01 is now available and fixes a logic error in the calculation of which items overlap in time.
__________________
Doug Gallob - Composer/Audio Engineer
Aural Hygiene - "Dangerous Music for Dangerous Movies"
sdog is offline   Reply With Quote
Old 10-07-2014, 06:38 PM   #3
Soli Deo Gloria
Human being with feelings
 
Soli Deo Gloria's Avatar
 
Join Date: Oct 2013
Location: Argentina
Posts: 1,303
Default

Hi Sdog!

Thank you very much for the script! There is one thing that leaves me with a doubt : I tried to download Sox but the sourceforge page is recognized as dangerous by Firefox...it´s a false positive, isn´t it?
Soli Deo Gloria is offline   Reply With Quote
Old 10-07-2014, 11:58 PM   #4
Runaway
Human being with feelings
 
Runaway's Avatar
 
Join Date: Jun 2009
Location: Sydney, Australia
Posts: 2,510
Default

Maybe this could be of some assistance?
http://www.aatranslator.com.au/cleaver.html
__________________
AATranslator
Runaway is offline   Reply With Quote
Old 10-08-2014, 05:23 AM   #5
sdog
Human being with feelings
 
sdog's Avatar
 
Join Date: Aug 2010
Location: Crawford, CO
Posts: 43
Default

Soli Deo Gloria,

I do believe that is a false positive.
__________________
Doug Gallob - Composer/Audio Engineer
Aural Hygiene - "Dangerous Music for Dangerous Movies"
sdog is offline   Reply With Quote
Old 10-08-2014, 06:16 AM   #6
sdog
Human being with feelings
 
sdog's Avatar
 
Join Date: Aug 2010
Location: Crawford, CO
Posts: 43
Default

Runaway! AATranslator is the best software ever created!! Does god-awful-complex conversions of project files and saves the sanity of countless post production audio engineers! I'll bet Cleaver is just as spiffy. (Actually, I just now downloaded it and took a quick look. What do you know: It is pretty spiffy.)

Hey, I know you guys are already doing everything you can to mitigate the mind boggling amount of pain and suffering brought into the world by the big picture editing software companies, but I'm wondering if you've had a chance to delve into that notion of how to rejoin stuff in reference to the project timeline as opposed to simply joining files externally.

I always blame the NLEs, but maybe some of this comes from the human part of the picture editing chain - I don't know the NLEs well enough. In any event, the split files are very often named fairly non-intuitively (i.e. rather than something like "somefile_L.wav" or "somefile.R.wav", more along the lines of "01234.wav" and "01234(1).wav"). I suspect that is why I don't usually have much luck selecting the "Combine Split Mono Wave Files" option in AATranslator. And of course trying to combine the goofily-named split mono files externally is seriously painful. I can see at a glance within the Reaper timeline which files belong together. From a file directory, not so much.

Then on top of that, once files are on a timeline (the new gospel), I'm hesitant to trust that the underlying files will rejoin correctly by simply starting each at "beginning of file". Although this doesn't seem to happen often, I've encountered picture editors with twitchy mouse fingers who have lopped off the handles of left and right channels at different points in time. When I'm inside Reaper, I can see/hear where everything is and know whats right and what's wrong.

Anyway, not saying this is a problem you guys should dump a lot of energy into solving - maybe I'm the only one who encounters this stuff. And except for all it's limitations, this script kinda, sorta solves what I need. Just saying, if anyone could solve the problem ("combine while keeping timeline and handles") without the limitations, the AATranslator team would be the ones to do it!!
__________________
Doug Gallob - Composer/Audio Engineer
Aural Hygiene - "Dangerous Music for Dangerous Movies"
sdog is offline   Reply With Quote
Old 10-08-2014, 06:56 AM   #7
Runaway
Human being with feelings
 
Runaway's Avatar
 
Join Date: Jun 2009
Location: Sydney, Australia
Posts: 2,510
Default

Sdog I am humbled by your comments

There are two main causes for splitting of stereo files by daws/nles
1. Some specifications like OMF call for only mono files - the strange numeric naming generally comes from internal identifiers used within the OMF for embedded audio and I guess also ensures unique (though not helpful) file names
2. ProTools used mono files internally for all versions prior to PT10 - hence the .L & .R references in split files

The "Combine Split Mono Wave Files" in AAT does it's best to try and work out what goes with what but it also needs access to the media - selecting 'Display Session Media Files' after a conversion can show if this is the case.

Quote:
Originally Posted by sdog View Post
Then on top of that, once files are on a timeline (the new gospel), I'm hesitant to trust that the underlying files will rejoin correctly by simply starting each at "beginning of file".
Cleaver was designed for that purpose and mainly for use where PT is or was involved

Quote:
Originally Posted by sdog View Post
Although this doesn't seem to happen often, I've encountered picture editors with twitchy mouse fingers who have lopped off the handles of left and right channels at different points in time. When I'm inside Reaper, I can see/hear where everything is and know whats right and what's wrong.
I would think that 2 clips referencing either the same or different parts of two mono files that were once a stereo file would still reference the same audio when the two files were joined from the beginning?
I would certainly be interested in seeing a small example of one of these sort of scenarios

Necessity is the mother of invention and sometimes having more than one tool in your arsenal is important and you should be commended for your efforts in this area.
__________________
AATranslator
Runaway is offline   Reply With Quote
Old 10-08-2014, 09:44 AM   #8
sdog
Human being with feelings
 
sdog's Avatar
 
Join Date: Aug 2010
Location: Crawford, CO
Posts: 43
Default

Oh, yeah. I completely forgot that mono thing is right there in the OMF spec.

Quote:
Originally Posted by Runaway View Post
I would think that 2 clips referencing either the same or different parts of two mono files that were once a stereo file would still reference the same audio when the two files were joined from the beginning?
I would certainly be interested in seeing a small example of one of these sort of scenarios
I think the problem is when the beginning is not the beginning. If during the picture edit process, the file for one channel gets inadvertently trimmed to a different point than the other (talking about the trim of the underlying file, not the slip edit), then the "beginning" of the files are no longer in sync, even though everything on the timeline still is.

Now, here's where I run into difficulty: I'm about 98% sure that I can categorize this trim sync issue under, "This really happened to me." But there is a small chance that it should be categorized under, "I just have a false memory of this happening to me." There is even a small chance that it should be categorized, "Never happened. don't remember it. Just paranoid!"

I'll keep my eyes open as projects come through (or maybe even look at a few old ones) and if I run into this again, I'll send you an example.

And by the way, now that you've pointed out Cleaver, I'll definitely be using that now for those cases where it does make sense (i.e. where there's some logical organization to the file naming).

Thanks!
__________________
Doug Gallob - Composer/Audio Engineer
Aural Hygiene - "Dangerous Music for Dangerous Movies"
sdog is offline   Reply With Quote
Old 10-08-2014, 06:40 PM   #9
Soli Deo Gloria
Human being with feelings
 
Soli Deo Gloria's Avatar
 
Join Date: Oct 2013
Location: Argentina
Posts: 1,303
Default

Quote:
Originally Posted by sdog View Post
Soli Deo Gloria,

I do believe that is a false positive.
Fine! I´ll give it a try tomorrow...Thanks!
Soli Deo Gloria is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:04 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.