From 5360299c83e55dfd2e8e43ff5b999afd67544877 Mon Sep 17 00:00:00 2001
From: Han-Wen Nienhuys <hanwen@xs4all.nl>
Date: Tue, 13 Jul 1999 10:28:58 +0200
Subject: [PATCH] release: 1.1.57

---
 Documentation/metadoc/musicnotes.sty   |   1 +
 Documentation/tex/lilypond-regtest.doc |  16 +
 Documentation/tex/tutorial.yo          |  23 +-
 NEWS                                   |  28 ++
 TODO                                   |  93 +++++-
 VERSION                                |   2 +-
 flower/rtti.cc                         |  12 -
 input/bugs/choral.ly                   | 241 +++++++++++++++
 input/bugs/enghack.ly                  |  14 +
 input/bugs/rhythm.ly                   |  19 --
 input/star-spangled-banner.ly          |  42 ++-
 input/test/beam-extreme.ly             |  12 +
 input/test/chord-table.ly              |   2 +-
 input/test/rhythm-melody.fly           |   3 +-
 input/test/rhythm.ly                   |   4 +-
 input/test/score-bar-scripts.ly        |  77 -----
 input/test/slur-symmetry-1.ly          |  21 +-
 input/test/slur-symmetry-2.ly          |  16 +
 input/test/slur-symmetry-3.ly          |  15 +
 input/test/slur-symmetry.ly            |  22 +-
 input/test/tie.ly                      |  26 +-
 input/test/volta.fly                   |   2 +-
 input/test/wtk-huh.ly                  |  24 --
 input/tril.ly                          |  17 --
 lily/beam.cc                           |  14 +-
 lily/bow.cc                            |  17 +-
 lily/break-align-item.cc               |   8 +-
 lily/encompass-info.cc                 |  53 ++--
 lily/include/slur.hh                   |   4 -
 lily/misc.cc                           |   2 +-
 lily/parser.yy                         |  20 +-
 lily/repeat-engraver.cc                |  10 +-
 lily/sequential-music-iterator.cc      |  10 +-
 lily/slur.cc                           | 395 +++++++++++--------------
 lily/spacing-spanner.cc                |  13 +-
 lily/spanner.cc                        |   1 -
 lily/spring-spacer.cc                  |   3 +-
 lily/tie.cc                            | 151 ++++++----
 ly/params.ly                           |  18 +-
 make/out/lelievijver.lsm               |   8 +-
 make/out/lilypond.lsm                  |   8 +-
 make/out/lilypond.spec                 |   4 +-
 midi2ly/include/midi-score-parser.hh   |   2 -
 scm/lily.scm                           |   4 +-
 tex/fetdefs.tex                        |  15 +
 tex/lilyponddefs.tex                   |   2 +
 tex/mudela-book.tex                    |   4 +-
 47 files changed, 916 insertions(+), 582 deletions(-)
 create mode 100644 input/bugs/choral.ly
 create mode 100644 input/bugs/enghack.ly
 delete mode 100644 input/bugs/rhythm.ly
 create mode 100644 input/test/beam-extreme.ly
 delete mode 100644 input/test/score-bar-scripts.ly
 create mode 100644 input/test/slur-symmetry-2.ly
 create mode 100644 input/test/slur-symmetry-3.ly
 delete mode 100644 input/test/wtk-huh.ly
 delete mode 100644 input/tril.ly
 create mode 100644 tex/fetdefs.tex

diff --git a/Documentation/metadoc/musicnotes.sty b/Documentation/metadoc/musicnotes.sty
index bc4a69f543..31d2f83a9c 100644
--- a/Documentation/metadoc/musicnotes.sty
+++ b/Documentation/metadoc/musicnotes.sty
@@ -4,6 +4,7 @@
 \def\fetdef#1#2{%
   \def#1{\hbox{\char#2}}}
 
+% huh? from where
 \input feta20.sty
 
 \font\fetasixteenfont=feta16
diff --git a/Documentation/tex/lilypond-regtest.doc b/Documentation/tex/lilypond-regtest.doc
index d774479de6..a92910cdee 100644
--- a/Documentation/tex/lilypond-regtest.doc
+++ b/Documentation/tex/lilypond-regtest.doc
@@ -70,6 +70,22 @@ hidden just as with breakable bar lines.
 %
 % \mud elafile{beam-repeat.ly}
 
+Beams should behave reasonably well, even under extreme circumstances.
+Stems may be short, but noteheads should never touch the beam.
+
+\mudelafile{beam-extreme.ly}
+
+Slurs should look nice and symmetric.  The curvature may increase
+only to avoid noteheads, and as little as possible.
+
+\mudelafile{slur-symmetry.ly}
+\mudelafile{slur-symmetry-1.ly}
+
+Ties are strictly horizontal.  They are placed in between note heads.
+The horizontal middle should not overlap with a staffline.
+
+\mudelafile{tie.ly}
+
 Beams can be typeset over fixed distance aligned staffs, beam
 beautification doesn't really work, but knees do. Beams should be
 behave well, wherever the switching point is.
