]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.3.130
authorfred <fred>
Wed, 27 Mar 2002 00:49:08 +0000 (00:49 +0000)
committerfred <fred>
Wed, 27 Mar 2002 00:49:08 +0000 (00:49 +0000)
Documentation/regression-test.tely
input/regression/phrasing-slur.ly [new file with mode: 0644]
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

index d910b1f7c8a49e3c010e89db625bf24ae78879b8..fc18c140bd3f7c6b1140102bfa20b046e87a3dd8 100644 (file)
@@ -51,7 +51,7 @@ and documenting bugfixes.
 
 @lilypondfile[printfilename]{staccato-pos.ly}
 
-@lilypondfile[printfilename]{dyn-line.ly}
+@lilypondfile[printfilename]{dynamics-line.ly}
 
 @lilypondfile[printfilename]{arpeggio.ly}
 
@@ -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}
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 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..ccfb55813ed1fdb905702ed5fdac1857fc79b8e8 100644 (file)
@@ -1,6 +1,6 @@
+\version "1.3.122"
 
-\version "1.3.110"
-       %
+%
 % setup for Request->Element conversion. Guru-only
 %
 
@@ -33,8 +33,6 @@ StaffContext=\translator {
        \consists "Local_key_engraver";
        \consists "Piano_pedal_engraver";
 
-       \consistsend "Axis_group_engraver";
-
 %{
        The Instrument_name_engraver puts the name of the instrument
        (\property Staff.instrument; Staff.instr for subsequent lines)
@@ -45,11 +43,20 @@ StaffContext=\translator {
        \consists "Instrument_name_engraver";
 %}
 
+       \consistsend "Axis_group_engraver";
 
          
        \accepts "Voice";
 }
 
+
+StaffContainerContext = \translator {
+       \type Engraver_group_engraver;
+       \consists "Axis_group_engraver";
+       \accepts Staff;
+       \name StaffContainer;
+}
+
 ChoirStaffContext = \translator {
        \type "Engraver_group_engraver";
        \name ChoirStaff;
@@ -101,7 +108,6 @@ VoiceContext = \translator {
        \consists "Output_property_engraver";   
        \consists "Arpeggio_engraver";
 
-       \consists "Dynamic_engraver";   % must come before text_engraver.
        \consists "Text_spanner_engraver";
        \consists "Property_engraver";
        
@@ -114,17 +120,25 @@ VoiceContext = \translator {
 
        \consists "Chord_tremolo_engraver";
        \consists "Melisma_engraver";
+
+%{
+ Must come before text_engraver, but after note_column engraver.
+
+%}
+       \consists "Dynamic_engraver";
        \consists "Text_engraver";
-       \consists "A2_engraver";
-       \consists "Voice_devnull_engraver";
 
        \consists "Script_engraver";
        \consists "Script_column_engraver";
        \consists "Rhythmic_column_engraver";
+       \consists "Phrasing_slur_engraver";
        \consists "Slur_engraver";
        \consists "Tie_engraver";
        \consists "Tuplet_engraver";
        \consists "Grace_position_engraver";
+       \consists "A2_engraver";
+       \consists "Voice_devnull_engraver";
+
        \consists "Skip_req_swallow_translator";
        \accepts Thread; % bug if you leave out this!
        \accepts Grace;
@@ -338,8 +352,8 @@ ScoreContext = \translator {
        \consists "Bar_number_engraver";
        \consists "Span_arpeggio_engraver";
 
-       
-       \accepts "Staff";
+       \accepts "Staff";       
+       \accepts "StaffContainer";
        \accepts "StaffGroup";
        \accepts "RhythmicStaff";       
        \accepts "Lyrics";
index df810a004842e80041588d9c184598205f2cdf70..b1ecfc0a2a1696700b039a59623dc065e229b3f1 100644 (file)
@@ -49,7 +49,9 @@
                (direction . 1)
                 (font-family . roman)
                (font-relative-size . -1)
+               (Y-offset-callbacks . (,Side_position::aligned_side))
                (meta . ,(grob-description "BarNumber"
+                                          side-position-interface
                        text-interface  font-interface break-aligned-interface))
        ))
 
                 (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..7d5ee12eaaedd8d5b5039f14ad8c68faf5bf1990 100644 (file)
@@ -69,9 +69,9 @@
 
 #'thickness= weight of beams, in staffspace
   "
-   '(
+   '(auto-knee-gap
      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))
+    ))
+