From cdbb2c05f1a8a531e4504c9352969638bdc0c0af Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 26 Mar 2002 22:23:32 +0000 Subject: [PATCH] lilypond-1.1.56 --- midi2ly/include/mi2mu-global.hh | 33 -- midi2ly/include/mi2mu-proto.hh | 29 -- midi2ly/mi2mu-version.cc | 20 -- scripts/abc-2-ly.py | 617 -------------------------------- scripts/mup-to-ly.py | 159 -------- tex/fetdefs.tex | 3 - 6 files changed, 861 deletions(-) delete mode 100644 midi2ly/include/mi2mu-global.hh delete mode 100644 midi2ly/include/mi2mu-proto.hh delete mode 100644 midi2ly/mi2mu-version.cc delete mode 100644 scripts/abc-2-ly.py delete mode 100644 scripts/mup-to-ly.py delete mode 100644 tex/fetdefs.tex diff --git a/midi2ly/include/mi2mu-global.hh b/midi2ly/include/mi2mu-global.hh deleted file mode 100644 index 4ed873fb54..0000000000 --- a/midi2ly/include/mi2mu-global.hh +++ /dev/null @@ -1,33 +0,0 @@ -// -// mi2mu-global.hh -- declare global (sic) stuff for mi2mu -// -// copyright 1997 Jan Nieuwenhuizen - -#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/mi2mu-proto.hh b/midi2ly/include/mi2mu-proto.hh deleted file mode 100644 index d8ad1368e4..0000000000 --- a/midi2ly/include/mi2mu-proto.hh +++ /dev/null @@ -1,29 +0,0 @@ -/* - mi2mu-proto.hh -- declare type names in mi2mu - - source file of mi2mu, part of the GNU LilyPond package, - - (c) 1997--1998 Han-Wen Nienhuys -*/ - - -#ifndef MI2MU_PROTO_HH -#define MI2MU_PROTO_HH - -class Midi_parser; -struct Midi_parser_info; -class Midi_score_parser; -class Midi_track_parser; -class Mudela_stream; -class Mudela_item; -class Mudela_key; -class Mudela_time_signature; -class Mudela_note; -class Mudela_tempo; -class Mudela_text; -class Mudela_score; -class Mudela_staff; -class Mudela_voice; -class Mudela_column; - -#endif // MI2MU_PROTO_HH diff --git a/midi2ly/mi2mu-version.cc b/midi2ly/mi2mu-version.cc deleted file mode 100644 index 113512d363..0000000000 --- a/midi2ly/mi2mu-version.cc +++ /dev/null @@ -1,20 +0,0 @@ -// -// version.cc -- implement inexpensive versioning -// -// copyright 1997 Jan Nieuwenhuizen - -#include -#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/scripts/abc-2-ly.py b/scripts/abc-2-ly.py deleted file mode 100644 index dd4bcf2637..0000000000 --- a/scripts/abc-2-ly.py +++ /dev/null @@ -1,617 +0,0 @@ -#!@PYTHON@ - -# once upon a rainy monday afternoon. -# -# ... -# -# (not finished.) -# ABC standard v1.6: http://www.gre.ac.uk/~c.walshaw/abc2mtex/abc.txt -# - -program_name = 'abc-to-ly' -version = '@TOPLEVEL_VERSION@' -import __main__ -import getopt -import sys -import re -import string -try: - import mpz -except: - sys.stderr.write ("This script needs Python 1.5.1\n") - sys.exit (1) - - -header = {} -lyrics = [] -voices = [] -global_voice_stuff = [] -default_len = 4 -global_key = [0] * 7 # UGH -names = ["One", "Two", "Three"] -DIGITS='0123456789' -HSPACE=' \t' - -def gcd (a, b): - while a % b: - a,b = b, a % b - return b - -class Rational: - def __init__ (self, n, d = 1): - self.num = n - self.den = d - - def simplify (self): - g = gcd (self.num, self.den) - self.num = self.num / g - self.den = self.den /g - if self.den < 0: - self.den = - self.den - self.num = - self.num - - def __sub__ (self, other): - pass - - -def dump_global (): - print ("global = \\notes{") - for i in global_voice_stuff: - print (i); - print ("}") - - -def dump_header (hdr): - print '\\header {' - for k in hdr.keys (): - print '%s = "%s";\n'% (k,hdr[k]) - print '}' - -def dump_lyrics (): - for i in range (len (lyrics)): - print ("verse%s = \\lyrics {" % names [i]) - print (lyrics [i]) - print ("}") - -def dump_voices (): - for i in range (len (voices)): - print ("voice%s = \\notes {" % names [i]) - print (voices [i]) - print ("}") - -def dump_score (): - print ("\\score{") - print (" \\notes<") - print (" \\global") - for i in range (len (voices)): - print (" \\context Staff=%s \\voice%s" % - (names [i], names [i])) - for i in range (len (lyrics)): - j = i - if j >= len (voices): - j = len (voices) - 1 - print (" \\context Lyrics=%s \\rhythm \\voice%s \\verse%s" % - (names [i], names [j], names [i])) - print (" >") - dump_header (header) - #print "%%%s" % global_voice_stuff, 1 - print ("}") - -def set_default_length (s): - m = re.search ('1/([0-9]+)', s) - if m: - __main__.default_len = string.atoi ( m.group (1)) - -def gulp_file(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) - if len (s) <= 0: - sys.stderr.write ("gulped emty file: %s\n" % f) - i.close () - return s - - -# pitch manipulation. Tuples are (name, alteration). -# 0 is (central) C. Alteration -1 is a flat, Alteration +1 is a sharp -# pitch in semitones. -def semitone_pitch (tup): - p =0 - - t = tup[0] - p = p + 12 * (t / 7) - t = t % 7 - - if t > 2: - p = p- 1 - - p = p + t* 2 + tup[1] - return p - -def fifth_above_pitch (tup): - (n, a) = (tup[0] + 4, tup[1]) - - difference = 7 - (semitone_pitch ((n,a)) - semitone_pitch (tup)) - a = a + difference - - return (n,a) - -def sharp_keys (): - p = (0,0) - l = [] - k = 0 - while 1: - l.append (p) - (t,a) = fifth_above_pitch (p) - if semitone_pitch((t,a)) % 12 == 0: - break - - p = (t % 7, a) - return l - -def flat_keys (): - p = (0,0) - l = [] - k = 0 - while 1: - l.append (p) - (t,a) = quart_above_pitch (p) - if semitone_pitch((t,a)) % 12 == 0: - break - - p = (t % 7, a) - return l - -def quart_above_pitch (tup): - (n, a) = (tup[0] + 3, tup[1]) - - difference = 5 - (semitone_pitch ((n,a)) - semitone_pitch (tup)) - a = a + difference - - return (n,a) - - -def compute_key (k): - k = string.lower (k) - intkey = (ord (k[0]) - ord('a') + 5) % 7 - intkeyacc =0 - k = k[1:] - - if k and k[0] == 'b': - intkeyacc = -1 - k = k[1:] - elif k and k[0] == '#': - intkeyacc = 1 - k = k[1:] - - keytup = (intkey, intkeyacc) - - sharp_key_seq = sharp_keys () - flat_key_seq = flat_keys () - - accseq = None - accsign = 0 - if keytup in sharp_key_seq: - accsign = 1 - key_count = sharp_key_seq.index (keytup) - accseq = map (lambda x: (4*x -1 ) % 7, range (1, key_count + 1)) - - elif keytup in flat_key_seq: - accsign = -1 - key_count = flat_key_seq.index (keytup) - accseq = map (lambda x: (3*x + 3 ) % 7, range (1, key_count + 1)) - else: - raise "Huh" - - key_table = [0] * 7 - for a in accseq: - key_table[a] = key_table[a] + accsign - - - return key_table - -tup_lookup = { - '3' : '2/3', - '4' : '4/3', - '5' : '4/5', - '6' : '4/6', - } - - -def try_parse_tuplet_begin (str, state): - if str and str[0] in DIGITS: - dig = str[0] - str = str[1:] - state.parsing_tuplet = 1 - - voices_append ("\\times %s {" % tup_lookup[dig]) - return str - -def try_parse_group_end (str, state): - if str and str[0] in HSPACE: - str = str[1:] - if state.parsing_tuplet: - state.parsing_tuplet = 0 - voices_append ("}") - return str - -def header_append (key, a): - s = '' - if header.has_key (key): - s = header[key] + "\n" - header [key] = s + a - -def lyrics_append (a): - i = len (lyrics) - 1 - if i < 0: - i = 0 - if len (lyrics) <= i: - lyrics.append ('') - lyrics [i] = lyrics [i] + a + "\n" - -def voices_append (a): - i = len (voices) - 1 - if i < 0: - i = 0 - if len (voices) <= i: - voices.append ('') - voices [i] = voices [i] + a + "\n" - -def try_parse_header_line (ln): - m = re.match ('^(.): *(.*)$', ln) - - if m: - g =m.group (1) - a = m.group (2) - a = re.sub ('"', '\\"', a) - if g == 'T': - header['title'] = a - if g == 'M': - if a == 'C': - a = '4/4' - global_voice_stuff.append ('\\time %s;' % a) - if g == 'K': - __main__.global_key =compute_key (a)# ugh. - - global_voice_stuff.append ('\\key %s;' % a) - if g == 'O': - header ['origin'] = a - if g == 'X': - header ['crossRefNumber'] = a - if g == 'A': - header ['area'] = a - if g == 'H': - header_append ('history', a) - if g == 'B': - header ['book'] = a - if g == 'S': - header ['subtitle'] = a - if g == 'L': - set_default_length (ln) - if g == 'W': - if not len (a): - lyrics.append ('') - else: - lyrics_append (a); - return m - -def pitch_to_mudela_name (name, acc): - s = '' - if acc < 0: - s = 'es' - acc = -acc - elif acc > 0: - s = 'is' - - if name > 4: - name = name -7 - return chr (name + ord('c')) + s * acc - -def octave_to_mudela_quotes (o): - o = o + 2 - s ='' - if o < 0: - o = -o - s=',' - else: - s ='\'' - - return s * o - -def parse_num (str): - durstr = '' - while str and str[0] in DIGITS: - durstr = durstr + str[0] - str = str[1:] - - n = None - if durstr: - n =string.atoi (durstr) - return (str,n) - - -def duration_to_mudela_duration (multiply_tup, defaultlen, dots): - base = 1 - - # (num / den) / defaultlen < 1/base - while base * multiply_tup[0] < defaultlen * multiply_tup[1]: - base = base * 2 - - - return '%d%s' % ( base, '.'* dots) - -class Parser_state: - def __init__ (self): - self.next_dots = 0 - self.next_den = 1 - self.parsing_tuplet = 0 - - -# WAT IS ABC EEN ONTZETTENDE PROGRAMMEERPOEP ! -def try_parse_note (str, parser_state): - mud = '' - - slur_begin =0 - if not str: - return str - - if str[0] == '(': - slur_begin = 1 - str = str[1:] - - acc = 0 - if str[0] in '^=_': - c = str[0] - str = str[1:] - if c == '^': - acc = 1 - if c == '=': - acc = 0 - if c == '_': - acc = -1 - - octave = 0; - if str[0] in "ABCDEFG": - str = string.lower (str[0]) + str[1:] - octave = -1 - - - notename = 0 - if str[0] in "abcdefg": - notename = (ord(str[0]) - ord('a') + 5)%7 - str = str[1:] - else: - return str # failed; not a note! - - while str[0] == ',': - octave = octave - 1 - str = str[1:] - while str[0] == '\'': - octave = octave + 1 - str = str[1:] - - num = 0 - den = parser_state.next_den - parser_state.next_den = 1 - - (str, num) = parse_num (str) - if not num: - num = 1 - - if str[0] == '/': - while str[0] == '/': - str= str[1:] - d = 2 - if str[0] in DIGITS: - (str, d) =parse_num (str) - - den = den * d - - current_dots = parser_state.next_dots - parser_state.next_dots = 0 - while str[0] == '>': - str = str [1:] - current_dots = current_dots + 1; - parser_state.next_den = parser_state.next_den * 2 - - while str[0] == '<': - str = str [1:] - den = den * 2 - parser_state.next_dots = parser_state.next_dots + 1 - - - - voices_append ("%s%s%s" % - (pitch_to_mudela_name (notename, acc + global_key[notename]), - octave_to_mudela_quotes (octave), - duration_to_mudela_duration ((num,den), default_len, current_dots))) - slur_end =0 - if str[0] == ')': - slur_begin = 1 - str = str[1:] - - - return str - -def junk_space (str): - while str and str[0] in '\t\n ': - str = str[1:] - - return str - - -def try_parse_guitar_chord (str): - if str and str[0] == '"': - str = str[1:] - gc = '' - while str and str[0] != '"': - gc = gc + str[0] - str = str[1:] - - if str: - str = str[1:] - - sys.stderr.write ("warning: ignoring guitar chord: %s\n" % gc) - - return str - -def try_parse_escape (str): - if not str or str [0] != '\\': - return str - - str = str[1:] - if str and str[0] == 'K': - key_table = compute_key () - - return str - -# -# |] thin-thick double bar line -# || thin-thin double bar line -# [| thick-thin double bar line -# :| left repeat -# |: right repeat -# :: left-right repeat -# - -def try_parse_bar (str): - if str and str[0] == '|': - bs = '' - str = str[1:] - if str: - if str[0] == ']': - bs = '|.' - if str[0] == '|': - bs = '||' - if str[0] == '|:': - sys.stderr.write ("warning: repeat kludge\n") - bs = '|:' - if bs: - voices_append ('\\bar "%s";' % bs) - str = str[1:] - - if str and str[:2] == '[|': - sys.stderr.write ("warning: thick-thin bar kludge\n") - voices_append ('\\bar "||";') - str = str[2:] - - if str and str[:2] == ':|': - sys.stderr.write ("warning: repeat kludge\n") - voices_append ('\\bar ":|:";') - str = str[2:] - - if str and str[:2] == '::': - sys.stderr.write ("warning: repeat kludge\n") - voices_append ('\\bar ":|:";') - str = str[2:] - - return str - - -def try_parse_chord_delims (str): - if str and str[0] == '[': - str = str[1:] - voices_append ('<') - - if str and str[0] == ']': - str = str[1:] - voices_append ('>') - - return str - -# urg, hairy to compute grace note hack using \times{} -def try_parse_grace_delims (str): - if str and str[0] == '{': - str = str[1:] - voices_append ('\\grace { ') - - if str and str[0] == '}': - str = str[1:] - voices_append ('}') - - return str - -# Try nibbling characters off until the line doesn't change. -def try_parse_body_line (ln, state): - prev_ln = '' - while ln != prev_ln: - prev_ln = ln - ln = try_parse_chord_delims (ln) - ln = try_parse_note (ln, state) - ln = try_parse_bar (ln) - ln = try_parse_escape (ln) - ln = try_parse_guitar_chord (ln) - ln = try_parse_tuplet_begin (ln, state) - ln = try_parse_group_end (ln, state) - ln = try_parse_grace_delims (ln) - ln = junk_space (ln) - - if ln: - sys.stderr.write ("Huh? Don't understand `%s'\n" % ln) - - - -def parse_file (fn): - f = open (fn) - ls = f.readlines () - - head = 1 - state = Parser_state () - for l in ls: - if re.match ('^[\t ]*(%.*)?$', l): - continue - - if head: - m = try_parse_header_line (l) - if not m: - head = 0 - - if not head: - m = try_parse_body_line (l,state) - - -def identify(): - sys.stderr.write ("%s from LilyPond %s\n" % (program_name, version)) - -def help (): - print r""" -This is a disfunctional ABC to mudela convertor. It only gulps input, and -says huh when confused. Go ahead and fix me. - -Usage: abc-2-ly INPUTFILE - --h, --help this help. -""" - - - -identify() -(options, files) = getopt.getopt (sys.argv[1:], 'h', ['help']) - -for opt in options: - o = opt[0] - a = opt[1] - if o== '--help' or o == '-h': - help () - else: - print o - raise getopt.error - - -for f in files: - if f == '-': - f = '' - parse_file (f) - - dump_global () - dump_lyrics () - dump_voices () - dump_score () - - diff --git a/scripts/mup-to-ly.py b/scripts/mup-to-ly.py deleted file mode 100644 index c9eb62d4b5..0000000000 --- a/scripts/mup-to-ly.py +++ /dev/null @@ -1,159 +0,0 @@ -#!@PYTHON@ - -# mup-to-ly.py -- -# -# source file of the GNU LilyPond music typesetter -# -# (c) 1998 Jan Nieuwenhuizen - -# 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/tex/fetdefs.tex b/tex/fetdefs.tex deleted file mode 100644 index 730b17a85b..0000000000 --- a/tex/fetdefs.tex +++ /dev/null @@ -1,3 +0,0 @@ -% fetdefs.tex -% encapsulating tex backend for auto-generated feta definitions -\endinput -- 2.39.5