From 55925e0d09fd9f518d6b8a416d9fb70a350d47ff Mon Sep 17 00:00:00 2001 From: fred Date: Wed, 27 Mar 2002 00:49:08 +0000 Subject: [PATCH] lilypond-1.3.130 --- Documentation/regression-test.tely | 4 +- input/regression/phrasing-slur.ly | 12 ++ lily/lexer.ll | 4 + lily/parser.yy | 12 +- lily/phrasing-slur-engraver.cc | 185 +++++++++++++++++++++++++++++ lily/slur-engraver.cc | 3 +- ly/engraver.ly | 32 +++-- scm/grob-description.scm | 23 ++++ scm/interface-description.scm | 5 +- scm/slur.scm | 20 ++++ 10 files changed, 285 insertions(+), 15 deletions(-) create mode 100644 input/regression/phrasing-slur.ly create mode 100644 lily/phrasing-slur-engraver.cc diff --git a/Documentation/regression-test.tely b/Documentation/regression-test.tely index d910b1f7c8..fc18c140bd 100644 --- a/Documentation/regression-test.tely +++ b/Documentation/regression-test.tely @@ -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 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/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..ccfb55813e 100644 --- a/ly/engraver.ly +++ b/ly/engraver.ly @@ -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"; diff --git a/scm/grob-description.scm b/scm/grob-description.scm index df810a0048..b1ecfc0a2a 100644 --- a/scm/grob-description.scm +++ b/scm/grob-description.scm @@ -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)) )) @@ -370,6 +372,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..7d5ee12eaa 100644 --- a/scm/interface-description.scm +++ b/scm/interface-description.scm @@ -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 ) )) 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)) + )) + -- 2.39.5