+++ /dev/null
-//
-// 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
-
--- /dev/null
+//
+// 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
+
+++ /dev/null
-//
-// 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;
-}
-
--- /dev/null
+//
+// 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;
+}
+
+++ /dev/null
-#!@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')
--- /dev/null
+#!@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')