From: Jan Nieuwenhuizen Date: Tue, 1 Mar 2011 13:47:38 +0000 (+0100) Subject: Midi2ly: new option: --include-header. Allows titling and customizing. X-Git-Tag: release/2.13.52-1~3^2~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=65085ea0c3ac6b155aa0828d4c5ccf1baf91d9dc;p=lilypond.git Midi2ly: new option: --include-header. Allows titling and customizing. --- diff --git a/scripts/midi2ly.py b/scripts/midi2ly.py index af47460a96..f831123c3e 100644 --- a/scripts/midi2ly.py +++ b/scripts/midi2ly.py @@ -917,10 +917,10 @@ def convert_midi (in_file, out_file): tag = '%% Lily was here -- automatically converted by %s from %s' % ( program_name, in_file) - s = '' - s = tag + '\n\\version "2.7.38"\n\n' - for i in range (len (tracks)): - s = s + dump_track (tracks[i], i) + s = tag + s += r''' +\version "2.7.38" +''' s += r''' \layout { @@ -932,6 +932,16 @@ def convert_midi (in_file, out_file): } ''' + for i in global_options.include_header: + s += '\n%% included from %(i)s\n' % locals () + s += open (i).read () + if s[-1] != '\n': + s += '\n' + s += '% end\n' + + for i in range (len (tracks)): + s = s + dump_track (tracks[i], i) + s += '\n\\score {\n <<\n' i = 0 @@ -975,6 +985,11 @@ def get_option_parser (): p.add_option('-h', '--help', action='help', help=_ ('show this help and exit')) + p.add_option('-i', '--include-header', + help=_ ('prepend FILE to output'), + action='append', + default=[], + metavar=_ ('FILE')) p.add_option('-k', '--key', help=_ ('set key: ALT=+sharps|-flats; MINOR=1'), metavar=_ ('ALT[:MINOR]'), default='0'),