From bf50334890ce4abe63d040f0cbecf84faa953738 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Tue, 30 Apr 2013 17:26:57 -0700 Subject: [PATCH] Timeline: Ardour input script now merges sources for multi-channel tracks instead of creating multiple mono tracks. --- timeline/bin/import-ardour-session | 63 ++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 17 deletions(-) diff --git a/timeline/bin/import-ardour-session b/timeline/bin/import-ardour-session index 9546479..6912713 100755 --- a/timeline/bin/import-ardour-session +++ b/timeline/bin/import-ardour-session @@ -133,34 +133,63 @@ for node in root.findall( "./Playlists/Playlist" ): if node.attrib["name"] == Track.attrib["playlist"]: 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" ) - History.write( "Audio_Sequence " + SequenceID + " create :track " + TrackID + " :name \"" + node.attrib["name"] + "\"\n" ) - for n2 in node.findall("./Region"): - RegionID = NewID(); + # 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"] + 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 ): print "\t\tCopying source: " + SourceName; - + try: shutil.copy( os.path.dirname(ArdourFilePath) + "/interchange/" + ProjectName + "/audiofiles/" + SourceName, - NonTimelineProjectPath + "/sources/" ) + NonTimelineProjectPath + "/sources/" ) except: shutil.copy( os.path.dirname(ArdourFilePath) + "/sounds/" + SourceName, - NonTimelineProjectPath + "/sources/" ) + NonTimelineProjectPath + "/sources/" ) - History.write ("Audio_Region " + RegionID + - " create :source \"" + Sources[n2.attrib["source-" + ( "%i" % chan )]].attrib["name"] + + History.write ("Audio_Region " + RegionID + + " create :source \"" + SourceName + "\" :start " + n2.attrib["position"] + " :length " + n2.attrib["length"] + " :offset " + n2.attrib["start"] +