Browse Source

Timeline: Update syntax of impor-ardour-session script to work with python3.

tags/non-daw-v1.2.0
Jonathan Moore Liles 10 years ago
parent
commit
467e369cd1
1 changed files with 28 additions and 28 deletions
  1. +28
    -28
      timeline/bin/import-ardour-session

+ 28
- 28
timeline/bin/import-ardour-session View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python2

# Copyright (C) 2013 Jonathan Moore Liles #
# #
@@ -24,7 +24,7 @@ from datetime import date
import shutil

if len(sys.argv) == 1:
print "Usage: import-ardour-session [PATH_TO_ARDOUR_FILE] [NAME_OF_NON_TIMELINE_PROJECT]"
print( "Usage: import-ardour-session [PATH_TO_ARDOUR_FILE] [NAME_OF_NON_TIMELINE_PROJECT]" )
sys.exit( 1 )

Overwrite=False
@@ -45,13 +45,13 @@ try:
os.makedirs( NonTimelineProjectPath + "/sources");
except:
if not Overwrite:
print "Output path already exists!"
print( "Output path already exists!" )
sys.exit( 1 )

try:
tree = et.parse( ArdourFilePath );
except:
print "Invalid XML input"
print( "Invalid XML input" )
sys.exit( 1 )

root = tree.getroot();
@@ -59,39 +59,39 @@ root = tree.getroot();
Sources = {}
DiskStreams = {}

print "Gathering session info"
print( "Gathering session info" )
if root.tag != "Session":
print "Not an Ardour session?"
print( "Not an Ardour session?" )
sys.exit(1)

print "Ardour session file version is " + root.attrib["version"]
print "This program is known to work with versions <= 3.0.1"
print( "Ardour session file version is " + root.attrib["version"] )
print( "This program is known to work with versions <= 3.0.1" )

ProjectName = root.attrib["name"]

print "Converting Ardour session \"" + ProjectName + "\" to Non Timeline format. Please be patient."
print( "Converting Ardour session \"" + ProjectName + "\" to Non Timeline format. Please be patient." )


print "Gathering sources."
print( "Gathering sources." )
for node in root.findall( "./Sources/Source" ):
Sources[node.attrib["id"]] = node;
# print "\tFound source " + node.attrib["name"]
# print( "\tFound source " + node.attrib["name"] )

print "Gathering version 3 diskstreams."
print( "Gathering version 3 diskstreams." )
for node in root.findall( "./Routes/Route/Diskstream" ):
DiskStreams[node.attrib["id"]] = node;
print "\tFound diskstream " + node.attrib["name"];
print( "\tFound diskstream " + node.attrib["name"] )

print "Gathering version 2 diskstreams."
print( "Gathering version 2 diskstreams." )
for node in root.findall( "./DiskStreams/AudioDiskstream" ):
DiskStreams[node.attrib["id"]] = node;
# print "\tFound diskstream " + node.attrib["name"];
# print( "\tFound diskstream " + node.attrib["name"]; )


print "Gathering version 1 diskstreams."
print( "Gathering version 1 diskstreams." )
for node in root.findall( "./DiskStreams/DiskStream" ):
DiskStreams[node.attrib["id"]] = node;
# print "\tFound diskstream " + node.attrib["name"];
# print( "\tFound diskstream " + node.attrib["name"]; )

LoggableID = 1;

@@ -104,7 +104,7 @@ def NewID():

History = "{\n"

print "Processing tempo."
print( "Processing tempo." )

for node in root.findall("./TempoMap/Tempo"):
TempoID = NewID()
@@ -120,7 +120,7 @@ for node in root.findall("./TempoMap/Meter"):
History += ( "\tTime_Point " + TimeID + " create :start 0 :beats_per_bar " + BPB + " :beat_type " + node.attrib["note-type"] + "\n")

print "Processing playlists."
print( "Processing playlists." )
for node in root.findall( "./Playlists/Playlist" ):
try:
@@ -129,12 +129,12 @@ for node in root.findall( "./Playlists/Playlist" ):
try:
Track = DiskStreams[node.attrib["orig-track-id"]]
except:
print "\tSkipping playlist " + node.attrib["name"] + " for unknown diskstream"
print( "\tSkipping playlist " + node.attrib["name"] + " for unknown diskstream" )
continue

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()
@@ -164,7 +164,7 @@ for node in root.findall( "./Playlists/Playlist" ):
elif os.path.exists( APath2 + SourceName ):
SourceName = APath2 + SourceName
else:
print "source not found!"
print( "source not found!" )
SourceList.append( "'" + SourceName + "'" );
@@ -174,13 +174,13 @@ for node in root.findall( "./Playlists/Playlist" ):
OutputName = NonTimelineProjectPath + "/sources/" + SourceName
if not os.path.exists( OutputName ):
print "Combining multifile source into multichannel source"
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;
print( "\t\tCopying source: " + SourceName )
try:
shutil.copy( os.path.dirname(ArdourFilePath) + "/interchange/" + ProjectName + "/audiofiles/" + SourceName,
@@ -197,17 +197,17 @@ for node in root.findall( "./Playlists/Playlist" ):
" :offset " + n2.attrib["start"] +
" :sequence " + SequenceID + "\n")
else:
print "\tSkipping inactive playlist"
print( "\tSkipping inactive playlist" )

History += ("}\n")

print "Comitting to disk."
print( "Comitting to disk." )

with open( NonTimelineProjectPath + "/info", 'w' ) as InfoFile:
try:
SampleRate = root.attrib["sample-rate"]
except:
print "Couldn't find sample rate... Using default."
print( "Couldn't find sample rate... Using default." )
SampleRate = "48000"
InfoFile.write( "created by\n\tNon-Timeline 1.2.0\ncreated on\n\t" + date.today().ctime() + "\nversion\n\t2\nsample rate\n\t" + SampleRate + "\n" )
@@ -215,5 +215,5 @@ with open( NonTimelineProjectPath + "/info", 'w' ) as InfoFile:
with open( NonTimelineProjectPath + "/history", 'w' ) as HistoryFile:
HistoryFile.write( History )
print "Done. You've been freed. Go make music!"
print( "Done. You've been freed. Go make music!" )


Loading…
Cancel
Save