andy baxter wrote:
Hello,
Does anyone know if there's a way to display recorded midi tracks in
Rosegarden with a double staff, treble and bass clef, the way piano
music is usually written?
I'm posting this in case anyone else has a similar problem. I've written
a short script (attached) in Python which takes a lilypond file output
by Rosegarden and converts it to piano stave format, then runs lilypond
on the result to make a pdf.
I've only tested it on single track, single segment files so far, so it
may fail with more complex files. To use it just export your rosegarden
session to lilypond format, then run 'pianoconv.py filename.ly'
If you don't want the intermediate files to be cleaned up afterwards,
comment out the lines indicated in the source.
Hope someone finds this useful.
Andy
#!/usr/bin/python
import re, sys, os
if len(sys.argv) < 2:
print "No filename given"
sys.exit(1)
fInName=sys.argv[1]
fOutName=re.compile("\.ly$").sub(".conv.ly",fInName)
print fOutName
reStaff=re.compile("Staff")
rePianoStart=re.compile("\\context PianoStaff = \".*?\"")
reVoiceStart=re.compile("\\context Voice = \".*?\"")
try:
print "Opening file: "+fInName
fOut=open(fOutName,'w')
print "Converting file..."
for line in open(fInName):
line=reStaff.sub("PianoStaff",line)
mo=rePianoStart.search(line)
if mo:
end=mo.end()
line=line[:end]+" \\autochange "+line[end+1:]
mo=reVoiceStart.search(line)
if mo:
end=mo.end()
line=line[:end]+" \\autochange "+line[end+1:]
fOut.write(line)
fOut.close()
print "Running lilypond on converted file: "+fOutName+" ..."
lilyOutName=re.compile("\.ly$").sub("",fOutName)
os.system("lilypond -o \""+ lilyOutName+"\" \""+fOutName+"\"")
# comment out the next 2 lines if you want the intermediate files to be left in place.
print "Cleaning up..."
os.system("rm "+lilyOutName+".ly "+lilyOutName+".ps")
print "\nDone."
except IOError,err:
import errno
if err.errno != errno.ENOENT: raise
else:
print "Can't open file: " + fInName
sys.exit(2)
_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@xxxxxxxxxxxxxxxxxxxx
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-user