From: Jan Nieuwenhuizen Date: Tue, 20 Feb 2001 15:57:26 +0000 (+0100) Subject: patch::: 1.3.129.jcn2 X-Git-Tag: release/1.3.130~2 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=6d2a5deed2f5299232641efc67f8806683278aec;p=lilypond.git patch::: 1.3.129.jcn2 1.3.129.jcn2 ============ * Implemented Phrasing slurs, copied from slur. --- diff --git a/CHANGES b/CHANGES index 93f614c23c..88bfa06c0d 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +1.3.129.jcn2 +============ + +* Implemented Phrasing slurs, copied from slur. + 1.3.129.jcn1 ============ diff --git a/Documentation/regression-test.tely b/Documentation/regression-test.tely index d910b1f7c8..5e995df80b 100644 --- a/Documentation/regression-test.tely +++ b/Documentation/regression-test.tely @@ -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/Documentation/user/refman.itely b/Documentation/user/refman.itely index dcf971b9c1..54f4fa6707 100644 --- a/Documentation/user/refman.itely +++ b/Documentation/user/refman.itely @@ -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 b23a1bdeb1..40479530b4 100644 --- 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 index 0000000000..2436f62409 --- /dev/null +++ b/input/regression/phrasing-slur.ly @@ -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 diff --git a/lily/include/slur-engraver.hh b/lily/include/slur-engraver.hh index 71a84a21bc..e69de29bb2 100644 --- a/lily/include/slur-engraver.hh +++ b/lily/include/slur-engraver.hh @@ -1,13 +0,0 @@ -/* - slur-engraver.hh -- declare Slur_engraver - - (c) 1997--2000 Han-Wen Nienhuys -*/ - - -#ifndef SLURGRAV_HH -#define SLURGRAV_HH - - - -#endif // SLURGRAV_HH diff --git a/lily/lexer.ll b/lily/lexer.ll index b4f49e39f5..3381498155 100644 --- a/lily/lexer.ll +++ b/lily/lexer.ll @@ -426,6 +426,10 @@ HYPHEN -- return E_SMALLER; case '!': return E_EXCLAMATION; + case '(': + return E_OPEN; + case ')': + return E_CLOSE; default: return E_CHAR; } diff --git a/lily/parser.yy b/lily/parser.yy index a49098a006..99d1a5d529 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -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 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 index 0000000000..8cabec4803 --- /dev/null +++ b/lily/phrasing-slur-engraver.cc @@ -0,0 +1,185 @@ +/* + phrasing-slur-engraver.cc -- implement Phrasing_slur_engraver + + (c) 1997--2000 Han-Wen Nienhuys +*/ + +#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 requests_arr_; + Link_array new_phrasing_slur_req_l_arr_; + Link_array phrasing_slur_l_stack_; + Link_array 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 (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 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); diff --git a/lily/slur-engraver.cc b/lily/slur-engraver.cc index 0ac37d0d09..0692526657 100644 --- a/lily/slur-engraver.cc +++ b/lily/slur-engraver.cc @@ -1,11 +1,10 @@ /* - slur-grav.cc -- implement Slur_engraver + slur-engraver.cc -- implement Slur_engraver (c) 1997--2000 Han-Wen Nienhuys */ #include "musical-request.hh" -#include "slur-engraver.hh" #include "slur.hh" #include "debug.hh" #include "note-column.hh" diff --git a/ly/engraver.ly b/ly/engraver.ly index a54fe7ba84..ae5d56fde4 100644 --- a/ly/engraver.ly +++ b/ly/engraver.ly @@ -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"; diff --git a/scm/grob-description.scm b/scm/grob-description.scm index df810a0048..59e9a54db2 100644 --- a/scm/grob-description.scm +++ b/scm/grob-description.scm @@ -370,6 +370,27 @@ (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) diff --git a/scm/interface-description.scm b/scm/interface-description.scm index 60f0a19779..f17a9f9e5a 100644 --- a/scm/interface-description.scm +++ b/scm/interface-description.scm @@ -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 ) )) diff --git a/scm/slur.scm b/scm/slur.scm index 81cf5050ec..b188a2a517 100644 --- a/scm/slur.scm +++ b/scm/slur.scm @@ -107,4 +107,24 @@ ((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)) + )) +