]> git.donarmstrong.com Git - lilypond.git/commitdiff
patch::: 1.3.129.jcn2
authorJan Nieuwenhuizen <janneke@gnu.org>
Tue, 20 Feb 2001 15:57:26 +0000 (16:57 +0100)
committerJan Nieuwenhuizen <janneke@gnu.org>
Tue, 20 Feb 2001 15:57:26 +0000 (16:57 +0100)
1.3.129.jcn2
============

* Implemented Phrasing slurs, copied from slur.

14 files changed:
CHANGES
Documentation/regression-test.tely
Documentation/user/refman.itely
VERSION
input/regression/phrasing-slur.ly [new file with mode: 0644]
lily/include/slur-engraver.hh
lily/lexer.ll
lily/parser.yy
lily/phrasing-slur-engraver.cc [new file with mode: 0644]
lily/slur-engraver.cc
ly/engraver.ly
scm/grob-description.scm
scm/interface-description.scm
scm/slur.scm

diff --git a/CHANGES b/CHANGES
index 93f614c23c8ba3d591ead1429962ca15cd3d3c45..88bfa06c0d4ee804d5c9d5d1b5ad80f9685c5564 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+1.3.129.jcn2
+============
+
+* Implemented Phrasing slurs, copied from slur.
+
 1.3.129.jcn1
 ============
 
index d910b1f7c8a49e3c010e89db625bf24ae78879b8..5e995df80b670f6017fade3e9a0b164a6d85c944 100644 (file)
@@ -109,6 +109,8 @@ and documenting bugfixes.
 
 @lilypondfile[printfilename]{ophee-slurs.ly}
 
+@lilypondfile[printfilename]{phrasing-slur.ly}
+
 @lilypondfile[printfilename]{tie.ly}
 
 @lilypondfile[printfilename]{tie-chord.ly}
index dcf971b9c1e36ad90acc136b7f6b3da27da51744..54f4fa6707cf697c68cce8aa093d644ec73d6c05 100644 (file)
@@ -1,3 +1,4 @@
+
 @c Note:
 @c
 @c A menu is needed before every deeper *section nesting of @nodes
@@ -879,12 +880,12 @@ FIXME
 * Span requests::               
 @end menu
 
-Slurs connects chords and try to avoid crossing stems.  A slur is
-started with @code{(} and stopped with @code{)}.  The
-starting @code{(} appears to the right of the first note in
-the slur.  The terminal @code{)} appears to the left of the
-first note in the slur.  This makes it possible to put a note in
-slurs from both sides:
+A slur connects chords and is used to indicate legato.  Slurs avoid
+crossing stems.  A slur is started with @code{(} and stopped with
+@code{)}.  The starting @code{(} appears to the right of the first note
+in the slur.  The terminal @code{)} appears to the left of the last note
+in the slur.  This makes it possible to put a note in slurs from both
+sides:
 
 @lilypond[fragment,verbatim,center]
   f'()g'()a' [a'8 b'(] a'4 g'2 )f'4
@@ -985,6 +986,24 @@ increasing the @code{beautiful} value:
 
 
 
+@c .   {Phrasing slur}
+@node Phrasing slur
+@subsection Phrasing slur
+@cindex phrasing slur
+@cindex phrasing mark
+
+A phrasing slur (or phrasing mark) connects chords and is used to
+indicate a musical sentence.  Phrasing slurs avoid crossing stems.  A
+phrasing slur is started with @code{\(} and stopped with @code{\)}.  The
+starting @code{\(} appears to the right of the first note in the
+phrasing slur.  The terminal @code{\)} appears to the left of the last
+note in the phrasing slur.
+
+@lilypond[fragment,verbatim,center,relative]
+  \time 6/4; c''\((d)e f(e)\)d
+@end lilypond
+
+
 @c .   {Tie}
 @node Tie
 @subsubsection Tie
diff --git a/VERSION b/VERSION
index b23a1bdeb19e1092fb04b8019a5afe6e55c39212..40479530b4678a27a43dbcf77ee9948092708edf 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=3
 PATCH_LEVEL=129
-MY_PATCH_LEVEL=jcn1
+MY_PATCH_LEVEL=jcn2
 
 # use the above to send patches: MY_PATCH_LEVEL is always empty for a
 # released version.
