Timeline: Ardour input script now merges sources for multi-channel tracks instead of creating multiple mono tracks.

This commit is contained in:
Jonathan Moore Liles 2013-04-30 17:26:57 -07:00
parent 2f730acefb
commit bf50334890
1 changed files with 46 additions and 17 deletions

View File

@ -133,34 +133,63 @@ for node in root.findall( "./Playlists/Playlist" ):
if node.attrib["name"] == Track.attrib["playlist"]: if node.attrib["name"] == Track.attrib["playlist"]:
print "\tFound playlist " + node.attrib["name"] print "\tFound playlist " + node.attrib["name"]
for chan in range(0, int( Track.attrib["channels"] )):
TrackID = NewID()
SequenceID = NewID()
if int(Track.attrib["channels"]) > 1:
TrackName = Track.attrib["name"] + "-" + ( "%i" % chan )
else:
TrackName = Track.attrib["name"]
History.write( "Track " + TrackID + " create :name \"" + TrackName + "\"" + ( " :sequence " + SequenceID ) + " :color " + ( "%i" % random.randint(256,123123123)) + " :inputs 1 :outputs 1\n" ) # for chan in range(0, int( Track.attrib["channels"] )):
History.write( "Audio_Sequence " + SequenceID + " create :track " + TrackID + " :name \"" + node.attrib["name"] + "\"\n" ) TrackID = NewID()
for n2 in node.findall("./Region"): SequenceID = NewID()
RegionID = NewID(); # if int(Track.attrib["channels"]) > 1:
# TrackName = Track.attrib["name"] + "-" + ( "%i" % chan )
# else:
TrackName = Track.attrib["name"]
Channels = int(Track.attrib["channels"])
History.write( "Track " + TrackID + " create :name \"" + TrackName + "\"" + ( " :sequence " + SequenceID ) + " :color " + ( "%i" % random.randint(256,123123123)) + ( " :inputs %i :outputs %i\n" % ( Channels, Channels ) ) )
History.write( "Audio_Sequence " + SequenceID + " create :track " + TrackID + " :name \"" + node.attrib["name"] + "\"\n" )
for n2 in node.findall("./Region"):
RegionID = NewID();
SourceName = Sources[n2.attrib["source-" + ( "%i" % chan )]].attrib["name"]; if ( int( Track.attrib["channels"] ) > 1 ):
SourceList = []
APath1 = os.path.dirname(ArdourFilePath) + "/sounds/"
APath2 = os.path.dirname(ArdourFilePath) + "/interchange/" + ProjectName + "/audiofiles/"
for chan in range(0, int( Track.attrib["channels"] )):
SourceName = Sources[n2.attrib["source-" + ( "%i" % chan )]].attrib["name"]
if os.path.exists( APath1 + SourceName):
SourceName = APath1 + SourceName
elif os.path.exists( APath2 + SourceName ):
SourceName = APath2 + SourceName
else:
print "source not found!"
SourceList.append( "'" + SourceName + "'" );
s1,s2,s3 = Sources[n2.attrib["source-0"]].attrib["name"].partition( '%' )
SourceName = s1 + ".wav"
OutputName = NonTimelineProjectPath + "/sources/" + SourceName
if not os.path.exists( OutputName ):
print "Combining multifile source into multichannel source"
os.system( "sox -S -M " + " ".join(SourceList) + " " + "'" + OutputName + "'" )
else:
SourceName = Sources[n2.attrib["source-0"]].attrib["name"];
if not os.path.exists( NonTimelineProjectPath + "/sources/" + SourceName ): if not os.path.exists( NonTimelineProjectPath + "/sources/" + SourceName ):
print "\t\tCopying source: " + SourceName; print "\t\tCopying source: " + SourceName;
try: try:
shutil.copy( os.path.dirname(ArdourFilePath) + "/interchange/" + ProjectName + "/audiofiles/" + SourceName, shutil.copy( os.path.dirname(ArdourFilePath) + "/interchange/" + ProjectName + "/audiofiles/" + SourceName,
NonTimelineProjectPath + "/sources/" ) NonTimelineProjectPath + "/sources/" )
except: except:
shutil.copy( os.path.dirname(ArdourFilePath) + "/sounds/" + SourceName, shutil.copy( os.path.dirname(ArdourFilePath) + "/sounds/" + SourceName,
NonTimelineProjectPath + "/sources/" ) NonTimelineProjectPath + "/sources/" )
History.write ("Audio_Region " + RegionID + History.write ("Audio_Region " + RegionID +
" create :source \"" + Sources[n2.attrib["source-" + ( "%i" % chan )]].attrib["name"] + " create :source \"" + SourceName +
"\" :start " + n2.attrib["position"] + "\" :start " + n2.attrib["position"] +
" :length " + n2.attrib["length"] + " :length " + n2.attrib["length"] +
" :offset " + n2.attrib["start"] + " :offset " + n2.attrib["start"] +