]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scripts/midi2ly.py (Key.dump): pychecker cleanups.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 2 Mar 2006 10:50:40 +0000 (10:50 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 2 Mar 2006 10:50:40 +0000 (10:50 +0000)
* python/lilylib.py (underscore): remove identify() , warranty()

* ps/music-drawing-routines.ps: change Border routine for GSView
compatibility.

* lily/stem.cc (height): use quantize-positions.  This triggers
set_stem_lengths, so scripts on beamed stems are handled correctly.

* lily/side-position-interface.cc (aligned_side): check if edges
of script are inside staff. Fixes accent of edge of the staff.

* input/regression/staccato-pos.ly: more examples.

ChangeLog
THANKS
input/regression/staccato-pos.ly
lily/side-position-interface.cc
lily/stem.cc
ps/music-drawing-routines.ps
python/lilylib.py
scm/script.scm
scripts/convert-ly.py
scripts/lilypond-book.py
scripts/midi2ly.py

index 2219c732aeab6a8acd5c6832002fab3f960ccb1a..55c6613fff4375b75b6a1ef606bbda49fba192de 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
 2006-03-02  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * scripts/midi2ly.py (Key.dump): pychecker cleanups.
+
+       * python/lilylib.py (underscore): remove identify() , warranty()
+
+       * ps/music-drawing-routines.ps: change Border routine for GSView
+       compatibility.
+
+       * lily/stem.cc (height): use quantize-positions.  This triggers
+       set_stem_lengths, so scripts on beamed stems are handled correctly.
+
+       * lily/side-position-interface.cc (aligned_side): check if edges
+       of script are inside staff. Fixes accent of edge of the staff.
+
+       * input/regression/staccato-pos.ly: more examples.
+
        * stepmake/aclocal.m4 (depth): fix bashism.
 
        * lily/lyric-combine-music-iterator.cc: move from
diff --git a/THANKS b/THANKS
index 21078903a6bbc91912aa2b2b8d3373bd15695869..a600fa9b9cd20ce234b12d1ef7b8a6e097f5c96a 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -63,6 +63,7 @@ Darius Blasband
 David Bobroff
 Donald Axel
 Don Blaheta
+Dunstan Vavasour
 Edward Neeman
 Eduardo Vieira
 Ernesto Gancedo
@@ -89,6 +90,7 @@ Ralph Little
 Richard Schoeller
 Robert Vlatasy
 Roman Kurakin
+Russell Lang
 Scott Russell
 Sean Reed
 Seng Liang
index 322b8a0886ca89594e88abf8a74c8f725da446cd..a1ccc13477448e779f3291452bc850d73dc80583 100644 (file)
@@ -3,10 +3,10 @@
 
 \header{
 
-  texidoc=" The staccato dot (and all scripts with follow-into-staff
-set) must not be on staff lines. The staccato dot is close to the
-notehead. If the head is in a space, then the dot is in the space next
-to it.  "
+  texidoc=" Some scripts must have quantized postions. VErtical
+ position descend monotonously for a descending scale.  The staccato
+ dot is close to the notehead. If the head is in a space, then the dot
+ is in the space next to it.  "
 
 }
 
@@ -14,12 +14,16 @@ to it.  "
   ragged-right = ##t
 }
 
-
-\context Voice \relative c' {
-  e'4-. f-. g-. d-. c-. b-.
-  \stemDown
-  e,-. d-. c-. b-. a-. g-.    
+\context Voice {
+  \relative c' {
+    e'4-. f-. g-. d-. c-. b-.
+    \stemDown
+    e,-. d-. c-. b-. a-. g-.    
+  }
+  \relative c'' {
+    \stemUp             
+    d-> c-> b-> a-> g-> f-> e-> d->
+    d'
+    d-. c-. b-. a-. g-. f-. e-. d-. 
+  }  
 }
-  
-
-
index 8836e30d24cacf8190788899b31d7a4ef5e4f881..3dfe6eb900d9026a13c3b250600bc752c74ee6a7 100644 (file)
@@ -179,8 +179,8 @@ Side_position_interface::aligned_side (Grob *me, Axis a)
          Real position = 2 * (my_off + o - staff_off) / ss;
          Real rounded = directed_round (position, dir);
          Grob *head = me->get_parent (X_AXIS);