diff --git a/input/regression/phrasing-slur.ly b/input/regression/phrasing-slur.ly
new file mode 100644 (file)
index 0000000..2436f62
--- /dev/null
@@ -0,0 +1,12 @@
+\header {
+texidoc="Slurs play well with phrasing slur.";
+}
+
+\score {
+  \notes\relative c'' {
+    \time 6/4; c\((d)e f(e)\)d
+  }
+  \paper {
+    linewidth = -1.;
+  }
+}
\ No newline at end of file
index 71a84a21bcc373a67cbb0f1c80b0c2313f91515f..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,13 +0,0 @@
-/*
-  slur-engraver.hh -- declare Slur_engraver
-
-  (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-
-#ifndef SLURGRAV_HH
-#define SLURGRAV_HH
-
-
-
-#endif // SLURGRAV_HH
index b4f49e39f501498996b3ba108c440bfd95dfc80a..3381498155f014148accb33f03ed7be43f7f48b3 100644 (file)
@@ -426,6 +426,10 @@ HYPHEN             --
        return E_SMALLER;
     case '!':
        return E_EXCLAMATION;
+    case '(':
+       return E_OPEN;
+    case ')':
+       return E_CLOSE;
     default:
        return E_CHAR;
     }
index a49098a006d6b187a72a41e44383f0edf82fe0c4..99d1a5d529ee86e4e8462108104521f8386b6788 100644 (file)
@@ -202,7 +202,7 @@ yylex (YYSTYPE *s,  void * v_l)
 %token CONTEXT
 
 /* escaped */
-%token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER 
+%token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER E_OPEN E_CLOSE
 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET 
 
 %type <i>      exclamations questions dots
@@ -1395,6 +1395,11 @@ close_request_parens:
                $$ = s;
                s->set_mus_property ("span-type", ly_str02scm( "slur"));
        }
+       | E_OPEN        {
+               Span_req* s= new Span_req;
+               $$ = s;
+               s->set_mus_property ("span-type", ly_str02scm( "phrasing-slur"));
+       }
        | E_SMALLER {
                Span_req*s =new Span_req;
                $$ = s;
@@ -1427,6 +1432,11 @@ open_request_parens:
                $$ = s;
                s->set_mus_property ("span-type", ly_str02scm( "slur"));
        }
+       | E_CLOSE       {
+               Span_req* s= new Span_req;
+               $$ = s;
+               s->set_mus_property ("span-type", ly_str02scm( "phrasing-slur"));
+       }
        ;
 
 gen_text_def:
