view patches/0001-Midi2ly-new-option-include-header.-Allows-titling-an.patch @ 6512:ccc20ae889ca default tip guix

mingw::guile-2.0.7 builds.
author Jan Nieuwenhuizen <janneke@gnu.org>
date Thu, 24 Mar 2016 08:03:39 +0100
parents fb2d592c16e7
children
line wrap: on
line source

From 65085ea0c3ac6b155aa0828d4c5ccf1baf91d9dc Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Tue, 1 Mar 2011 14:47:38 +0100
Subject: [PATCH] Midi2ly: new option: --include-header.  Allows titling and customizing.

---
 scripts/midi2ly.py |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/scripts/midi2ly.py b/scripts/midi2ly.py
index af47460..f831123 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'),
-- 
1.7.1