-      
-         if (fabs (rounded) <= 2 * Staff_symbol_referencer::staff_radius (me) 
+
+         if (fabs (position) <= 2 * Staff_symbol_referencer::staff_radius (me) + 1 
              || (Note_head::has_interface (head)
                  && sign (Staff_symbol_referencer::get_position (head)) == - dir))
            {
index accada587de29a7d753557bf096f4fb303f2f540..8a59a4909cf777997280b98ca6481fc3909e28a1 100644 (file)
@@ -509,7 +509,8 @@ Stem::height (SCM smob)
   Grob *beam = get_beam (me);
   if (beam)
     {
-      beam->get_property ("positions");
+      /* trigger set-stem-lengths. */
+      beam->get_property ("quantized-positions");
     }
 
   /*
index b8f36aa208343c15912a4fba124bccc9f760d954..bc875b448da92ee1f5283f2275b2822a7bb57d03 100644 (file)
@@ -62,7 +62,7 @@
     /llx exch def
     [
        /Rect [ llx lly urx ury ]
-       /Border [ 0 0 0 ]
+       /Border [ 0 0 0 ]
 
         /Action
            <<
index 10c05656c7d0b7c19cf0c52b7551736d3566ad13..d4772286e5e34bc2d821badd9d14e7d393611225 100644 (file)
@@ -57,21 +57,6 @@ except:
                return s
 underscore = _
 
-def identify (port):
-       port.write ('%s (GNU LilyPond) %s\n' % (__main__.program_name, __main__.program_version))
-
-def warranty ():
-       identify (sys.stdout)
-       sys.stdout.write ('\n')
-       sys.stdout.write (_ ("Copyright (c) %s by") % '1998--2006')
-       sys.stdout.write ('\n')
-       map (lambda x: sys.stdout.write ('  %s\n' % x), __main__.copyright)
-       sys.stdout.write ('\n')
-       sys.stdout.write (_ ("Distributed under terms of the GNU General Public License."))
-       sys.stdout.write ('\n')
-       sys.stdout.write (_ ("It comes with NO WARRANTY."))
-       sys.stdout.write ('\n')
-
 def progress (s):
        sys.stderr.write (s)
 
index 3c8c9aebf0ba3d0097b38cd47dd23514e4b1c9de..18f39cc7a54f89bf51d8ce26c3acd83ba641b0c0 100644 (file)
@@ -13,7 +13,7 @@
          ((avoid-slur . around)
           (quantize-position . #t)
           (script-stencil . (feta . ("sforzato" .  "sforzato")))
-          (side-relative-direction . -1)))      
+          (side-relative-direction . -1)))
          ("espressivo" .
          ((avoid-slur . around)
           (quantize-position . #t)
index 3202f53b5f6040d5fd49cd0d6b718c60559ccacb..149b9130415e893ba2411a95b9a56c202af2af3c 100644 (file)
@@ -12,8 +12,6 @@
 
 import os
 import sys
-import __main__
-import getopt
 import string
 import re
 
@@ -39,7 +37,6 @@ for p in ['share', 'lib']:
        sys.path.insert (0, datadir)
 
 import lilylib as ly
-import fontextract
 global _;_=ly._
 
 from convertrules import *
@@ -66,6 +63,30 @@ program_version = '@TOPLEVEL_VERSION@'
 
 add_version = 1
 
+def warning (s):
+       sys.stderr.write (program_name + ": " + _ ("warning: %s") % s + '\n')
+
+def error (s):
+       sys.stderr.write (program_name + ": " + _ ("error: %s") % s + '\n')
+
+def identify (port=sys.stderr):
+       port.write ('%s (GNU LilyPond) %s\n' % (program_name, program_version))
+
+def warranty ():
+       identify ()
+       sys.stdout.write ('''
+Copyright (c) %s by
+
+  Han-Wen Nienhuys
+  Jan Nieuwenhuizen
+
+%s
+%s
+'''  ( '2001--2006',
+       _('Distributed under terms of the GNU General Public License.'),
+       _('It comes with NO WARRANTY.')))
+
+
 
 def get_option_parser ():
        p = ly.get_option_parser (usage='lilypond-book [OPTIONS] FILE',
@@ -107,7 +128,7 @@ def get_option_parser ():
 
 
 def str_to_tuple (s):
-       return tuple (map (string.atoi, string.split (s, '.')))
+       return tuple (map (int, string.split (s, '.')))
 
 def tup_to_str (t):
        return string.join (map (lambda x: '%s' % x, list (t)), '.')
@@ -179,12 +200,9 @@ class UnknownVersion:
 def do_one_file (infile_name):
        sys.stderr.write (_ ("Processing `%s\'... ") % infile_name)
        sys.stderr.write ('\n')
-       outfile_name = ''
-       if global_options.edit:
-               outfile_name = infile_name + '.NEW'
-       elif global_options.outfile_name:
-               outfile_name = global_options.outfile_name
 
+       from_version = None
+       to_version = None
        if global_options.from_version:
                from_version = global_options.from_version
        else:
@@ -258,23 +276,23 @@ def main ():
 
        # should parse files[] to read \version?
        if global_options.show_rules:
-               show_rules (sys.stdout, from_version, to_version)
+               show_rules (sys.stdout, global_options.from_version, global_options.to_version)
                sys.exit (0)
 
-       ly.identify (sys.stderr)
+       identify (sys.stderr)
 
        for f in files:
                if f == '-':
                        f = ''
                elif not os.path.isfile (f):
-                       ly.error (_ ("can't open file: `%s'") % f)
+                       error (_ ("can't open file: `%s'") % f)
                        if len (files) == 1:
                                sys.exit (1)
                        continue
                try:
                        do_one_file (f)
                except UnknownVersion:
-                       ly.error (_ ("can't determine version for `%s'. Skipping") % f)
+                       error (_ ("can't determine version for `%s'. Skipping") % f)
 
        sys.stderr.write ('\n')
 
index 7b79c9e2046e1af8bd411f3d66dac2588f4a8130..2d2328672f9f6968b100b07805197a6bbfaea46f 100644 (file)
@@ -95,9 +95,28 @@ Example usage:
    lilypond-book --process='lilypond -I include' BOOK
 ''')
 
-copyright = ('Jan Nieuwenhuizen <janneke@gnu.org>',
+authors = ('Jan Nieuwenhuizen <janneke@gnu.org>',
             'Han-Wen Nienhuys <hanwen@cs.uu.nl>')
 
+
+def identify ():
+       sys.stdout.write ('%s (GNU LilyPond) %s\n' % (program_name, program_version))
+
+def warranty ():
+       identify ()
+       sys.stdout.write ('''
+%s
+
+%s
+
+%s
+%s
+'''  ( _('Copyright (c) %s by') % '2001--2006',
+       authors
+       _('Distributed under terms of the GNU General Public License.'),
+       _('It comes with NO WARRANTY.')))
+
+
 def get_option_parser ():
        p = ly.get_option_parser (usage='lilypond-book [OPTIONS] FILE',
                                  version="@TOPLEVEL_VERSION@",
index 798f3efe4109e7820cd52b21d1f2bca63edc46fc..c61cce84ed610a43b00ca60a74eec4450bfaf886 100644 (file)
 
 '''
 TODO:
-   * test on weird and unquantised midi input (lily-devel)
-   * update doc and manpage
-
-   * simply insert clef changes whenever too many ledger lines
-     [to avoid tex capacity exceeded]
-   * do not ever quant skips
-   * better lyrics handling
-   * [see if it is feasible to] move ly-classes to library for use in
-     other converters, while leaving midi specific stuff here
+       * test on weird and unquantised midi input (lily-devel)
+       * update doc and manpage
+
+       * simply insert clef changes whenever too many ledger lines
+               [to avoid tex capacity exceeded]
+       * do not ever quant skips
+       * better lyrics handling
+       * [see if it is feasible to] move ly-classes to library for use in
+               other converters, while leaving midi specific stuff here
 '''
 
-import getopt
 import os
 import string
 import sys
 
-       
+
 ################################################################
 # Users of python modules should include this snippet.
 #
@@ -44,16 +43,17 @@ if os.environ.has_key ('LILYPONDPREFIX'):
 
 if os.path.exists (os.path.join (datadir, 'lib/lilypond/@TOPLEVEL_VERSION@/')):
        libdir = os.path.join (libdir, 'lib/lilypond/@TOPLEVEL_VERSION@/')
-        
+
 if os.path.exists (os.path.join (datadir, 'lib/lilypond/current/')):
        libdir = os.path.join (libdir, 'lib/lilypond/current/')
-        
+
 sys.path.insert (0, os.path.join (libdir, 'python'))
 
 # dynamic relocation, for GUB binaries.
 bindir = os.path.split (sys.argv[0])[0]
-for p in ['share', 'lib']:
-       datadir = os.path.abspath (bindir + '/../%s/lilypond/current/python/' % p)
+
+for prefix_component in ['share', 'lib']:
+       datadir = os.path.abspath (bindir + '/../%s/lilypond/current/python/' % prefix_component)
        sys.path.insert (0, datadir)
 
 import midi
@@ -299,8 +299,7 @@ class Note:
 
                ## FIXME: compile fix --jcn
                if dump_dur and (global_options.explicit_durations \
-                  or Duration.compare (self.duration,
-                                       reference_note.duration)):
+                  or self.duration.compare (reference_note.duration)):
                        s = s + self.duration.dump ()
 
                reference_note = self
@@ -362,8 +361,7 @@ class Key:
                self.minor = minor
 
        def dump (self):
-               global key
-               key = self
+               global_options.key = self
 
                s = ''
                if self.sharps and self.flats:
@@ -425,8 +423,7 @@ class Text:
                        s = '"%s"' % self.text
                        d = Duration (self.clocks)
                        if global_options.explicit_durations \
-                          or Duration.compare (d,
-                                               reference_note.duration):
+                          or d.compare (reference_note.duration):
                                s = s + Duration (self.clocks).dump ()
                        s = s + ' '
                else:
@@ -556,8 +553,7 @@ def events_on_channel (channel):
                                # ugh, must set key while parsing
                                # because Note init uses key
                                # Better do Note.calc () at dump time?
-                               global key
-                               key = k
+                               global_options.key = k
 
                        elif e[1][1] == midi.LYRIC \
                             or (global_options.text_lyrics and e[1][1] == midi.TEXT_EVENT):
@@ -636,8 +632,8 @@ def gcd (a,b):
 def dump_skip (skip, clocks):
        return skip + Duration (clocks).dump () + ' '
 
-def dump (self):
-       return self.dump ()
+def dump (d):
+       return d.dump ()
 
 def dump_chord (ch):
        s = ''
@@ -679,9 +675,9 @@ def dump_bar_line (last_bar_t, t, bar_count):
 
                        
 def dump_channel (thread, skip):
-       global key, reference_note, time
+       global reference_note, time
 
-       key = Key (0, 0, 0)
+       global_options.key = Key (0, 0, 0)
        time = Time (4, 4)
        # urg LilyPond doesn't start at c4, but
        # remembers from previous tracks!
@@ -844,14 +840,14 @@ def convert_midi (in_file, out_file):
 
        allowed_tuplet_clocks = []
        for (dur, num, den) in global_options.allowed_tuplets:
-               allowed_tuplet_clocks.append (clocks_per_1 * num / (dur * den))
+               allowed_tuplet_clocks.append (clocks_per_1 / den)
 
        tracks = []
        for t in midi_dump[1]:
-               key = Key (0, 0, 0)
+               global_options.key = Key (0, 0, 0)
                tracks.append (split_track (t))
 
-       tag = '%% Lily was here -- automatically converted by %s from %s' % ( program_name, f)
+       tag = '%% Lily was here -- automatically converted by %s from %s' % ( program_name, in_file)
 
         
        s = ''
@@ -874,9 +870,9 @@ def convert_midi (in_file, out_file):
                 i += 1
        s = s + '  >>\n}\n'
 
-       progress (_ ("%s output to `%s'...") % ('LY', o))
+       progress (_ ("%s output to `%s'...") % ('LY', out_file))
 
-       if o == '-':
+       if out_file == '-':
                handle = sys.stdout
        else:
                handle = open (out_file, 'w')
@@ -913,10 +909,10 @@ def get_option_parser ():
                      dest="allowed_tuplets",
                      help=_ ("allow tuplet durations DUR*NUM/DEN"),
                      default=[])
-       p.add_option ('-V', '--verbose', help=_ ("be verbose"),
-                     action='store_true',
+       p.add_option ('-V', '--verbose', help=_("be verbose"),
+                     action='store_true'
                      ),
-       p.add_option ('-w', '--warranty', help=_ ("show warranty"),
+       p.add_option ('-w', '--warranty', help=_("show warranty"),
                      action='store_true',
                      ),
        p.add_option ('-x', '--text-lyrics', help=_("treat every text as a lyric"),
@@ -947,13 +943,13 @@ def do_options ():
                sys.exit (2)
 
        if options.duration_quant:
-               options.duration_quant = string.atoi (options.duration_quant)
+               options.duration_quant = int (options.duration_quant)
 
        if options.warranty:
                warranty ()
                sys.exit (0)
        if 1:
-               (alterations, minor) = map (string.atoi, string.split (options.key + ':0', ':'))[0:2]
+               (alterations, minor) = map (int, string.split (options.key + ':0', ':'))[0:2]
                sharps = 0
                flats = 0
                if alterations >= 0:
@@ -965,9 +961,9 @@ def do_options ():
 
                
        if options.start_quant:
-               options.start_quant = string.atoi (a)
+               options.start_quant = int (options.start_quant)
                
-       options.allowed_tuplets = [map (string.atoi, a.replace ('/','*').split ('*'))
+       options.allowed_tuplets = [map (int, a.replace ('/','*').split ('*'))
                                for a in options.allowed_tuplets]
        
        global global_options
@@ -975,33 +971,34 @@ def do_options ():
 
        return args
 
+def main():
+       files = do_options()
+
+       for f in files:
+               g = f
+               g = strip_extension (g, '.midi')
+               g = strip_extension (g, '.mid')
+               g = strip_extension (g, '.MID')
+               (outdir, outbase) = ('','')
+
+               if not output_name:
+                       outdir = '.'
+                       outbase = os.path.basename (g)
+                       o = os.path.join (outdir, outbase + '-midi.ly')
+               elif output_name[-1] == os.sep:
+                       outdir = output_name
+                       outbase = os.path.basename (g)
+                       os.path.join (outdir, outbase + '-gen.ly')
+               else:
+                       o = output_name
+                       (outdir, outbase) = os.path.split (o)
 
-files = do_options()
-
-for f in files:
-       g = f
-       g = strip_extension (g, '.midi')
-       g = strip_extension (g, '.mid')
-       g = strip_extension (g, '.MID')
-       (outdir, outbase) = ('','')
-
-       if not output_name:
-               outdir = '.'
-               outbase = os.path.basename (g)
-               o = os.path.join (outdir, outbase + '-midi.ly')
-       elif output_name[-1] == os.sep:
-               outdir = output_name
-               outbase = os.path.basename (g)
-               os.path.join (outdir, outbase + '-gen.ly')
-       else:
-               o = output_name
-               (outdir, outbase) = os.path.split (o)
-
-       if outdir != '.' and outdir != '':
-               try:
-                       os.mkdir (outdir, 0777)
-               except OSError:
-                       pass
-
-       convert_midi (f, o)
+               if outdir != '.' and outdir != '':
+                       try:
+                               os.mkdir (outdir, 0777)
+                       except OSError:
+                               pass
 
+               convert_midi (f, o)
+if __name__ == '__main__':
+       main()