diff --git a/Documentation/tex/tutorial.yo b/Documentation/tex/tutorial.yo
index 5c8a6ea966..72ffe2ff2f 100644
--- a/Documentation/tex/tutorial.yo
+++ b/Documentation/tex/tutorial.yo
@@ -210,7 +210,7 @@ this command comes after the code(\time) command, in the
 output, the key comes before the time signature: LilyPond knows about
 music typesetting conventions.
 verb(
-	\repeat 2 {
+	\repeat "semi" 2 {
 ) COMMENT(
 
 ) This command tells LilyPond that the enclosed piece of music must
@@ -379,7 +379,7 @@ verb(
   c'1 c'2 c'4 c'8 c'16 c'32 c'64 c'64 c'2. c'8. c'16
 )
 
-mudela()(
+COMMENT(
 \score {
        \notes {
          c'\longa c'\breve  
@@ -1650,14 +1650,11 @@ COMMENT(
 
 Of course, you can also use different ratios, and use beamed notes or
 rests:
-COMMENT( BROKEN
-
-lilypond: score-element.cc:134: class Paper_def * Score_element::paper() const: Assertion `pscore_l_' failed.
-
-mudela(fragment)(
+COMMENT( 
+)mudela(fragment)(
 	\context Voice \times 4/5 { [c''8 c''16 c''16] r8 [g'8 g'8] }
 )
-)
+
 If you make a tuplet of  beamed notes, where the beam is as wide as
 the bracket, the bracket is omitted.
 
@@ -1666,11 +1663,12 @@ sect(Repeats)
 A repeated piece of music can consist of two parts: one part to be 
 repeated, and optionally, a list of alternative endings:
 COMMENT(
+
 )mudela(verbatim,fragment,center)(
     \relative c'{
     	\time 2/4;
     	g' a
-        \repeat 2 { b c }
+        \repeat "semi" 2 { b c }
 	\alternative { 
 	    { d c } { d e }
 	}
@@ -1684,15 +1682,16 @@ A less intuitive form may be needed for lyrics, when there are
 a couple alternatives, but nothing is repeated.  The code(\repeat) command
 must be present, but it may specify an empty music list:
 COMMENT(
+
 )mudela(verbatim,fragment,center)(
     \context Lyrics \lyrics {
-	\repeat 2 { }
-	\alternative < 
+	\repeat "folded" 2 { }
+	\alternative { 
 	    { Let's not sing 
 	      this twice } 
 	    { Rather sing 
 	      this in- stead } 
-	> 
+	} 
     }
 )
 
diff --git a/NEWS b/NEWS
index f2193e35fd..2a01616cca 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,31 @@
+pl 56.jcn3
+	- slur de-hairification
+	  * slurs always attached to noteheads, by default
+	  * corrections for steep and high slurs
+	  * snap to stem end when close
+	- bow/tie/slur dy/dx fix
+
+pl 56.hwn1
+	- some spacing tweaks.
+ 	- bf: two repeats + alts after each other.
+pl 56.jcn2
+	- tie: bfs + even simpler
+
+pl 56.jcn1
+	- bf: re-added \textflat,sharp to fix chords...
+	- bf: chord-modifier and mandatory dot: c-maj5 
+	- tutorial chord fixes
+	- tie fixes and boldifying:
+	  * removed sloping (dy!=0) code
+	  * use actual note-widths
+	  * y[left] == y[right]
+	  * follow OSU rules, I hope (from comments in text -- must check)
+	  * undetermined direction -> down; inverse of stem
+	- bf: beam: undetermined direction -> up; like stem
+	- slur-symmetry fixes
+	- fix for \rhythm and seq_iter childs (still crude, but more effective)
+*********
+
 pl 55.uu1
 	- use GS' anti aliasing
 
diff --git a/TODO b/TODO
index 3939b22ad5..e95bd85eda 100644
--- a/TODO
+++ b/TODO
@@ -9,7 +9,6 @@ Most of the items are marked in the code as well
 Grep for TODO and ugh/ugr/urg.  
 
 .* TODO before 1.2
-. * rename abc2ly mup2ly
 . * rename 'staff_line_leading' (who is being lead where?) to
 staff_space, interline; (or other meaningful name) and use throughout lily
 . * rename files to class-name:
@@ -18,7 +17,29 @@ staff_space, interline; (or other meaningful name) and use throughout lily
 .  * p-score
 .  * engraver-group
 . * standardise(d) switches: -v, --version; -d, --debug,
-. * Auto_beam debugging output (waarom/wanneer heb jij die weggehaald?)
+. * Peter    1.  Key signatures are no longer transposed with the rest
+    of
+        the music.
+
+                \notes\transpose bes  {\key D; d1 }
+        should produce no key signature (key C)
+
+        2.  Crescendos and other dynamic markings that start inside a
+        \grace { } section are ignored.
+
+        \notes \relative c' { fis4 r4   \grace { [g16 ( \<   a16] }
+        ) b4 \! a8. g16}
+
+        3.  Slurs that end within a grace section but start outside
+        are treated strangely.
+        a2 d,4 ( \grace { [e16 ) d16]} cis8 d
+
+
+        4.  Lyrics and grace sections don't go too well together.
+        The words are aligned with the main note, not the start of the
+        grace note.  This is usually wrong, but is sometimes right.
+
+
 . * Auto_beam debugging output (waarom/wanneer heb jij die weggehaald?)
 .  * Rename illegal to invalid
 .  * Mats:
@@ -51,11 +72,68 @@ staff_space, interline; (or other meaningful name) and use throughout lily
 
 - The paper11/13/26 files have to be updated.
 . * Grace_slur_engraver.
+. * input/star-spangled-banner.ly: fold for lyrics?
 . * Break_req handling is silly (break_forbid () + \break fucks up.)
 . * hangOnClef with non-breakable clefs.
 . * do scaled fonts generally 
 . * fix partial measures in meaningful way.
+. * Michael
+
+- The two spacing bugs in the choral-1.ly I sent you earlier, small
+GIFs attached for easy reference: #1: time meter and first note on the
+line are too close; #2: last note on the line and next bar are too
+close.
+
+- And I haven't got any feedback on this one, posted last week:
+
+Check out:
+
+\score {
+  \notes \relative c' {
+    \context Staff <
+      \context Voice = one { \stemdown c1 c4 }
+      \context Voice = two { \stemup d1 d4 }
+    >
+  }
+}
+
+Notes are shifted as expected. Now check out:
+
+\score {
+  \notes \relative c' {
+    \context Staff <
+      \context Voice = one { \stemdown c1 <a4 c4> }
+      \context Voice = two { \stemup d1 d4 }
+    >
+  }
+}
+
+i.e. do 
+
+-      \context Voice = one { \stemdown c1 c4 }
++      \context Voice = one { \stemdown c1 <a4 c4> }
+
+Now the chord collides with the note of the other voice!
+
 . * relative mode for midi2ly
+. * 
+Crescendi/diminuendi that cross a line break lose their vertical
+position and all end up above the top staff line, see the 
+following example.
+
+----------------
+\score{
+  \context StaffGroup <
+    \context Staff=s1 \notes\relative c'{
+      c d e f | 
+      g f e d | \break %% If this break is removed, it works fine
+      c d e f |}
+    \context Staff=s2 \notes\relative c'{
+      c \< d e f | 
+      g f e d | 
+      c d e \! f |}
+  >
+}
 . * uniformise recent feta contributions.
 .  * bigger and fatter 4/4 C
 . * sort out directory stuff.
@@ -81,6 +159,7 @@ GNU LilyPond 1.1.54.
 [/home/fred/usr/src/lilypond/scm/lily.scm]
 warning: can't find file: `init'
 . * indent = 0.0 with linewidth=-1.0
+. * collisions & accidentals.
 . * auto-beaming in input/test/spacing.ly.
 huh, snap niks van: gewone beam gaat wel goed.  hoe kan abe nu
 invloed hebben op beam-creatie, stopt toch gewoon stokken in?
@@ -107,7 +186,6 @@ invloed hebben op beam-creatie, stopt toch gewoon stokken in?
 . * Beam
 . * Stem
 . * Rhythmic_column and interaction stem/rhythmic_column/note_head/dots.
-. * Slur
 . * Duration
 . * clef engraver 
 . * parser
@@ -562,3 +640,12 @@ hesitate to ask.
  
 (require 'allout)
 (outline-init 't)
+
++ pl 56.jcn3
++ 	- slur de-hairification
++ 	  * slurs always attached to noteheads, by default
++ 	  * corrections for steep and high slurs
++ 	  * snap to stem end when close
++ 	- bow/tie/slur dy/dx fix
++ 
++ 
diff --git a/VERSION b/VERSION
index 08044eed79..4cfbcaff7b 100644
--- a/VERSION
+++ b/VERSION
@@ -1,7 +1,7 @@
 PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=1
-PATCH_LEVEL=56
+PATCH_LEVEL=57
 MY_PATCH_LEVEL=
 
 # use the above to send patches: MY_PATCH_LEVEL is always empty for a
diff --git a/flower/rtti.cc b/flower/rtti.cc
index 911e191515..c24cc27ec9 100644
--- a/flower/rtti.cc
+++ b/flower/rtti.cc
@@ -1,15 +1,3 @@
-
-
-
-/*#include <typeinfo>
-
-signature S
-{
-  int foo ();
-  int bar (int);
-};
-*/
-
 #include <ctype.h>
 #include "virtual-methods.hh"
 
diff --git a/input/bugs/choral.ly b/input/bugs/choral.ly
new file mode 100644
index 0000000000..84a5d45011
--- /dev/null
+++ b/input/bugs/choral.ly
@@ -0,0 +1,241 @@
+
+% TODO:
+% Copyright, Header etc.
+% Begleitsatz
+% Tempo
+
+\include "deutsch.ly"
+
+global = \notes {
+	\time 2/2; \partial 2*1;
+	\key g;
+
+	s2 | s1 | s1 |
+	\time 3/2;
+	s1. | s1. |
+	\time 2/2;
+	s1 | s1 | s1 | s2
+
+	s2 | s1 | s1 |
+	\time 3/2;
+	s1. | s1. |
+	\time 2/2;
+	s1 | s1
+	\time 3/2;
+	s1. \bar "||";
+
+	s1. | s1. | s1. | s1. |
+	s1. | s1. | s1. | s1. \bar "||";
+
+	\key es;
+	s1. | s1. | s1. | s1. |
+	s1. | s1. | s1. | s1 \bar "||";
+
+	\key g;
+	s2 |
+	\time 2/2;
+	s1 | s1 |
+	\time 3/2;
+	s1. | s1. |
+	\time 2/2;
+	s1 | s1 | s1 | s2
+
+	s2 | s1 | s1 |
+	\time 3/2;
+	s1. | s1. |
+	\time 2/2;
+	s1 | s1 | s1 \bar "|.";
+}
+
+themeMelody = \notes \relative c'' {
+	g2 | g d' | h a |
+	g fis g | a ~ a \breathe b |
+	d b | a a | g ~ g ~ | g \breathe
+
+	g2 | g d' | h a |
+	g fis g | a ~ a \breathe b |
+	d b |
+}
+
+themeBeforeBreak1EndMelody = \notes \relative  c'' {
+	 a2 a | g ~ g ~ g4 r4
+}
+
+themeFinalEndMelody = \notes \relative  c'' {
+	 a2 a ~ | a1^\fermata
+}
+
+themeRightHand = \notes \relative c' {
+	d2 | c <e g> | <e g> <d fis> | d2 es es4 c4 |
+	<d1 e1> <d2 f2> | <g2 b2> f2 | <cis2 e2> <e2 g2> |
+	<d2 f2> <c4 f4> cis4 | <dis2 fis2>
+
+	<c2 e2> | <c e> <e g> | <e g> <d fis> | d2 es es4 c4 |
+	<d1 e1> <d2 f2> | <g2 b2> f2 |
+}
+
+themeBeforeBreak1EndRightHand = \notes \relative c' {
+	 <cis2 e2> <e2 g2> | <d2 f2> <c4 f4> cis4 <dis4 fis4> r4 |
+}
+
+themeFinalEndRightHand = \notes \relative c' {
+	 <cis2 e2> <e2 g2> | <d1 f1>
+}
+
+themeLeftHand =	\notes \relative c {
+	<d2 g h> | <f a h> <g c> | <g cis> c | <g2 {a4 c4}> <a2 c2> <g2 {b4 a4}> |
+	<a,1 fis'1 a1> <d2 g2 b2> | <g2 b2 e2> <f2 a2 d2> | <a2 h2> <a2 cis2> |
+	<g2 b2> a2 | h2
+
+	g2 | <g a> <g c> | <g cis> c | <g2 {a4 c4}> <a2 c2> <g2 {b4 a4}> |
+	<a,1 fis'1 a1> <d2 g2 b2> | <g2 b2 e2> <f2 a2 d2> |
+}
+
+themeBeforeBreak1EndLeftHand = \notes \relative c' {
+	 <a2 h2> <a2 cis2> | <g2 b2> a2 h4 r4 |
+}
+
+themeFinalEndLeftHand = \notes \relative c' {
+	 <a2 h2> <a2 cis2> | <g1 b1>
+}
+
+themePedal = \notes \relative c' {
+	g4 fis | f2 c | a' d, |
+	h c es | d ~ d b |
+	e, g | a a | d, f4 a | h2
+
+	c2 | e2 c | a' d, |
+	h c es | d ~ d b |
+	e, g |
+}
+
+themeBeforeBreak1EndPedal = \notes \relative c {
+	a2 a | d,2 f4 a h4 r4 |
+}
+
+themeFinalEndPedal = \notes \relative c {
+	a2 a | d,1_\fermata
+}
+
+break1Melody = \notes \relative c'' {
+	g4( fis e fis d' h | )a1. |
+	g4( es g b es g | <fis1. )a1.> |
+	b,2 g es | d1. |
+	b'2 g d' | a1 r2 |
+}
+
+break1RightHand = \notes \relative c' {
+	e1. | g4( fis e fis g fis |
+	)es1. | dis'2 d4 c b a \breathe |
+	s1. | s1. |
+	es1 <es2 g2> | <dis1 fis1 > r2 |
+}
+
+break1LeftHand = \notes \relative c {
+	<
+		\context Voice = oben {
+			\stemup
+			c'1. | d2. c4 h a | b1. | d1. |
+		}
+		\context Voice = unten {
+			\stemdown
+			<c,1. g'1.> | <d1. a'1.> | <es1. g1.> | d2. e4 fis d |
+		}
+	>
+	r4 b2( g4 b c | d c b g fis d |
+	<)es1 c'1> <c2 c'2> | <h1 h'1> r2 |
+}
+
+break2RightHand = \notes \relative c'' {
+	g8 r8 c,8 r8 <fis8 g8> r8 c r g' r c, r |
+	<fis8 g8> r  c r  b' r  es, r  <es g> r  es  r |
+	b' r es, r <es g> r es r d' r <d, g> r |
+	d' r f, r <f b> r f r d' r <fis, a> r |
+	d' r g, r <g b> r g r d' r g, r |
+	es' r g, r <g b> r g b es r <a, c> r |
+	d8 r b r d8 f d b a r <a cis> r |
+	<fis1 a d1> \breathe
+}
+
+break2LeftHand = \notes \relative c' {
+	r8 g r g r g r g r g r g |
+	r8 g r g r b r b r b r b |
+	r c r c r c r c r h r h |
+	r d r d r d r d r d r d |
+	r d r d r d r d r c r c |
+	r <b es> r <b es> r <b es> r <g es'> r f' r <a, f'> |
+	r <b f'> r <b f'> r <g f'> r <g f'> r <a e'> r <a e'> |
+	<d,1 d'1>
+}
+
+break2Pedal = \notes \relative c {
+	c2 c g' | es1 d2 | c1 h2 |
+	b1 d2 \breathe | g2 g f2 | es1 f2 |
+	b,2 g a | d1 \breathe
+}
+
+\score {
+	<
+		\context PianoStaff <
+			\context Staff = treble <
+				\global
+				\context Voice = melody {
+					\stemup \themeMelody \themeBeforeBreak1EndMelody
+					\break1Melody
+					\stemboth \break2RightHand
+					\stemup \themeMelody \themeFinalEndMelody
+				}
+				\context Voice = firstdown {
+					\stemdown \themeRightHand \themeBeforeBreak1EndRightHand
+					\break1RightHand
+					\notes {
+						s1. | s1. | s1. | s1. |
+						s1. | s1. | s1. | s1
+					}
+					\themeRightHand \themeFinalEndRightHand
+				}
+			>
+			\context Staff = bass <
+				\clef "bass";
+				\global
+				{
+					\themeLeftHand \themeBeforeBreak1EndLeftHand
+					\break1LeftHand
+					\break2LeftHand
+					\themeLeftHand \themeFinalEndLeftHand
+				}
+			>
+		>
+		\context Staff = pedal {
+			\clef "bass";
+			<
+				\global
+				{
+					\themePedal \themeBeforeBreak1EndPedal
+					\notes {
+						s1. | s1. | s1. | s1. |
+						s1. | s1. | s1. | s1. |
+					}
+					\break2Pedal
+					\themePedal \themeFinalEndPedal
+				}
+			>
+		}
+	>
+
+	\header {
+		title = "Choral I";
+		subtitle = "(über ``Aus meines Herzens Grunde'')";
+		composer = "Michael Krause 1999 (*1977)";
+		enteredby = "Michael Krause";
+		copyright = "dunno";
+	}
+
+	\paper {
+		linewidth = 18.0 \cm;
+		textheight = 28.0 \cm;
+
+		indent = 0.0 \mm;
+		\translator { \OrchestralScoreContext }
+	}
+}
diff --git a/input/bugs/enghack.ly b/input/bugs/enghack.ly
new file mode 100644
index 0000000000..2be4064a91
--- /dev/null
+++ b/input/bugs/enghack.ly
@@ -0,0 +1,14 @@
+\score {
+       \notes {
+         c'\longa c'\breve  
+         c'1 c'2 c'4 c'8 c'16 c'32 c'64 c'64 c'2. c'8. c'16
+         }
+         \paper {
+                linewidth = -1.0;
+                \translator { \type "Score_engraver";
+                            \name "Score";
+                            \consists "Note_heads_engraver";
+                            \consists "Stem_engraver";
+                            \consists "Rhythmic_column_engraver";
+         }}}
+         
diff --git a/input/bugs/rhythm.ly b/input/bugs/rhythm.ly
deleted file mode 100644
index e9fdd621f0..0000000000
--- a/input/bugs/rhythm.ly
+++ /dev/null
@@ -1,19 +0,0 @@
-text =   \lyrics { four4 syl- la ble }
-two = \notes  { c4. c8 }
-fourn = \notes  { c4. c8 c4. c8 }
-fiven = \notes  { [c16  c16 \bar "";  <{ c8 } { c16 c16 }> c8 }
-
-\score { \notes{
-	\context Staff = SA
-	< \context Staff { \two } 
- 	  \context Lyrics { \rhythm \fourn \text   }
-	>
-	< \context Staff { \two } 
- 	  \context Lyrics { \rhythm \two \text   }
-	>
-	< \context Staff { \fiven } 
- 	  \context Lyrics { \rhythm \fiven \text   }
-	>
-
-}
-}
diff --git a/input/star-spangled-banner.ly b/input/star-spangled-banner.ly
index ef7324b2ca..b609d34d70 100644
--- a/input/star-spangled-banner.ly
+++ b/input/star-spangled-banner.ly
@@ -1,5 +1,5 @@
 %{
-Converted from star.mup with the aid of mup-to-ly.py
+Converted from star.mup with the aid of mup2ly.py
 http://www.Arkkra.com/doc/star.html
 http://www.Arkkra.com/doc/star.ps
 %}
@@ -57,15 +57,20 @@ $staff2_voice_2 = \notes {
   g8. g16 fis4.()a,8 d8 e8 fis2 b8 b8 a4. a8 a,4 d2 s4 
 }
 
-text = \lyrics
- {  Oh4 __ \repeat fold 2 { }
+% hw: how does this work with new repeats?
+textx = \lyrics {  
+  Oh4 __ \repeat fold 2 { }
   \alternative {
-     { say.4 can you | see,2 by8. the16 dawn's4 ear- ly light2 What8
-    so8 proud-4. ly8 we4 hailed,2 At8. the16 twi-4 light's last gleam-
-    ing. Whose8. broad16 }
+     { 
+       say.4 can you | see,2 by8. the16 dawn's4 ear- ly light2 What8
+       so8 proud-4. ly8 we4 hailed,2 At8. the16 twi-4 light's last gleam-
+       ing. Whose8. broad16 
+     }
 
-    { stripes4 and bright stars,2 through8. the16 per-4 il- ous fight,2
-    O'er8 the8 ram-4. parts8 we4 watched,2 were8. so16 gal-4 lant- ly }
+    { 
+      stripes4 and bright stars,2 through8. the16 per-4 il- ous fight,2
+      O'er8 the8 ram-4. parts8 we4 watched,2 were8. so16 gal-4 lant- ly 
+    }
   }
   stream-4 ing. And8. the16 rock-4 ets' red glare,2 the8 bombs8
   burst-4 ing in air,2 gave4 proof4. through8 the4 night2 that8.
@@ -74,6 +79,27 @@ text = \lyrics
   and8 the8 home4. of8 the4 brave.2
 }
 
+text = \lyrics {  
+  Oh4 __ 
+  %\alternative {
+     { 
+       say.4 can you | see,2 by8. the16 dawn's4 ear- ly light2 What8
+       so8 proud-4. ly8 we4 hailed,2 At8. the16 twi-4 light's last gleam-
+       ing. Whose8. broad16 
+     }
+
+    %{ 
+      stripes4 and bright stars,2 through8. the16 per-4 il- ous fight,2
+      O'er8 the8 ram-4. parts8 we4 watched,2 were8. so16 gal-4 lant- ly 
+    }
+  %}
+  stream-4 ing. And8. the16 rock-4 ets' red glare,2 the8 bombs8
+  burst-4 ing in air,2 gave4 proof4. through8 the4 night2 that8.
+  our16 flag4 was still there,2 Oh4 say, does that star- span-
+  gled ban- ner yet wave,2 __ O'er8. the16 land2 __ of8 the8 free2
+  and8 the8 home4. of8 the4 brave.2
+}
+
 global = \notes {
 	\time 3/4;
 	\key D;
diff --git a/input/test/beam-extreme.ly b/input/test/beam-extreme.ly
new file mode 100644
index 0000000000..4bdb1b0bc7
--- /dev/null
+++ b/input/test/beam-extreme.ly
@@ -0,0 +1,12 @@
+\score{
+	\notes\relative c''{
+		[g8 c c,]
+		[c16 c'' a f]
+		\stemup 
+		[c,,32 c'' a f]
+
+	}
+	\paper{
+		linewidth=-1.;
+	}
+}
diff --git a/input/test/chord-table.ly b/input/test/chord-table.ly
index c2b30c2c92..907782915f 100644
--- a/input/test/chord-table.ly
+++ b/input/test/chord-table.ly
@@ -5,7 +5,7 @@ enteredby = 	"jcn";
 }
 
 tab = \notes\transpose c'''\chords{
-	c1 c-m c-4 c-m.4 c-5+ c-5- c-m.5- c-5-.5+ c-6\break %c-m6\break
+	c1 c-m c-4 c-m4 c-5+ c-5- c-m5- c-5-.5+ c-6\break %c-m6\break
 }
 
 \score{
diff --git a/input/test/rhythm-melody.fly b/input/test/rhythm-melody.fly
index 7365625e35..9ccd77a4bf 100644
--- a/input/test/rhythm-melody.fly
+++ b/input/test/rhythm-melody.fly
@@ -1 +1,2 @@
-\rhythm { 4. 8 8. 16 } { c'' d e f }
+%\rhythm { 4. 8 8. 16 } { c'' d e f }
+\rhythm { c4. c8 c8. c16 } { c'' d e f }
diff --git a/input/test/rhythm.ly b/input/test/rhythm.ly
index c4125e26a3..4fe37cb585 100644
--- a/input/test/rhythm.ly
+++ b/input/test/rhythm.ly
@@ -1,5 +1,7 @@
 \score{
 	\context Voice \notes\relative c''{
-		c4. 8 4. 8
+		% still thinking 'bout this
+		%c4. 8 4. 8
+		c4. c8 c4. c8
 	}
 }
diff --git a/input/test/score-bar-scripts.ly b/input/test/score-bar-scripts.ly
deleted file mode 100644
index 4e155e5632..0000000000
--- a/input/test/score-bar-scripts.ly
+++ /dev/null
@@ -1,77 +0,0 @@
-
-
-
-\version "1.1.52";
-
-onestaff =	\context Staff = foo\notes  {
-		\property Staff.instr = instr
-		\property Staff.instrument = instrument \mark "B"; c1 \mark "A"; \break c2  c2 \break }
-
-grstaff =	\notes \context GrandStaff <
-	\context Staff = bar	{
-
-	\property Staff.instr = instr
-	
-	 \mark "B"; \break c1 \mark "A"; c2  }
-	\context Staff = bufl	  { c1 c2  } >
-
-scpaper =  \paper {Score = \translator {
-	\context Score_engraver;
-	barScriptPadding = "2.0";	% dimension \pt
-	markScriptPadding = "4.0";
-	barColumnPriority = "-4";
-	markBreakPriority = "-4";
-	barNumberBreakPriority = "-4";
-	
-	\consists "Timing_engraver";
-	\consists "Bar_column_engraver";
-	\consists "Bar_number_engraver";
-	\consists "Mark_engraver";
-	\consists "Span_score_bar_engraver";
-	\consists "Score_priority_engraver";
-	\consists "Priority_horizontal_align_engraver";
-	\consists "Vertical_align_engraver";
-
-	\accepts "ChoirStaff";
-	\accepts "StaffGroup";
-	\accepts "Staff";
-	\accepts "RhythmicStaff";	
-	\accepts "Lyrics";
-	\accepts "GrandStaff";
-}}
-
-stpaper =\paper{
-Staff = \translator {
-	\context "Line_group_engraver_group";
-	defaultclef = violin;
-	barColumnPriority = "0";
-
-	marginBreakPriority = "-4";
-
-	\consists "Bar_engraver";
-	\consists "Clef_engraver";
-	\consists "Key_engraver";
-	\consists "Time_signature_engraver";
-	\consists "Local_key_engraver";
-	\consists "Staff_sym_engraver";
-	\consists "Mark_engraver";	
-	\consists "Collision_engraver";
-	\consists "Rest_collision_engraver";
-	\consists "Bar_column_engraver";
-	\consists "Bar_number_engraver";
-	\consists "Separating_line_group_engraver";
-	\consists "Staff_margin_engraver";
-	\accepts "Voice";
-}}
-
-scscore = \score { \grstaff \paper {
-\scpaper
-}}
-
-
-stscore = \score { \onestaff \paper {
- \stpaper
-}}
-
-%\score {\stscore}
-\score {\scscore}
diff --git a/input/test/slur-symmetry-1.ly b/input/test/slur-symmetry-1.ly
index 4811a63d4c..6e2ea7c67b 100644
--- a/input/test/slur-symmetry-1.ly
+++ b/input/test/slur-symmetry-1.ly
@@ -1,15 +1,14 @@
-\header{
-% should look the same
-title="symmetry";
-}
 \score{
-	\notes\relative c'{
-		[g'8( e )c' g,] r2
-		\break
-		[d''8( f )a, d'] r2
-	}
+	\notes\relative c''<
+		\time 4/4;
+		\context Staff{
+			f8(f f)f f(g g)f f(a a)f f(b b)f
+		}
+		\context Staff=x{
+			e,(e e)e e(d d)e e(c c)e e(b b)e
+		}
+	>
 	\paper{
-		castingalgorithm = \Wordwrap;
-		linewidth = 50.0\mm;
+		linewidth=-1.;
 	}
 }
diff --git a/input/test/slur-symmetry-2.ly b/input/test/slur-symmetry-2.ly
new file mode 100644
index 0000000000..93c2df1825
--- /dev/null
+++ b/input/test/slur-symmetry-2.ly
@@ -0,0 +1,16 @@
+\header{
+% should look the same
+title="symmetry";
+}
+\score{
+	\notes\relative c'{
+		[g'8( e )c' g,]
+		[d'( f' )a, a]
+		[d( f )a, d']
+		[g,( e, )c' c]
+	}
+	\paper{
+		castingalgorithm = \Wordwrap;
+		linewidth = 50.0\mm;
+	}
+}
diff --git a/input/test/slur-symmetry-3.ly b/input/test/slur-symmetry-3.ly
new file mode 100644
index 0000000000..4811a63d4c
--- /dev/null
+++ b/input/test/slur-symmetry-3.ly
@@ -0,0 +1,15 @@
+\header{
+% should look the same
+title="symmetry";
+}
+\score{
+	\notes\relative c'{
+		[g'8( e )c' g,] r2
+		\break
+		[d''8( f )a, d'] r2
+	}
+	\paper{
+		castingalgorithm = \Wordwrap;
+		linewidth = 50.0\mm;
+	}
+}
diff --git a/input/test/slur-symmetry.ly b/input/test/slur-symmetry.ly
index 93c2df1825..41ebe836b3 100644
--- a/input/test/slur-symmetry.ly
+++ b/input/test/slur-symmetry.ly
@@ -1,16 +1,14 @@
-\header{
-% should look the same
-title="symmetry";
-}
 \score{
-	\notes\relative c'{
-		[g'8( e )c' g,]
-		[d'( f' )a, a]
-		[d( f )a, d']
-		[g,( e, )c' c]
-	}
+	\notes\relative c'<
+		\time 6/8;
+		\context Staff{
+			e8(e)e e(d)e e(c)e e(b)e
+		}
+		\context Staff=x{
+			f'8(f)f f(g)f f(a)f f(b)f
+		}
+	>
 	\paper{
-		castingalgorithm = \Wordwrap;
-		linewidth = 50.0\mm;
+		linewidth=-1.;
 	}
 }
diff --git a/input/test/tie.ly b/input/test/tie.ly
index 90e9389b40..36998a23f5 100644
--- a/input/test/tie.ly
+++ b/input/test/tie.ly
@@ -1,20 +1,12 @@
-\version "1.1.52";
-
-tie = \notes\transpose c''{
-
-	e4 ~ e e e ~ |
-	e ~ a a a ~ |
-	a d d d ~ |
-	e e e e |
-	g,, g,, g,, g,, ~ |
-	g,, g,, g,, g,, |
-}
-
 \score{
-	\tie
-	\paper{ 
-	      indent = 0.0\pt;
-		linewidth= 30.\mm;
-		castingalgorithm = \Wordwrap;
+	\notes\relative c''{
+		%b2~b4~b8~b16~b32~b64 r64\break
+		%a2~a4~a8~a16~a32~a64 r64
+		d2~d4~d8~d16~d32~d64 r64\break
+		a2~a4~a8~a16~a32~a64 r64
+		%c2~c4~c8~c16~c32~c64 r64
+	}
+	\paper{
+		linewidth=0.;
 	}
 }
diff --git a/input/test/volta.fly b/input/test/volta.fly
index 17b42bd28f..9386a43669 100644
--- a/input/test/volta.fly
+++ b/input/test/volta.fly
@@ -4,7 +4,7 @@
 c' d e f |
 \repeat semi 2 { g a b c }
 \alternative { { c b a g a g a g} { f e d c } } \break
-c, d e f |  % Assertion failure if this line is removed!!
+%c, d e f |  % Assertion failure if this line is removed!!
 \repeat semi 2 { g a b c }
 \alternative { { c b a g \break a g a g} { f e d c } } \break
 c, d e f |
diff --git a/input/test/wtk-huh.ly b/input/test/wtk-huh.ly
deleted file mode 100644
index d7111dac20..0000000000
--- a/input/test/wtk-huh.ly
+++ /dev/null
@@ -1,24 +0,0 @@
-
-%{
-What's supposed to be demonstrated here?
-%}
-\score{
-	\context Staff \notes\relative c'''{
-		< \context Voice = one {
-		\stemup
-		\voiceone
-		[g8 a g f]
-		}
-		\context Voice=two
-		{
-		\stemdown
-		\voicetwo
-		[c8 f e d]
-		}>
-	}
-	\paper{
-		linewidth=-1.;
-	}
-}
-
-\version "1.1.52"; 
diff --git a/input/tril.ly b/input/tril.ly
deleted file mode 100644
index 60c612bd65..0000000000
--- a/input/tril.ly
+++ /dev/null
@@ -1,17 +0,0 @@
-\header{
-enteredby =	 "jcn";
-copyright =	 "PD";
-TestedFeatures =	 "This file tests trills" +
-	 "(Feta definitively is not an abbreviation of Font-En-TjA)";
-}
-
-\version "1.1.52";
-
-\score{
-	\notes{ 
-		c-\prall c-\mordent c-\prallprall c-\prallmordent
-		c-\upprall c-\downprall
-	}
-	\paper{ }
-}
-
diff --git a/lily/beam.cc b/lily/beam.cc
index e523466d3c..43975b65dc 100644
--- a/lily/beam.cc
+++ b/lily/beam.cc
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--1999, 1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
     Jan Nieuwenhuizen <janneke@gnu.org>
 
 */
@@ -194,27 +194,29 @@ Beam::get_default_dir () const
      wants to provide some real simple hands-on rules.
      
      We have our doubts, so we simply provide all sensible alternatives.
+
+     If dir is not determined: up (see stem::get_default_dir ())
   */
 
   Dir_algorithm a = (Dir_algorithm)rint(paper_l ()->get_var ("beam_dir_algorithm"));
   switch (a)
     {
     case MAJORITY:
-      beamdir = (count[UP] > count[DOWN]) ? UP : DOWN;
+      beamdir = (count[UP] >= count[DOWN]) ? UP : DOWN;
       break;
     case MEAN:
       // mean center distance
-      beamdir = (total[UP] > total[DOWN]) ? UP : DOWN;
+      beamdir = (total[UP] >= total[DOWN]) ? UP : DOWN;
       break;
     default:
     case MEDIAN:
       // median center distance
+      if (!count[DOWN])
+	beamdir = UP;
       if (!count[UP])
 	beamdir = DOWN;
-      else if (!count[DOWN])
-	beamdir = UP;
       else
-	beamdir = (total[UP] / count[UP] > total[DOWN] / count[DOWN]) ? UP : DOWN;
+	beamdir = (total[UP] / count[UP] >= total[DOWN] / count[DOWN]) ? UP : DOWN;
       break;
     }
   return beamdir;
diff --git a/lily/bow.cc b/lily/bow.cc
index e5daab3c1b..a3ac0bf073 100644
--- a/lily/bow.cc
+++ b/lily/bow.cc
@@ -46,8 +46,6 @@ Bow::do_brew_molecule_p () const
       cout << "dy_f_r: " << dy_f_drul_[RIGHT] << endl;
       cout << "dy_f: " << dy_f_drul_[RIGHT] - dy_f_drul_[LEFT] << endl;
     }
-  a.translate (Offset (dx_f_drul_[LEFT], dy_f_drul_[LEFT]));
-
   return new Molecule (a); 
 }
 
@@ -97,14 +95,11 @@ Bow::get_controls () const
 Array<Offset>
 Bow::get_encompass_offset_arr () const
 {
-  Offset d (dx_f_drul_[RIGHT] - dx_f_drul_[LEFT],
-    dy_f_drul_[RIGHT] - dy_f_drul_[LEFT]);
-  d.x() += extent (X_AXIS). length ();
-
-  Array<Offset> notes;
-  notes.push (Offset (0, 0));
-  notes.push (d);
-
-  return notes;
+  Array<Offset> offset_arr;
+  offset_arr.push (Offset (dx_f_drul_[LEFT], dy_f_drul_[LEFT]));
+  offset_arr.push (Offset (do_width ().length () + dx_f_drul_[RIGHT],
+		      dy_f_drul_[RIGHT]));
+		      
+  return offset_arr;
 }
 
diff --git a/lily/break-align-item.cc b/lily/break-align-item.cc
index bd8e723ea3..d8e284a388 100644
--- a/lily/break-align-item.cc
+++ b/lily/break-align-item.cc
@@ -25,7 +25,11 @@
 void
 Break_align_item::do_pre_processing()
 {
-  align_dir_ = break_status_dir();
+  if (break_status_dir() == LEFT)
+    align_dir_ = LEFT;
+  else
+    align_dir_ = RIGHT;
+  
   flip (&align_dir_);
   sort_elements ();
   Real interline= paper_l ()->get_realvar (interline_scm_sym);	
@@ -38,8 +42,6 @@ Break_align_item::do_pre_processing()
 	elems.push (dynamic_cast<Score_element*> (elem_l_arr_[i]));
     }
   
-
-  
   if (!elems.size ())
     return;
 
diff --git a/lily/encompass-info.cc b/lily/encompass-info.cc
index 0271eba297..8dd95437d4 100644
--- a/lily/encompass-info.cc
+++ b/lily/encompass-info.cc
@@ -23,33 +23,28 @@ Encompass_info::Encompass_info ()
   assert (0);
 }
 
-Encompass_info::Encompass_info (Note_column const* note, Direction dir, Slur const* slur_l)
+Encompass_info::Encompass_info (Note_column const* note_column, Direction dir, Slur const* slur_l)
 {
   interstaff_f_ = 0;
   
-  Paper_def* paper = note->paper_l ();
-  
-  // UGH
-  Real notewidth = paper->note_width () * 0.8;
-  
-
-  Stem* stem_l = note->stem_l_;
+  Stem* stem_l = note_column->stem_l_;
   if (!stem_l)
     {
-      warning ("Slur over rest?");
-      o_[X_AXIS] = note->hpos_f ();
+      warning (_ ("Slur over rest?"));
+      o_[X_AXIS] = note_column->hpos_f ();
       return; 
     }
   
-  Real internote = stem_l-> staff_line_leading_f ()/2.;
+  o_[X_AXIS] = stem_l->hpos_f ();
 
+#if 0
   /* 
+    Let's not do this; yields ugly assymetric slurs.
+
     set o_[X_AXIS] to middle of notehead or on the exact position of stem,
     according to slur direction
-   */
-  o_[X_AXIS] = stem_l->hpos_f ();
 
-  /*
+    
      stem_l->dir == dir
                       ________
            |   |     /        \
@@ -58,18 +53,34 @@ Encompass_info::Encompass_info (Note_column const* note, Direction dir, Slur con
 
    */
 
+  dx_f_drul_[d] = -d * spanned_drul_[d]->extent (X_AXIS).length ();
+
   if (stem_l->dir_ != dir)
-    o_[X_AXIS] -= 0.5 * notewidth * stem_l->dir_;
+    o_[X_AXIS] -= 0.5 * stem_l->dir_ * note_column->extent (X_AXIS).length ();
+
+#else
 
-  o_[Y_AXIS] = stem_l->extent (Y_AXIS)[dir];
   /*
-   leave a gap: slur mustn't touch head/stem
+    Instead; simply set x to middle of notehead
    */
-  o_[Y_AXIS] += 2.5 * internote * dir;
 
-  if (stem_l->dir_ != dir)
-    o_[Y_AXIS] += 1.0 * internote * dir;
+  o_[X_AXIS] -= 0.5 * stem_l->dir_ * note_column->extent (X_AXIS).length ();
+
+#endif
+
+  if (stem_l->dir_ == dir)
+    {
+      o_[Y_AXIS] = stem_l->extent (Y_AXIS)[dir];
+    }
+  else
+    {
+      o_[Y_AXIS] = note_column->extent (Y_AXIS)[dir];
+    }
 
+  /*
+   leave a gap: slur mustn't touch head/stem
+   */
+  o_[Y_AXIS] += dir * slur_l->paper_l ()->get_var ("slur_y_free");
 
   Dimension_cache *common = stem_l->common_group (slur_l, Y_AXIS);
   Align_element * align = dynamic_cast<Align_element*> (common->element_l ());
@@ -82,7 +93,7 @@ Encompass_info::Encompass_info (Note_column const* note, Direction dir, Slur con
       interstaff_f_ = align->threshold_interval_[MIN];
 
       Dimension_cache * slur_refpoint = slur_l->dim_cache_[Y_AXIS];
-      Dimension_cache * note_refpoint = note->dim_cache_[Y_AXIS];
+      Dimension_cache * note_refpoint = note_column->dim_cache_[Y_AXIS];
 
       while (slur_refpoint->parent_l_ != common)
 	slur_refpoint = slur_refpoint->parent_l_;
diff --git a/lily/include/slur.hh b/lily/include/slur.hh
index 5f634e700c..bf61df4b86 100644
--- a/lily/include/slur.hh
+++ b/lily/include/slur.hh
@@ -15,10 +15,6 @@
  */
 class Slur : public Bow
 {
-  bool broken_edge_b ( Direction dir) const;
-  bool normal_edge_b ( Direction dir) const;
-  Drul_array<Note_column*> extrema () const; 
-
 public:
   Slur ();
   VIRTUAL_COPY_CONS(Score_element);
diff --git a/lily/misc.cc b/lily/misc.cc
index ae015bdbc1..3f1f2ad949 100644
--- a/lily/misc.cc
+++ b/lily/misc.cc
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--1999, 1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
     Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
diff --git a/lily/parser.yy b/lily/parser.yy
index 7973a73d6b..bc65f297bd 100644
--- a/lily/parser.yy
+++ b/lily/parser.yy
@@ -241,7 +241,7 @@ yylex (YYSTYPE *s,  void * v_l)
 %type <pitch_arr>	pitch_list
 %type <music>	chord
 %type <pitch_arr>	chord_additions chord_subtractions chord_notes
-%type <pitch>	chord_addsub chord_note chord_inversion
+%type <pitch>	chord_note chord_inversion
 %type <midi>	midi_block midi_body
 %type <duration>	duration_length
 
@@ -1451,14 +1451,22 @@ chord_additions:
 	| '-' chord_notes {
 		$$ = $2;
 	}
+	| '-' CHORDMODIFIER_PITCH {
+		$$ = new Array<Musical_pitch>;
+		$$->push (*$2);
+	}
+	| '-' CHORDMODIFIER_PITCH chord_notes {
+		$$ = $3;
+		$$->push (*$2);
+	}
 	;
 
 chord_notes:
-	chord_addsub {
+	chord_note {
 		$$ = new Array<Musical_pitch>;
 		$$->push (*$1);
 	}
-	| chord_notes '.' chord_addsub {
+	| chord_notes '.' chord_note {
 		$$ = $1;
 		$$->push (*$3);
 	}
@@ -1478,12 +1486,6 @@ chord_subtractions:
 	forevery : X : optional_X sucks. Devise  a solution.
 */
 
-
-chord_addsub:
-	chord_note
-	| CHORDMODIFIER_PITCH
-	;
-
 chord_inversion:
 	{
 		$$ = 0;
diff --git a/lily/repeat-engraver.cc b/lily/repeat-engraver.cc
index 9ca3649fe3..5dd89eb2f5 100644
--- a/lily/repeat-engraver.cc
+++ b/lily/repeat-engraver.cc
@@ -104,8 +104,13 @@ Repeat_engraver::queue_events ()
 	  else
 	    becel.append (new Bar_create_event (walk_mom, "stop"));
 	}
-    } 
-  create_barmoments_queue_ = becel.head_ ;
+    }
+
+  Cons<Bar_create_event> *&tail = create_barmoments_queue_
+    ? last_cons (create_barmoments_queue_)->next_
+    : create_barmoments_queue_;
+
+  tail = becel.head_ ;
   becel.head_ = 0;
 }
 
@@ -129,7 +134,6 @@ Repeat_engraver::do_process_requests ()
   /*
     Do all the events that need to be done now.
   */
-  bool stop = false;
   while (head && now_mom () == head->car_->when_)
     {
       create_barmoments_queue_ = create_barmoments_queue_->next_;
diff --git a/lily/sequential-music-iterator.cc b/lily/sequential-music-iterator.cc
index a6602b7709..eb572cd817 100644
--- a/lily/sequential-music-iterator.cc
+++ b/lily/sequential-music-iterator.cc
@@ -10,6 +10,9 @@
 #include "debug.hh"
 #include "sequential-music-iterator.hh"
 #include "music-list.hh"
+// hmm
+//#include "request-chord-iterator.hh"
+#include "request-iterator.hh"
 
 void
 Sequential_music_iterator::do_print() const
@@ -141,9 +144,10 @@ Sequential_music_iterator::next_music_l ()
 	}
       else
 	{
-	  // urg FIXME: grace-iterator::next_music_l () fools me!
-	  if (dynamic_cast<Grace_iterator*> (iter_p_))
-	    iter_p_ = 0;
+	  // urg FIXME: sequential children should be iterated to finish
+	  if (dynamic_cast<Request_chord_iterator*> (iter_p_))
+	    delete iter_p_;
+	  iter_p_ = 0;
 	  leave_element ();
 	  
 	  if (cursor_)
diff --git a/lily/slur.cc b/lily/slur.cc
index 827e9a0222..82aaa7e544 100644
--- a/lily/slur.cc
+++ b/lily/slur.cc
@@ -3,16 +3,14 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1996,  1997--1999, 1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1996,  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
     Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
 /*
   [TODO]
-    * URG: share code with tie
-    * begin and end should be treated as a Script.
-    * damping
-    * slur from notehead to stemend: c''()b''
+    * begin and end should be treated as a/acknowledge Scripts.
+    * broken slur should have uniform trend
  */
 
 #include "slur.hh"
@@ -42,7 +40,6 @@ Slur::add_column (Note_column*n)
   else
     {
       encompass_arr_.push (n);
-      //  n->stem_l_->slur_l_ = this;
       add_dependency (n);
     }
 }
@@ -95,36 +92,6 @@ Note_column_compare (Note_column *const&n1 , Note_column* const&n2)
   return Item::left_right_compare (n1, n2);
 }
 
-bool
-Slur::broken_edge_b ( Direction dir) const
-{
-  return extrema ()[dir] != spanned_drul_[dir];
-}
-
-bool
-Slur::normal_edge_b ( Direction dir) const
-{
-  Note_column *n = extrema ()[dir];
-  return !broken_edge_b ( dir)
-    && n->stem_l_
-    && n->stem_l_->get_elt_property (transparent_scm_sym) == SCM_BOOL_F
-    && n->head_l_arr_.size ();
-}
-
-Drul_array<Note_column*>
-Slur::extrema ()const
-{
-  Drul_array<Note_column*> extrema;
-  extrema[LEFT] = encompass_arr_[0];
-  extrema[RIGHT] = encompass_arr_.top ();
-  return extrema;
-}
-
-/*
-  TODO.
-
-  Unhair this.
- */
 void
 Slur::do_post_processing ()
 {
@@ -132,237 +99,231 @@ Slur::do_post_processing ()
   if (!dir_)
     dir_ = get_default_dir ();
 
-  Real interline_f = paper_l ()->get_realvar (interline_scm_sym);
-  Real internote_f = interline_f / 2;
-  // URG
-  Real notewidth_f = paper_l ()->note_width () * 0.8;
-
   /* 
-   [OSU]: slur and tie placement
+   Slur and tie placement [OSU]
 
-   slurs:
-   * x = center of head (upside-down: inner raakpunt stem) - d * gap
+   Slurs:
+   * x = centre of head - d * x_gap_f
 
-   * y = length < 5ss : horizontal raakpunt + d * 0.25 ss
+   TODO:
+   * y = length < 5ss : horizontal tangent + d * 0.25 ss
      y = length >= 5ss : y next interline - d * 0.25 ss
-     --> height <= 5 length ?? we use <= 3 length, now...
    */
-  
-  Real gap_f = paper_l ()->get_var ("slur_x_gap");
 
+  Real interline_f = paper_l ()->get_realvar (interline_scm_sym);
+  Real internote_f = interline_f / 2;
+
+  Real x_gap_f = paper_l ()->get_var ("slur_x_gap");
+  Real y_gap_f = paper_l ()->get_var ("slur_y_gap");
+
+  Drul_array<Note_column*> note_column_drul;
+  note_column_drul[LEFT] = encompass_arr_[0];
+  note_column_drul[RIGHT] = encompass_arr_.top ();
 
-  Direction d=LEFT;
- 
+  bool fix_broken_b = false;
+  Direction d = LEFT;
   do 
     {
-      if (broken_edge_b (d))
+      dx_f_drul_[d] = dy_f_drul_[d] = 0;
+      if ((note_column_drul[d] == spanned_drul_[d])
+	  && note_column_drul[d]->head_l_arr_.size ()
+	  && (note_column_drul[d]->stem_l_))
 	{
-	  // ugh -- check if needed
-	  dx_f_drul_[d] = -d 
-	    *(spanned_drul_[d]->extent (X_AXIS).length () - 0.5 * notewidth_f);
-
-	  // prebreak
-	  if (d == RIGHT)
+	  Stem* stem_l = note_column_drul[d]->stem_l_;
+	  /*
+	    side directly attached to note head;
+	    no beam getting in the way
+	  */
+	  if (((stem_l->get_elt_property (transparent_scm_sym) != SCM_BOOL_F)
+	       || !((stem_l->dir_ == dir_) && (dir_ != d)))
+	      && !((dir_ == stem_l->dir_)
+		   && stem_l->beam_l_ && (stem_l->beams_i_drul_[-d] >= 1)))
 	    {
-	      dx_f_drul_[LEFT] = spanned_drul_[LEFT]->extent (X_AXIS).length ();
-	      
-	      // urg -- check if needed
-	      if (encompass_arr_.size () > 1)
-		dx_f_drul_[RIGHT] += notewidth_f;
+	      dx_f_drul_[d] = spanned_drul_[d]->extent (X_AXIS).length () / 2;
+	      dx_f_drul_[d] -= d * x_gap_f;
+
+	      if (stem_l->dir_ != dir_)
+		{
+		  dy_f_drul_[d] = note_column_drul[d]->extent (Y_AXIS)[dir_];
+		}
+	      else
+		{
+		  dy_f_drul_[d] = stem_l->chord_start_f ()
+		    + dir_ * internote_f;
+		}
+	      dy_f_drul_[d] += dir_ * y_gap_f;
 	    }
-	}
-      /*
-        normal slur
-       */
-      else if (normal_edge_b (d))
-        {
-	  Real notewidth_f = extrema ()[d]->extent (X_AXIS).length ();
-	  dy_f_drul_[d] = (int)rint (extrema ()[d]->stem_l_-> extent (Y_AXIS)[dir_]);
-	  dx_f_drul_[d] += 0.5 * notewidth_f - d * gap_f;
-	  if (dir_ == extrema ()[d]->stem_l_->dir_)
+	  /*
+	    side attached to (visible) stem
+	  */
+	  else
 	    {
-	      if (dir_ == d)
-		dx_f_drul_[d] += 0.5 * dir_ * notewidth_f;
+	      dx_f_drul_[d] = stem_l->hpos_f ()
+		- spanned_drul_[d]->absolute_coordinate (X_AXIS);
+	      /*
+		side attached to beamed stem
+	       */
+	      if (stem_l->beam_l_ && (stem_l->beams_i_drul_[-d] >= 1))
+		{
+		  dy_f_drul_[d] = stem_l->extent (Y_AXIS)[dir_];
+		  dy_f_drul_[d] += dir_ * 2 * y_gap_f;
+		}
+	      /*
+		side attached to notehead, with stem getting in the way
+	       */
 	      else
-		dx_f_drul_[d] += 0.25 * dir_ * notewidth_f;
+		{
+		  dx_f_drul_[d] -= d * x_gap_f;
+		  
+		  dy_f_drul_[d] = stem_l->chord_start_f ()
+		    + dir_ * internote_f;
+		  dy_f_drul_[d] += dir_ * y_gap_f;
+		}
 	    }
 	}
-	else 
-	  {
-	    Real notewidth_f = extrema ()[d]->extent (X_AXIS).length ();
-	    dy_f_drul_[d] = (int)rint (extrema ()[d]->head_positions_interval ()
-				       [dir_]) * internote_f;
-	    dx_f_drul_[d] += 0.5 * notewidth_f - d * gap_f;
+      /*
+	loose end
+      */
+      else
+	{
+	  dx_f_drul_[d] -= d * x_gap_f;
+	  /*
+	    broken: should get y from other piece, so that slur
+	    continues up/down trend
+
+	    for now: be horizontal..
+	  */
+	  fix_broken_b = true;
 	}
-	dy_f_drul_[d] += dir_ * interline_f;
-	if (extrema ()[d]->stem_l_ && (dir_ == extrema ()[d]->stem_l_->dir_))
-	  dy_f_drul_[d] -= dir_ * internote_f;
-      }
-  while (flip(&d) != LEFT);
+    }
+  while (flip (&d) != LEFT);
 
-  // now that both are set, do dependent
-  do 
-    {
-      if (broken_edge_b (d))
-        {
-	  Direction u = d;
-	  flip(&u);
+  if (fix_broken_b)
+    do {
+      if (dy_f_drul_[d])
+	dy_f_drul_[-d] = dy_f_drul_[d];
+    }
+    while (flip (&d) != LEFT);
+	
+
+  /*
+    Now we've got a fine slur
+    Catch and correct some ugly cases
+   */
 
-	  // postbreak
-	  if (d == LEFT)
-	    dy_f_drul_[u] += dir_ * internote_f;
+  Real dx_f = do_width ().length () + dx_f_drul_[RIGHT] - dx_f_drul_[LEFT];
+  Real dy_f = dy_f_drul_[RIGHT] - dy_f_drul_[LEFT];
+  Real height_f = do_height ().length ();
 
-	  dy_f_drul_[d] = dy_f_drul_[u];
-	}
-     }
-  while (flip(&d) != LEFT);
+  Real height_damp_f = paper_l ()->get_var ("slur_height_damping");
+  Real slope_damp_f = paper_l ()->get_var ("slur_slope_damping");
+  Real ratio_f;
+
+
+  /*
+    Avoid too steep slurs.
+   */
+  ratio_f = abs (dy_f / dx_f);
+  if (ratio_f > slope_damp_f)
+    {
+      Direction d = (Direction)(- dir_ * (sign (dy_f)));
+      if (!d)
+	d = LEFT;
+      dy_f_drul_[d] += dir_ * (ratio_f - slope_damp_f) * dx_f;
+    }
 
   /*
-    Slur should follow line of music
+   Avoid too high slurs 
    */
-  if (normal_edge_b (LEFT)
-      && normal_edge_b (RIGHT)
-      && (extrema ()[LEFT]->stem_l_ != extrema ()[RIGHT]->stem_l_))
+  ratio_f = abs (height_f / dx_f);
+  if (ratio_f > height_damp_f)
     {
-      Real note_dy = extrema ()[RIGHT]->stem_l_->head_positions ()[dir_]
-	- extrema ()[LEFT]->stem_l_->head_positions ()[dir_];
-      Real dy = dy_f_drul_[RIGHT] - dy_f_drul_[LEFT];
+      Direction d = (Direction)(- dir_ * (sign (dy_f)));
+      if (!d)
+	d = LEFT;
+      dy_f_drul_[d] += dir_ * height_f * height_damp_f;
       /*
-	Should we always follow note-heads, (like a tie)?
-	For now, only if the note_dy != slur_dy, we'll do
-	slur_dy := note_dy * factor.
-      */
-      if (sign (dy) != sign (note_dy))
+	if y positions at same height, correct both ends
+       */
+      if (abs (dy_f / dx_f ) < slope_damp_f)
 	{
-	  Real damp_f = paper_l ()->get_var ("slur_slope_follow_music_factor");
-	  Real realdy = note_dy * damp_f;
-	  Direction adjust_dir = (Direction)(- dir_ * sign (realdy));
-	  if (!adjust_dir)
-	    adjust_dir = -dir_;
-	  /*
-	    adjust only if no beam gets in the way
-	   */
-	  if (!extrema ()[adjust_dir]->stem_l_->beam_l_
-	      || (adjust_dir == extrema ()[adjust_dir]->stem_l_->dir_)
-	      || (extrema ()[adjust_dir]->stem_l_->beams_i_drul_[-adjust_dir] < 1))
-	    {
-	      dy_f_drul_[adjust_dir] = dy_f_drul_[-adjust_dir]
-		+ 2 * adjust_dir * realdy;
-	      Real dx = notewidth_f / 2;
-	      if (adjust_dir != extrema ()[adjust_dir]->stem_l_->dir_)
-		dx /= 2;
-	      dx_f_drul_[adjust_dir] -= adjust_dir * dx;
-	    }
+	  dy_f_drul_[-d] += dir_ * height_f * height_damp_f;
 	}
     }
 
   /*
-    Avoid too steep slurs.
-   */
-  Real damp_f = paper_l ()->get_var ("slur_slope_damping");
-  Offset d_off = Offset (dx_f_drul_[RIGHT] - dx_f_drul_[LEFT],
-    dy_f_drul_[RIGHT] - dy_f_drul_[LEFT]);
-  d_off[X_AXIS] += extent (X_AXIS).length ();
-
-  Real ratio_f = abs (d_off[Y_AXIS] / d_off[X_AXIS]);
-  if (ratio_f > damp_f)
-    dy_f_drul_[(Direction)(- dir_ * sign (d_off[Y_AXIS]))] +=
-      dir_ * (ratio_f - damp_f) * d_off[X_AXIS];
+    If, after correcting, we're close to stem-end...
+  */
+  Real snap_f = paper_l ()->get_var ("slur_snap_to_stem");
+  do
+    {
+      if ((note_column_drul[d] == spanned_drul_[d])
+	  && (note_column_drul[d]->stem_l_)
+	  && (note_column_drul[d]->stem_l_->dir_ == dir_)
+	  && (abs (note_column_drul[d]->stem_l_->extent (Y_AXIS)[dir_]
+		   - dy_f_drul_[d]) <= snap_f))
+	{
+	  /*
+	    attach to stem-end
+	  */
+	  Stem* stem_l = note_column_drul[d]->stem_l_;
+	  dx_f_drul_[d] = stem_l->hpos_f ()
+	    - spanned_drul_[d]->absolute_coordinate (X_AXIS);
+	  dy_f_drul_[d] = stem_l->extent (Y_AXIS)[dir_];
+	  dy_f_drul_[d] += dir_ * 2 * y_gap_f;
+	}
+    }
+  while (flip (&d) != LEFT);
 }
 
 Array<Offset>
 Slur::get_encompass_offset_arr () const
 {
-  Real notewidth = paper_l ()->note_width () * 0.8;
-  Real gap = paper_l ()->get_var ("slur_x_gap");
-
-  /*
-  urg.  Calcs done wrt the leftmost note.  Fixme.
-
-  Calcs ignore possibility of pre/postbreak.
-
-
-  */
-
-  Offset left = Offset (dx_f_drul_[LEFT], dy_f_drul_[LEFT]);
-  left[X_AXIS] += encompass_arr_[0]->stem_l_->hpos_f ();
-
-  Real internote = encompass_arr_[0]->stem_l_->staff_line_leading_f ()/2.0;
-
-  /*
-    <URG>
-    i don't understand these two, but *must* for symmetry 
-    look at encompass array: 
-       lilypond -D input/test/slur-symmetry*.ly
-       lilypond -D input/test/sleur.ly
-
-    do_post_processing should have calculated these into
-    dx_f_drul_[], no??
-
-   */
-
-  if (dir_ != encompass_arr_[0]->stem_l_->dir_)
-    left[X_AXIS] += - 0.5 * notewidth * encompass_arr_[0]->stem_l_->dir_
-      + gap;
-  else if (encompass_arr_[0]->stem_l_->dir_ == UP)
-    left[X_AXIS] -= notewidth;
-
-  if ((dir_ == encompass_arr_[0]->stem_l_->dir_) 
-    && (encompass_arr_[0]->stem_l_->dir_ == DOWN))
-    left[Y_AXIS] -= internote * encompass_arr_[0]->stem_l_->dir_;
-  /* </URG> */
-
-  Offset d = Offset (dx_f_drul_[RIGHT] - dx_f_drul_[LEFT],
-    dy_f_drul_[RIGHT] - dy_f_drul_[LEFT]);
-  d[X_AXIS] += extent (X_AXIS).length ();
+  Array<Offset> offset_arr;
+  Offset origin (absolute_coordinate (X_AXIS), 0);
 
   int first = 1;
-  int last = encompass_arr_.size () - 1;
+  int last = encompass_arr_.size () - 2;
 
-
-  Array<Offset> notes;
-  notes.push (Offset (0,0));
-
-  // prebreak
-  if (broken_edge_b (RIGHT))
-    last++;
-  else
-    {
-      Encompass_info info (encompass_arr_.top (), dir_, this);
-      d[Y_AXIS] += info.interstaff_f_;
-    }
-  
-  // postbreak
-  if (broken_edge_b (LEFT))
+  /*
+    left is broken edge
+  */
+  if (encompass_arr_[0] != spanned_drul_[LEFT])
     {
       first--;
-      /*
-        interstaff postbreak: slur begins at height of last note
-       */
-      Encompass_info info (encompass_arr_[0], dir_, this);
-      notes[0][Y_AXIS] += info.interstaff_f_;
     }
-  else
+  Encompass_info left_info (encompass_arr_[0], dir_, this);
+  offset_arr.push (Offset (0, left_info.interstaff_f_));
+
+  /*
+    right is broken edge
+  */
+  if (encompass_arr_.top () != spanned_drul_[RIGHT])
     {
-      Encompass_info info (encompass_arr_[0], dir_, this);
-      notes[0][Y_AXIS] += info.interstaff_f_;
+      last++;
     }
 
-  for (int i = first; i < last; i++)
+  for (int i = first; i <= last; i++)
     {
       Encompass_info info (encompass_arr_[i], dir_, this);
-      notes.push (info.o_ - left);
+      offset_arr.push (info.o_ - origin);
     }
 
-  /*
-    interstaff prebreak: slur ends at height of last note
-   */
-  if (broken_edge_b (RIGHT))
-    d[Y_AXIS] = notes.top ()[Y_AXIS];
+  offset_arr.push (Offset (do_width ().length (), 0));
 
-  notes.push (d);
+#if 1
+  offset_arr[0] += Offset (dx_f_drul_[LEFT], dy_f_drul_[LEFT]);
+  offset_arr.top () += Offset (dx_f_drul_[RIGHT], dy_f_drul_[RIGHT]);
+#else
+  /*
+    check non-disturbed slur
+    FIXME: ends off by a tiny bit!!
+  */
+  offset_arr[0] += Offset (0, dy_f_drul_[LEFT]);
+  offset_arr.top () += Offset (0, dy_f_drul_[RIGHT]);
+#endif
   
-  return notes;
+  return offset_arr;
 }
 
 
diff --git a/lily/spacing-spanner.cc b/lily/spacing-spanner.cc
index fad2d6903a..646d37cd97 100644
--- a/lily/spacing-spanner.cc
+++ b/lily/spacing-spanner.cc
@@ -67,6 +67,7 @@ Spacing_spanner::do_measure (int col1, int col2) const
 
   Array<Spring> meas_springs;
 
+  Real non_musical_space_strength = paper_l ()->get_var ("non_musical_space_strength");
   for (int i= col1; i < col2; i++)
     {
       Item * l = scol(i);
@@ -101,7 +102,7 @@ Spacing_spanner::do_measure (int col1, int col2) const
 	  else if (!lc->musical_b() && i+1 < col_count())
 	    {
 	      s.distance_f_ = default_bar_spacing (lc,rc,shortest);
-	      s.strength_f_ = 2.0;
+	      s.strength_f_ = non_musical_space_strength; // fixed after complaints by michael krause
 	    }
 	  else if (lc->musical_b())
 	    {
@@ -127,7 +128,15 @@ Spacing_spanner::do_measure (int col1, int col2) const
 
 	      s.distance_f_ += correction;
 	    }
-	  
+
+	  if (s.distance_f_ <=0)
+	    {
+	      /*
+		\bar "".  We give it 0 space, with high strength. 
+	       */
+	      s.distance_f_ = 0.0 PT;
+	      s.strength_f_ = 20.0; 
+	    }
 	  meas_springs.push (s);	
 	}
     }
diff --git a/lily/spanner.cc b/lily/spanner.cc
index 17ca378449..9fbd9b8226 100644
--- a/lily/spanner.cc
+++ b/lily/spanner.cc
@@ -41,7 +41,6 @@ Spanner::break_into_pieces ()
     }
   
   Link_array<Item> break_points = pscore_l_->broken_col_range (left,right);
-  Link_array<Spanner> broken_into_l_arr;
 
   break_points.insert (left,0);
   break_points.push (right);
diff --git a/lily/spring-spacer.cc b/lily/spring-spacer.cc
index e890602869..aee2bba8bc 100644
--- a/lily/spring-spacer.cc
+++ b/lily/spring-spacer.cc
@@ -407,8 +407,7 @@ Spring_spacer::add_column (Paper_column  *col, bool fixed, Real fixpos)
       Real d  = cr.distance_f_;
       if (fabs (d) < EPS)
 	{
-	  connect (idx, this_rank, 0.0, 10); // large strength. 
-	  programming_error ("requesting zero distance.");
+	  connect (idx, this_rank, cr.distance_f_, cr.strength_f_); // large strength. 
 	}
       else
 	connect (idx, this_rank, cr.distance_f_,
diff --git a/lily/tie.cc b/lily/tie.cc
index dc7ac39b9c..86eab96d1d 100644
--- a/lily/tie.cc
+++ b/lily/tie.cc
@@ -35,11 +35,15 @@ Tie::Tie()
   ugh: direction of the Tie is more complicated.  See [Ross] p136 and further
  */
 Direction
-Tie::get_default_dir() const
+Tie::get_default_dir () const
 {
-  int m= (head_l_drul_[LEFT]->position_i_ 
+  int m = (head_l_drul_[LEFT]->position_i_ 
 	  + head_l_drul_[RIGHT]->position_i_) /2;
-  return(m < 0)? DOWN : UP;
+  /*
+    If dir is not determined: inverse of stem: down
+    (see stem::get_default_dir ())
+   */
+  return (m <= 0)? DOWN : UP;
 }
 
 void
@@ -60,91 +64,116 @@ Tie::do_add_processing()
 void
 Tie::do_post_processing()
 {
-  // URG: share code with slur!
   assert (head_l_drul_[LEFT] || head_l_drul_[RIGHT]);
 
-  // URG
-  Real notewidth = paper_l ()->note_width () * 0.8;
   Real interline_f = paper_l ()->get_realvar (interline_scm_sym);
+  Real internote_f = interline_f / 2;
+  Real x_gap_f = paper_l ()->get_var ("tie_x_gap");
+  Real y_gap_f = paper_l ()->get_var ("tie_y_gap");
 
   /* 
-   [OSU]: slur and tie placement
+   Slur and tie placement [OSU]
+
+   Ties:
 
-   ties:
-   * x = inner raakpunt - d * gap
+       * x = inner vertical tangent - d * gap
 
-   * y = length < 5ss : horizontal raakpunt
-     y = length >= 5ss : y next interline - d * 0.25 ss
-     --> height <= 5 length ?? we use <= 3 length, now...
    */
 
-  Real gap_f = paper_l ()->get_var ("slur_x_gap");
 
+  /*
+    OSU: not different for outer notes, so why all this code?
+    ie,  can we drop this, or should it be made switchable.
+   */
+#if 0
   Direction d = LEFT;
   do
     {
-      dy_f_drul_[d] = .5 * interline_f * (head_l_drul_[d] 
-		       ? head_l_drul_[d]->position_i_
-		       : head_l_drul_[(Direction)-d]->position_i_);
-    }
-  while (flip(&d) != LEFT);
-
-  do
-    {
-      // tie attached to outer notehead
+      Real head_width_f = head_l_drul_[d]
+	? head_l_drul_[d]->extent (X_AXIS).length ()
+	: 0;
+      /*
+	side attached to outer (upper or lower) notehead of chord
+      */
       if (head_l_drul_[d]
-	  && head_l_drul_[d]->remove_elt_property (extremal_scm_sym) != SCM_BOOL_F)
-	{
-	  if (d == LEFT)
-	    dx_f_drul_[d] += notewidth;
-	  dx_f_drul_[d] += -d * gap_f;
-	  /* attach to outer 3/4 end of head */
-	  dy_f_drul_[d] += dir_ * 0.25 * interline_f;
-	}
-      // tie attached to inner notehead
-      else if (head_l_drul_[d] && d == LEFT)
+	  /*
+	    && head_l_drul_[d]->remove_elt_property (extremal_scm_sym) != SCM_BOOL_F)
+	    ugh, ugh:
+
+	        a~a~a;
+
+	    to second tie, middle notehead seems not extremal
+
+	    Getting scared a bit by score-element's comment:
+	    // is this a good idea?
+	  */
+	  && (head_l_drul_[d]->get_elt_property (extremal_scm_sym)
+	      != SCM_BOOL_F))
 	{
-	  dx_f_drul_[d] += -d * notewidth;
+	if (d == LEFT)
+	    dx_f_drul_[d] += head_width_f;
+	  dx_f_drul_[d] += -d * x_gap_f;
 	}
-      // uhm? loose end of tie // tie attached to stem
+      /*
+	side attached to inner notehead
+      */
       else
 	{
-	  dx_f_drul_[d] = -d * (spanned_drul_[d]->extent (X_AXIS).length () 
-			        -0.5 * notewidth);
+	  dx_f_drul_[d] += -d * head_width_f;
 	}
-    }
-  while (flip(&d) != LEFT);
+    } while (flip (&d) != LEFT);
 
-  // now that both are set, do dependent
-  do
-    {
-      // tie attached to outer notehead
-      if (!head_l_drul_[d])
-	{
-	  dy_f_drul_[d] = dy_f_drul_[(Direction) -d];
-	}
-    }
-  while (flip(&d) != LEFT);
+#else
 
-  /*
-    Avoid too steep ties
-      * slur from notehead to stemend: c''()b''
+  if (head_l_drul_[LEFT])
+    dx_f_drul_[LEFT] = head_l_drul_[LEFT]->extent (X_AXIS).length ();
+  dx_f_drul_[LEFT] += x_gap_f;
+  dx_f_drul_[RIGHT] -= x_gap_f;
+
+#endif
+
+  /* 
+   Slur and tie placement [OSU]  -- check this
+
+   Ties:
+
+       * y = dx <  5ss: horizontal tangent
+	 y = dx >= 5ss: y next interline - d * 0.25 ss
+
+	 which probably means that OSU assumes that
+
+	    dy <= 5 dx
+
+	 for smal slurs
    */
-  Real damp_f = paper_l ()->get_var ("tie_slope_damping");
-  Offset d_off = Offset (dx_f_drul_[RIGHT] - dx_f_drul_[LEFT],
-    dy_f_drul_[RIGHT] - dy_f_drul_[LEFT]);
-  d_off.x () += extent (X_AXIS).length ();
-
-  Real ratio_f = abs (d_off.y () / d_off.x ());
-  if (ratio_f > damp_f)
-    dy_f_drul_[(Direction)(- dir_ * sign (d_off.y ()))] +=
-      dir_ * (ratio_f - damp_f) * d_off.x ();
+
+  int ypos_i = head_l_drul_[LEFT] ? head_l_drul_[LEFT]->position_i_
+    : head_l_drul_[RIGHT]->position_i_;
+
+  Real y_f = internote_f * ypos_i; 
+
+  Real dx_f = extent (X_AXIS).length () + dx_f_drul_[RIGHT] - dx_f_drul_[LEFT];
+  if (dx_f < paper_l ()->get_var ("tie_staffspace_length"))
+    {
+      if (abs (ypos_i) % 2)
+	y_f += dir_ * internote_f;
+      y_f += dir_ * y_gap_f;
+    }
+  else
+    {
+      if (! (abs (ypos_i) % 2))
+	y_f += dir_ * internote_f;
+      y_f += dir_ * internote_f;
+      y_f -= dir_ * y_gap_f;
+    }
+  
+  dy_f_drul_[LEFT] = dy_f_drul_[RIGHT] = y_f;
 }
 
 void
 Tie::do_substitute_element_pointer (Score_element*o, Score_element*n)
 {
-  Note_head *new_l =n?dynamic_cast<Note_head *> (n):0;
+  Note_head *new_l = n ? dynamic_cast<Note_head *> (n) : 0;
   if (dynamic_cast <Item *> (o) == head_l_drul_[LEFT])
     head_l_drul_[LEFT] = new_l;
   else if (dynamic_cast <Item *> (o) == head_l_drul_[RIGHT])
diff --git a/ly/params.ly b/ly/params.ly
index afc68d5ab7..47b28f061e 100644
--- a/ly/params.ly
+++ b/ly/params.ly
@@ -87,17 +87,23 @@ beam_steep_slope = 0.2 / 1.0;
 
 % OSU: suggested gap = ss / 5;
 slur_x_gap = \interline / 5.0;
+slur_y_gap = 0.25 * \interline;
+slur_y_free = 0.75 * \interline;
 slur_x_minimum = 3.0 * \interline;
 
 % slope damping: keep dy/dx < slur_slope_damping
-slur_slope_damping = 0.6;
-
-% dy_slur := dy_music * factor
-slur_slope_follow_music_factor = 0.8;
+slur_slope_damping = 0.3;
+% height damping: keep h/dx < slur_height_damping
+slur_height_damping = 0.5;
+% snap to stem if slur ends closer to stem than
+slur_snap_to_stem = 1.5 * \interline;
 
 tie_x_minimum = \slur_x_minimum;
+% OSU: tie gap == slur gap
 tie_x_gap = \slur_x_gap;
-tie_slope_damping = 0.8;
+tie_y_gap = 0.25 * \interline;
+% length of a tie that's a staffspace high
+tie_staffspace_length = 4.0 * \interline;
 
 % ugh: rename to bow (in bezier.cc and fonts.doc too...)
 % slur_thickness = 1.8 * \staffline;
@@ -180,6 +186,8 @@ postBreakPadding = 0.0;
 stemSpacingCorrection = 0.5*\interline;
 
 
+% relative strength of space following  time signature, 
+non_musical_space_strength = 4.0; 
 
 
 
diff --git a/make/out/lelievijver.lsm b/make/out/lelievijver.lsm
index 8264b668fb..b72fd64cc0 100644
--- a/make/out/lelievijver.lsm
+++ b/make/out/lelievijver.lsm
@@ -1,15 +1,15 @@
 Begin3
 Titel: LilyPond
-Versie: 1.1.56
-Inschrijf datum: 11JUL99
+Versie: 1.1.57
+Inschrijf datum: 13JUL99
 Beschrijving: @FLAPTEKST@
 Trefwoorden: muziek typezetten midi notatie
 Auteur: hanwen@stack.nl (Han-Wen Nienhuys)
 	janneke@gnu.org (Jan Nieuwenhuizen)
 Onderhouden door: hanwen@cs.ruu.nl (Han-Wen Nienhuys)
 Voornaamste plek: sunsite.unc.edu /pub/Linux/apps
-	770k lilypond-1.1.56.tar.gz 
+	770k lilypond-1.1.57.tar.gz 
 Oorspronkelijke plek: ftp.cs.uu.nl /pub/GNU/LilyPond/development/
-	770k lilypond-1.1.56.tar.gz 
+	770k lilypond-1.1.57.tar.gz 
 Copi-eer voorwaarden: GPL
 End
diff --git a/make/out/lilypond.lsm b/make/out/lilypond.lsm
index 9c038fe229..5a29149615 100644
--- a/make/out/lilypond.lsm
+++ b/make/out/lilypond.lsm
@@ -1,7 +1,7 @@
 Begin3
 Title: LilyPond
-Version: 1.1.56
-Entered-date: 11JUL99
+Version: 1.1.57
+Entered-date: 13JUL99
 Description: 
 
 LilyPond is the GNU Project music typesetter. It transforms a musical
@@ -12,8 +12,8 @@ Author: hanwen@cs.ruu.nl (Han-Wen Nienhuys)
 	janneke@gnu.org (Jan Nieuwenhuizen)
 Maintained-by: hanwen@stack.nl (Han-Wen Nienhuys)
 Primary-site: sunsite.unc.edu /pub/Linux/apps/sound/convert
-	770k lilypond-1.1.56.tar.gz 
+	770k lilypond-1.1.57.tar.gz 
 Original-site: ftp.cs.uu.nl /pub/GNU/LilyPond/development/
-	770k lilypond-1.1.56.tar.gz 
+	770k lilypond-1.1.57.tar.gz 
 Copying-policy: GPL
 End
diff --git a/make/out/lilypond.spec b/make/out/lilypond.spec
index 6f6cd0721f..6f42f2001d 100644
--- a/make/out/lilypond.spec
+++ b/make/out/lilypond.spec
@@ -1,9 +1,9 @@
 Name: lilypond
-Version: 1.1.56
+Version: 1.1.57
 Release: 1
 Copyright: GPL
 Group: Applications/Publishing
-Source0: ftp.cs.uu.nl:/pub/GNU/LilyPond/development/lilypond-1.1.56.tar.gz
+Source0: ftp.cs.uu.nl:/pub/GNU/LilyPond/development/lilypond-1.1.57.tar.gz
 Summary: A program for printing sheet music.
 URL: http://www.cs.uu.nl/~hanwen/lilypond
 Packager: Han-Wen Nienhuys <hanwen@cs.uu.nl>
diff --git a/midi2ly/include/midi-score-parser.hh b/midi2ly/include/midi-score-parser.hh
index 02d6f18aeb..fca4fdf006 100644
--- a/midi2ly/include/midi-score-parser.hh
+++ b/midi2ly/include/midi-score-parser.hh
@@ -24,8 +24,6 @@ private:
   void open (String filename_str, Sources*);
 
   void parse_header ();
-  // why the #*&$#{%) has Link_array another behaviour than Link_list??
-  //  int find_earliest_i (Link_array<Midi_track_parser*>& tracks);
   int find_earliest_i (Link_array<Midi_track_parser>& tracks);
   Mudela_score* parse_score ();
 };	    
diff --git a/scm/lily.scm b/scm/lily.scm
index 5914bf1f8f..139b94cfa8 100644
--- a/scm/lily.scm
+++ b/scm/lily.scm
@@ -94,8 +94,8 @@
    (("" "Span_bar") . (extra_space 0.0))
    (("" "Time_signature") . (extra_space 0.0))
    (("" "begin-of-note") . (minimum_space 1.5))
-   (("Clef_item" "Key_item") . (minimum_space 3.5))
-   (("Key_item" "Time_signature") . (extra_space 2.0))
+   (("Clef_item" "Key_item") . (minimum_space 4.0))
+   (("Key_item" "Time_signature") . (extra_space 1.0))
    (("Clef_item"  "Time_signature") . (minimum_space 3.5))
    (("Staff_bar" "Clef_item") .   (minimum_space 1.0))
    (("Clef_item"  "Staff_bar") .  (minimum_space 3.7))
diff --git a/tex/fetdefs.tex b/tex/fetdefs.tex
new file mode 100644
index 0000000000..076cee8885
--- /dev/null
+++ b/tex/fetdefs.tex
@@ -0,0 +1,15 @@
+% fetdefs.tex
+% encapsulating tex backend for auto-generated feta definitions
+
+% fix chord.cc::banter_str before removing these
+\def\fetdef#1#2{%
+  \def#1{\hbox{\char#2}}}
+
+\fetdef\sharp{16}
+\fetdef\flat{18}
+\font\fetasixteenfont=feta16
+\def\fetafont{\fetasixteenfont}
+\def\textflat{{\fetafont\raise 1ex\hbox{\flat}}}
+\def\textsharp{{\fetafont\raise1ex\hbox{\sharp}}}
+
+\endinput
diff --git a/tex/lilyponddefs.tex b/tex/lilyponddefs.tex
index 696bf389a3..ada0b6442d 100644
--- a/tex/lilyponddefs.tex
+++ b/tex/lilyponddefs.tex
@@ -57,5 +57,7 @@
         nolilyfooter\texsuffix\endcsname
 \fi
 
+% fix chord.cc::banter_str before removing these
+\input fetdefs
 
 \endinput
diff --git a/tex/mudela-book.tex b/tex/mudela-book.tex
index c79076e597..2b13cf5be4 100644
--- a/tex/mudela-book.tex
+++ b/tex/mudela-book.tex
@@ -28,8 +28,8 @@
 % generates par
 \def\interscoreline{}
 % generates par
-\musixsixteendefs
-\def\musixsixteendefs{}
+%\musixsixteendefs
+%\def\musixsixteendefs{}
 \def\nolilyfooter{}
 %urg: missing \begin{document}?
 \def\noindent{}
-- 
2.39.5