]> git.donarmstrong.com Git - lilypond.git/commitdiff
partial: 1.1.56.jcn
authorJan Nieuwenhuizen <janneke@gnu.org>
Sun, 11 Jul 1999 20:23:58 +0000 (22:23 +0200)
committerJan Nieuwenhuizen <janneke@gnu.org>
Sun, 11 Jul 1999 20:23:58 +0000 (22:23 +0200)
midi2ly/include/mi2mu-global.hh [deleted file]
midi2ly/include/midi2ly-global.hh [new file with mode: 0644]
midi2ly/mi2mu-version.cc [deleted file]
midi2ly/midi2ly-version.cc [new file with mode: 0644]
scripts/mup-to-ly.py [deleted file]
scripts/mup2ly.py [new file with mode: 0644]

diff --git a/midi2ly/include/mi2mu-global.hh b/midi2ly/include/mi2mu-global.hh
deleted file mode 100644 (file)
index 4ed873f..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-//
-// mi2mu-global.hh -- declare global (sic) stuff for mi2mu
-//
-// copyright 1997 Jan Nieuwenhuizen <janneke@gnu.org>
-
-#ifndef MI2MU_GLOBAL_HH
-#define MI2MU_GLOBAL_HH
-
-#include "string.hh"
-#include "proto.hh"
-
-#define monitor_p_g &cout
-enum Verbose { QUIET_ver, BRIEF_ver, NORMAL_ver, VERBOSE_ver, DEBUG_ver };
-extern Verbose level_ver;
-#if 0 // NPRINT
-    // not what i want, all output goes through tors.
-    // set verbosity level.
-    #define LOGOUT(threshold) if  (0) *monitor_p_g
-#else
-    #define LOGOUT(threshold) if  (level_ver >= threshold) *monitor_p_g
-#endif
-
-extern Sources* source_l_g;
-// huh?
-void message (String message_str); //, char const* context_ch_C);
-void warning (String message_str); //, char const* context_ch_C);
-void error (String message_str); //, char const* context_ch_C);
-
-String mi2mu_version_str();
-extern bool no_timestamps_b_g;;
-
-#endif // MI2MU_GLOBAL_HH
-
diff --git a/midi2ly/include/midi2ly-global.hh b/midi2ly/include/midi2ly-global.hh
new file mode 100644 (file)
index 0000000..f6c9051
--- /dev/null
@@ -0,0 +1,33 @@
+//
+// midi2ly-global.hh -- declare global (sic) stuff for midi2ly
+//
+// copyright 1997 Jan Nieuwenhuizen <janneke@gnu.org>
+
+#ifndef MIDI2LY_GLOBAL_HH
+#define MIDI2LY_GLOBAL_HH
+
+#include "string.hh"
+#include "proto.hh"
+
+#define monitor_p_g &cout
+enum Verbose { QUIET_ver, BRIEF_ver, NORMAL_ver, VERBOSE_ver, DEBUG_ver };
+extern Verbose level_ver;
+#if 0 // NPRINT
+    // not what i want, all output goes through tors.
+    // set verbosity level.
+    #define LOGOUT(threshold) if  (0) *monitor_p_g
+#else
+    #define LOGOUT(threshold) if  (level_ver >= threshold) *monitor_p_g
+#endif
+
+extern Sources* source_l_g;
+// huh?
+void message (String message_str); //, char const* context_ch_C);
+void warning (String message_str); //, char const* context_ch_C);
+void error (String message_str); //, char const* context_ch_C);
+
+String midi2ly_version_str();
+extern bool no_timestamps_b_g;;
+
+#endif // MIDI2LY_GLOBAL_HH
+
diff --git a/midi2ly/mi2mu-version.cc b/midi2ly/mi2mu-version.cc
deleted file mode 100644 (file)
index 113512d..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-//
-// version.cc -- implement inexpensive versioning
-//
-// copyright 1997 Jan Nieuwenhuizen <janneke@gnu.org>
-
-#include <stdio.h>
-#include "config.hh"
-#include "version.hh"
-
-#define VERSION_SZ  MAJOR_VERSION "." MINOR_VERSION "."  PATCH_LEVEL "." MY_PATCH_LEVEL
-
-static char *s = "mi2mu " VERSION_SZ;
-
-
-const char * 
-mi2mu_version_sz()
-{
-  return s;
-}
-
diff --git a/midi2ly/midi2ly-version.cc b/midi2ly/midi2ly-version.cc
new file mode 100644 (file)
index 0000000..ac0b8c1
--- /dev/null
@@ -0,0 +1,20 @@
+//
+// version.cc -- implement inexpensive versioning
+//
+// copyright 1997 Jan Nieuwenhuizen <janneke@gnu.org>
+
+#include <stdio.h>
+#include "config.hh"
+#include "version.hh"
+
+#define VERSION_SZ  MAJOR_VERSION "." MINOR_VERSION "."  PATCH_LEVEL "." MY_PATCH_LEVEL
+
+static char *s = "midi2ly " VERSION_SZ;
+
+
+const char * 
+midi2ly_version_sz()
+{
+  return s;
+}
+
diff --git a/scripts/mup-to-ly.py b/scripts/mup-to-ly.py
deleted file mode 100644 (file)
index c9eb62d..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-#!@PYTHON@
-
-# mup-to-ly.py -- 
-# 
-# source file of the GNU LilyPond music typesetter
-# 
-# (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
-
-# TODO: regex -> re.
-
-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')
diff --git a/scripts/mup2ly.py b/scripts/mup2ly.py
new file mode 100644 (file)
index 0000000..c9eb62d
--- /dev/null
@@ -0,0 +1,159 @@
+#!@PYTHON@
+
+# mup-to-ly.py -- 
+# 
+# source file of the GNU LilyPond music typesetter
+# 
+# (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
+
+# TODO: regex -> re.
+
+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')