diff --git a/lily/phrasing-slur-engraver.cc b/lily/phrasing-slur-engraver.cc
new file mode 100644 (file)
index 0000000..8cabec4
--- /dev/null
@@ -0,0 +1,185 @@
+/*
+  phrasing-slur-engraver.cc -- implement Phrasing_slur_engraver
+
+  (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+
+#include "musical-request.hh"
+#include "slur.hh"
+#include "debug.hh"
+#include "note-column.hh"
+#include "translator-group.hh"
+#include "engraver.hh"
+#include "spanner.hh"
+
+class Phrasing_slur_engraver : public Engraver
+{
+  Link_array<Span_req> requests_arr_;
+  Link_array<Span_req> new_phrasing_slur_req_l_arr_;
+  Link_array<Grob> phrasing_slur_l_stack_;
+  Link_array<Grob> end_phrasing_slur_l_arr_;
+  Moment last_start_;
+
+protected:
+  virtual bool try_music (Music*);
+  virtual void acknowledge_grob (Grob_info);
+  virtual void stop_translation_timestep ();
+  virtual void start_translation_timestep ();
+  virtual void finalize ();
+  virtual void create_grobs ();
+
+public:
+  VIRTUAL_COPY_CONS (Translator);
+  Phrasing_slur_engraver ();
+};
+
+Phrasing_slur_engraver::Phrasing_slur_engraver ()
+{
+  last_start_ = Moment (-1);
+}
+
+bool
+Phrasing_slur_engraver::try_music (Music *req_l)
+{
+  if (Span_req *sl = dynamic_cast <Span_req *> (req_l))
+    {
+      String t =  ly_scm2string (sl->get_mus_property ("span-type"));
+      if (t == "abort")
+       {
+         for (int i = 0; i < phrasing_slur_l_stack_.size (); i++)
+           {
+             phrasing_slur_l_stack_[i]->suicide ();
+           }
+         phrasing_slur_l_stack_.clear ();
+         for (int i = 0; i < end_phrasing_slur_l_arr_.size (); i++)
+           {
+             end_phrasing_slur_l_arr_[i]->suicide ();
+           }
+         end_phrasing_slur_l_arr_.clear ();
+         requests_arr_.clear ();
+         new_phrasing_slur_req_l_arr_.clear ();
+       }
+      else if (t == "phrasing-slur")
+       {
+         /*
+           Let's not start more than one phrasing slur per moment.
+          */
+         if (sl->get_span_dir() == START)
+           {
+             if (now_mom () > last_start_)
+               {
+                 new_phrasing_slur_req_l_arr_.push (sl);
+                 last_start_ = now_mom ();
+                 return true;
+               }
+           }
+         else
+           {
+             new_phrasing_slur_req_l_arr_.push (sl);
+             return true;
+           }
+       }
+    }
+  return false;
+}
+
+void
+Phrasing_slur_engraver::acknowledge_grob (Grob_info info)
+{
+  if (Note_column::has_interface (info.elem_l_))
+    {
+      Grob *e =info.elem_l_;
+      for (int i = 0; i < phrasing_slur_l_stack_.size (); i++)
+       Slur::add_column (phrasing_slur_l_stack_[i], e);
+      for (int i = 0; i < end_phrasing_slur_l_arr_.size (); i++)
+       Slur::add_column (end_phrasing_slur_l_arr_[i], e);
+    }
+}
+
+void
+Phrasing_slur_engraver::finalize ()
+{
+  for (int i = 0; i < phrasing_slur_l_stack_.size (); i++)
+    {
+#if 0
+      typeset_grob (phrasing_slur_l_stack_[i]);
+#else
+      /*
+       Let's not typeset unterminated stuff
+       */
+      phrasing_slur_l_stack_[i]->suicide ();
+#endif     
+    }
+  phrasing_slur_l_stack_.clear ();
+  SCM wg = get_property ("weAreGraceContext");
+  bool wgb = to_boolean (wg);
+  if (!wgb)
+    for (int i=0; i < requests_arr_.size (); i++)
+      {
+       requests_arr_[i]->origin ()->warning (_ ("unterminated phrasing slur"));
+      }
+}
+
+void
+Phrasing_slur_engraver::create_grobs ()
+{
+  Link_array<Grob> start_phrasing_slur_l_arr;
+  for (int i=0; i< new_phrasing_slur_req_l_arr_.size (); i++)
+    {
+      Span_req* phrasing_slur_req_l = new_phrasing_slur_req_l_arr_[i];
+      // end phrasing slur: move the phrasing slur to other array
+      if (phrasing_slur_req_l->get_span_dir() == STOP)
+       {
+         if (phrasing_slur_l_stack_.empty ())
+           phrasing_slur_req_l->origin ()->warning (_f ("can't find start of phrasing slur"));
+         else
+           {
+             Grob* phrasing_slur = phrasing_slur_l_stack_.pop ();
+             SCM s = get_property ("phrasingSlurEndAttachment");
+             if (gh_symbol_p (s))
+               {
+                 index_set_cell (phrasing_slur->get_grob_property ("attachment"), STOP, s);
+               }
+             end_phrasing_slur_l_arr_.push (phrasing_slur);
+             requests_arr_.pop ();
+           }
+       }
+      else  if (phrasing_slur_req_l->get_span_dir() == START)
+       {
+         // push a new phrasing_slur onto stack.
+         // (use temp. array to wait for all phrasing_slur STOPs)
+         Grob* phrasing_slur = new Spanner (get_property ("PhrasingSlur"));
+         Slur::set_interface (phrasing_slur);
+         SCM s = get_property ("phrasingSlurBeginAttachment");
+         if (gh_symbol_p (s))
+           {
+             index_set_cell (phrasing_slur->get_grob_property ("attachment"), START, s);
+           }
+         start_phrasing_slur_l_arr.push (phrasing_slur);
+         requests_arr_.push (phrasing_slur_req_l);
+         announce_grob (phrasing_slur, phrasing_slur_req_l);
+       }
+    }
+  for (int i=0; i < start_phrasing_slur_l_arr.size (); i++)
+    phrasing_slur_l_stack_.push (start_phrasing_slur_l_arr[i]);
+  new_phrasing_slur_req_l_arr_.clear ();
+}
+
+void
+Phrasing_slur_engraver::stop_translation_timestep ()
+{
+  for (int i = 0; i < end_phrasing_slur_l_arr_.size (); i++)
+    {
+      typeset_grob (end_phrasing_slur_l_arr_[i]);
+    }
+  end_phrasing_slur_l_arr_.clear ();
+}
+
+void
+Phrasing_slur_engraver::start_translation_timestep ()
+{
+  new_phrasing_slur_req_l_arr_.clear ();
+}
+
+
+ADD_THIS_TRANSLATOR (Phrasing_slur_engraver);
index 0ac37d0d097d449fab71070aafe87fac384b99db..0692526657388f9dab8047832e767800fd1df28b 100644 (file)
@@ -1,11 +1,10 @@
 /*
-  slur-grav.cc -- implement Slur_engraver
+  slur-engraver.cc -- implement Slur_engraver
 
   (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #include "musical-request.hh"
-#include "slur-engraver.hh"
 #include "slur.hh"
 #include "debug.hh"
 #include "note-column.hh"
index a54fe7ba84b8a1864fcc63ca4d0b5141b474ef04..ae5d56fde4f3228f9f72dabfd50ae919bb9eaf4b 100644 (file)
@@ -121,6 +121,7 @@ VoiceContext = \translator {
        \consists "Script_engraver";
        \consists "Script_column_engraver";
        \consists "Rhythmic_column_engraver";
+       \consists "Phrasing_slur_engraver";
        \consists "Slur_engraver";
        \consists "Tie_engraver";
        \consists "Tuplet_engraver";
index df810a004842e80041588d9c184598205f2cdf70..59e9a54db2476590154481f4e4e479c696c74c62 100644 (file)
                 (before-musical-spacing-factor . 0.4)
                (meta . ,(grob-description "PaperColumn" paper-column-interface axis-group-interface spaceable-element-interface))
        ))
+       (PhrasingSlur . (
+                (molecule-callback . ,Slur::brew_molecule)
+                (thickness . 1.2)              
+                (spacing-procedure . ,Slur::set_spacing_rods)          
+                (minimum-length . 1.5)
+                (after-line-breaking-callback . ,Slur::after_line_breaking)
+                (extremity-rules . ,default-slur-extremity-rules)
+                (extremity-offset-alist . ,default-phrasing-slur-extremity-offset-alist)
+                (de-uglify-parameters . ( 1.5  0.8  -2.0))
+                (Y-extent-callback . ,Slur::height)
+                (details . ((height-limit . 2.0) (ratio . 0.333) (force-blowfit . 0.5)
+                            (bezier-pct-c0 . -0.2) (bezier-pct-c3 . 0.000006)
+                            (bezier-pct-out-max . 0.8) (bezier-pct-in-max . 1.2)
+                            (bezier-area-steps . 1.0)))
+                (beautiful . 0.5)
+                (y-free . 0.75)
+                (attachment . (#f . #f))
+                (attachment-offset . ((0 . 0) . (0 . 0)))
+                (slope-limit . 0.8)
+                (meta . ,(grob-description "PhrasingSlur" slur-interface))
+                ))
        (NonMusicalPaperColumn . (
                 (axes 0)
                 (before-musical-spacing-factor . 1.0)
index 60f0a19779dd09aef08e0f041f48a4a23dc6fb76..f17a9f9e5a9acce50d0139cda5a59e9e948fee4e 100644 (file)
@@ -71,7 +71,7 @@
   "
    '(
      staff-position
-    height 
+    height
     flag-width-function 
     damping 
     default-neutral-direction 
@@ -83,6 +83,7 @@
     damping 
     outer-stem-length-limit 
     slope-limit 
+    auto-knee-gap
     )
    ))
 
index 81cf5050ec0f99229fa35b0b9cda8520bff7b840..b188a2a517fd0c995d6e47a592e23e46fb0adf0b 100644 (file)
     ((loose-end -1 1) . (-4 . 0))
     ))
 
+;; This is a bit of a hack: slurs and phrasing slurs
+;; attaching at the same note must not collide.
+;; However, slurs (and phrasing slurs) should look
+;; at scripts and eachother.
+(define default-phrasing-slur-extremity-offset-alist
+  '(
+    ((head 1 1) . (-0.25 . 1.25))
+    ((head 1 -1) . (-0.25 . -1.25))
+    ((head -1 1) . (-0.25 . 1.25))
+    ((head -1 -1) . (-0.85 . -1.25))
+
+    ((stem 1 1) . (0 . 1.5))
+    ((stem -1 -1) . (0 . -1.5))
+
+    ((loose-end 1 1) . (-0.4 . 0))
+    ((loose-end 1 -1) . (-0.4 . 0))
+    ((loose-end -1 -1) . (-4 . 0))
+    ((loose-end -1 1) . (-4 . 0))
+    ))
+