--- /dev/null
+%{
+Converted from star.mup with the aid of mup-to-ly.py
+%}
+\header{
+title="The Star Spangled Banner";
+subtitle="(The United States National Anthem)";
+poet="Text: Francis Scott Key";
+composer="Tune: J. S. Smith";
+arranger="Arr: William J. Krauss";
+}
+
+$staff1_voice_1 = \notes {
+ [a8.()fis16] d4 fis4 a4 d'2 [fis'8. e'16] d'4 fis4 gis4 a2 [a8 a8] fis'4. e'8
+ d'4 cis'2 [b8. cis'16] d'4 d'4 a4 fis4 d4 [a8. fis16] fis4 d4 [fis'8.
+ fis'16] fis'4 g'4 a'4 a'2 [g'8 fis'8] e'4 fis'4 g'4 g'2 g'4 fis'4. e'8 d'4
+ cis'2 [b8. cis'16] d'4 fis4 gis4 a2 a4 d'4 d'4 [d'8()cis'8] b4 b4 b4 e'4 [g'8
+()fis'8] [e'8()d'8] d'4~cis'4 [a8. a16] d'4.~e'8 [fis'8 g'8] a'2 [d'8 e'8]
+ fis'4. g'8 e'4 d'2 s4 }
+
+$staff1_voice_2 = \notes {
+ [a8.()fis16] a,4 d4 e4 d4~fis4 [fis8. fis16] fis4 d4 d4 cis2 [e8 e8] a4. a8
+ a4 a2 [a8. a16] a4 a4 a4 fis4 d4 [a8. fis16] fis4 d4 r4 a4 a4 d'4 d'2
+ [a8 a8] cis'4 cis'4 cis'4 cis'2 a4 a4. a8 a4 a2 [a8. a16] d4 d4 d4
+ cis2 e4 fis4 e4 d4 d4 d4 dis4 g4 [g8()dis8] e4 e2 [e8. e16] d4.~a8 [a8 a8]
+ a2 [g8 g8] a4. a8 g4 fis2 s4 }
+
+$staff2_voice_1 = \notes {
+ r4 fis4 a4 a4 b2 [cis'8. cis'16] b4 b4 b4 a2 [cis'8 cis'8] d'4. cis'8
+ d'4 e'2 [e'8. e'16] d'4 d'4 a4 fis4 d4 r4 fis4 d4 r4 d4 e4 fis4 fis'2
+ [e'8 d'8] e'4 e'4 e'4 e'2 cis'4 d'4. cis'8 d'4 e'2 [e'8. e'16] a4 a4
+ e4 e2 cis'4 a4 a4 a4 g4 g4 b4 b4 b4 b4 a2 [cis'8. cis'16] a4.~cis'8
+ [d'8 d'8] d'2 [d'8 d'8] d'4. d'8 cis'4 a2 s4 }
+
+$staff2_voice_2 = \notes {
+ r4 d4 d4 cis4 b,2 [ais,8. ais,16] b,4 b,4 e4 a,2 [a8 a8] d4. e8 [fis8 g8]
+ a2 [g8. g16] fis4 fis4 a4 fis4 d4 r4 fis4 d4 r4 d4 d4 d4 d2 [d8 d8] a4
+ a4 a4 a2 a,4 d4. e8 [fis8 g8] a2 [g8. g16] fis4 d4 e4 a,2 a4 d4 e4 fis4
+ g4 g4 fis4 e4 [e8()fis8] [g8()gis8] a2 [g8. g16] fis4.~a,8 [d8 e8] fis2 [b8 b8]
+ a4. a8 a,4 d2 s4 }
+
+$text1 = \lyrics{
+ Oh say. can you see, by the dawn's ear- ly light What_so proud- ly we hailed,
+ At the twi- light's last gleam- ing. Whose broad
+}
+
+$text2 = \lyrics{
+ _ stripes and bright stars, through the per- il- ous fight, O'er the ram- parts
+ we watched, were so gal- lant- ly _ _ _
+}
+
+$text3 = \lyrics{
+ stream- ing. And the rock- ets' red glare, the bombs burst- ing in air, gave
+ proof through the night that our flag was still there, _ Oh say, does that
+ star- span- gled ban- ner yet wave, _ O'er the land _ of_the free and_the
+ home of the brave.
+}
+
+global = \notes {
+ \time 3/4;
+ \key D;
+ \partial 4;
+ \skip 4;
+ \bar "|:";
+ \skip 2.*8;
+ \bar ":|";
+ \skip 2.*16;
+ \skip 2.;
+ \bar "|.";
+ }
+
+\score{
+ \type GrandStaff <
+ <
+ \type Staff=staffA <
+ \global
+ \notes \transpose c'' {\voiceone \$staff1_voice_1 }
+ \notes \transpose c'' {\voicetwo \$staff1_voice_2 }
+ >
+ \type Lyrics = middle <
+ \lyrics \$text1
+ \lyrics { \$text2 \$text3 }
+ >
+ \type Staff=staffB <
+ \global
+ \clef bass;
+ {\voiceone \$staff2_voice_1 }
+ {\voicetwo \$staff2_voice_2 }
+ >
+ >
+ >
+ \paper{
+ \include "bar-numbering.ly"
+ }
+}
--- /dev/null
+#!/usr/bin/python
+#!@PYTHON@
+
+# mup-to-ly.py --
+#
+# source file of the GNU LilyPond music typesetter
+#
+# (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
+
+name = 'mup-to-ly'
+version = '0.1'
+
+import os
+import sys
+
+import getopt
+from string import *
+import regex
+import regsub
+import time
+
+def program_id ():
+ return name + ' version ' + version;
+
+def identify ():
+ sys.stdout.write (program_id () + '\n')
+
+def help ():
+ sys.stdout.write ("Usage: %s [options] [files]\n"
+ "Convert mup to ly\n\n"
+ + "Options:\n"
+ + " -h, --help print this help\n"
+ % (program_name)
+ )
+ sys.exit (0)
+
+identify ()
+(options, files) = getopt.getopt (
+ sys.argv[1:], 'hp:', ['help', 'package'])
+for opt in options:
+ o = opt[0]
+ a = opt[1]
+ if o== '--help' or o == '-h':
+ help ()
+ elif o == '-p' or o == '--package':
+ topdir = a
+ else:
+ print o
+ raise getopt.error
+
+def gulp_file (f):
+ sys.stderr.write ('[%s' % f)
+ try:
+ i = open (f)
+ i.seek (0, 2)
+ n = i.tell ()
+ i.seek (0,0)
+ except:
+ sys.stderr.write ('can\'t open file %s\n ' % f)
+ return ''
+ s = i.read (n)
+ sys.stderr.write (']')
+ if len (s) <= 0:
+ sys.stderr.write ('gulped empty file: %s\n'% f)
+ return s
+
+def line_to_ly (s):
+ notes = ""
+ o = 0
+ i = regex.search (";", s)
+ last_name = "c"
+ last_duration = "4"
+ while i >= 0:
+ note = s[o:o+i]
+ o = o + i
+ i = regex.search (";", s[o+1:])
+ if i >= 0 :
+ o = o + 1
+ name = regsub.gsub ("[0-9<>\.&]*", "", note)
+ duration = regsub.gsub ("[a-z+<>#+&\-]*", "", note)
+ duration = regsub.gsub (" ", "", duration)
+ if name:
+ last_name = name
+ else:
+ name = last_name
+ if duration:
+ last_duration = duration
+ else:
+ duration = last_duration
+ name = regsub.sub ("#", "is", name)
+ name = regsub.sub ("+", "'", name)
+ name = regsub.sub ("-", ",", name)
+ name = regsub.sub ("ms", "s1", name)
+ notes = notes + " %s%s" % (name, duration)
+ return notes
+
+def get_voice (staff, s, staffs):
+ voice = len (staffs[staff-1]) + 1
+ tag = "^%d [0-9-]*%d[0-9-]*:" % (staff, voice)
+ notes = ""
+ o = 0
+ i = regex.search (tag, s)
+ while i >= 0:
+ o = o + i
+ n = regex.search ("$", s[o:])
+ line = s[o:o+n]
+ line = regsub.sub (tag, "", line)
+ line = line_to_ly (line)
+ notes = notes + line
+ i = regex.search (tag, s[o+n:])
+ if i >= 0:
+ i = i + n
+ if notes != "":
+ sys.stderr.write ('%d ' % voice)
+ staffs[staff-1].append (notes)
+ return notes != ""
+
+def get_staff (s, staffs):
+ staff=len (staffs)
+ i=1
+ sys.stderr.write ('Staff %d ( ' % staff)
+ while i:
+ i = get_voice (staff, s, staffs)
+ if not i:
+ sys.stderr.write (')\n')
+ staffs.append ([])
+ staff = staff + 1
+ sys.stderr.write ('Staff %d ( ' % staff)
+ i = get_voice (staff, s, staffs)
+ if not i:
+ del staffs[staff-1]
+ return 0
+
+staffs=[[]]
+mup=files[0]
+ly = os.path.basename (os.path.splitext (mup)[0]) + ".ly"
+s = gulp_file (mup)
+sys.stderr.write ('\n')
+i=1
+while i:
+ i=get_staff (s, staffs)
+sys.stderr.write ('\n')
+sys.stderr.write ('Ly output to: %s...' % ly)
+lyfile = open (ly, "w")
+for i in range (len (staffs)):
+ for v in range (len (staffs[i])):
+ lyfile.write ("$staff%d_voice_%d = \\notes {\n %s\n}\n\n" % (i+1, v+1, staffs[i][v]))
+lyfile.write ("\\score{\n")
+lyfile.write ("\\notes <\n")
+for i in range (len (staffs)):
+ lyfile.write ("\\type Staff=staff%s <\n" % chr(ord('A')+i))
+ for v in range (len (staffs[i])):
+ lyfile.write ("{ \\$staff%d_voice_%d } " % (i+1, v+1))
+ lyfile.write ("\n>\n")
+lyfile.write (">\n")
+lyfile.write ("\n}")
+lyfile.close ()
+sys.stderr.write ('\n')