From fb807693067f854df3b2bd1f28456fe8955a7330 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Mon, 26 Jun 2000 21:51:43 +0200 Subject: [PATCH] patch::: 1.3.64.jcn2 1.3.64.jcn2 ============ * Made slur attachment position user settable; properties: slurBeginAttachment slurEndAttachment, values: 'head 'stem 'along-side-stem. See input/test/slur-attachment.ly and ophee-slurs.ly. * Fixed slur attachment positions, added missing rule and use simple default starting positions for attachments. --- CHANGES | 11 ++++++ VERSION | 2 +- input/test/beamed-slur-endings.ly | 24 ++++++++++++ input/test/ophee-slurs.ly | 12 ++++++ input/test/simple-slur-endings.ly | 13 +++++++ input/test/slur-attachment.ly | 17 +++++++++ lily/slur-engraver.cc | 62 ++++++++++++++++++------------- lily/slur.cc | 54 ++++++++++++++++++--------- scm/slur.scm | 54 +++++++++++++++------------ 9 files changed, 181 insertions(+), 68 deletions(-) create mode 100644 input/test/beamed-slur-endings.ly create mode 100644 input/test/ophee-slurs.ly create mode 100644 input/test/simple-slur-endings.ly create mode 100644 input/test/slur-attachment.ly diff --git a/CHANGES b/CHANGES index 0d289e95fa..5247911f00 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,14 @@ +1.3.64.jcn2 +============ + +* Made slur attachment position user settable; properties: +slurBeginAttachment slurEndAttachment, values: 'head 'stem +'along-side-stem. See input/test/slur-attachment.ly and ophee-slurs.ly. + +* Fixed slur attachment positions, added missing rule and use simple +default starting positions for attachments. + + 1.3.63.jcn1 ============ diff --git a/VERSION b/VERSION index 914fac1745..da5de0f781 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=3 PATCH_LEVEL=64 -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/test/beamed-slur-endings.ly b/input/test/beamed-slur-endings.ly new file mode 100644 index 0000000000..df91eec6a4 --- /dev/null +++ b/input/test/beamed-slur-endings.ly @@ -0,0 +1,24 @@ +\score{ + \notes \relative c''{ + \property Voice.slurVerticalDirection = #1 c8(()c())c4 + \property Voice.slurVerticalDirection = #-1 a8(()a)a4 + \break + + \property Voice.slurVerticalDirection = #-1 a8(()a())a4 + \property Voice.slurVerticalDirection = #1 c8(()c)c4 + \break + + \property Voice.slurVerticalDirection = #-1 e8(()e())e4 + \property Voice.slurVerticalDirection = #1 f,8(()f)f4 + \break + + \property Voice.slurVerticalDirection = #1 e8(()e())e4 + \property Voice.slurVerticalDirection = #-1 f'8(()f)f4 + \break + + } + \paper{ + indent = 0.0; + linewidth = 60.0\mm; + } +} diff --git a/input/test/ophee-slurs.ly b/input/test/ophee-slurs.ly new file mode 100644 index 0000000000..402aba2322 --- /dev/null +++ b/input/test/ophee-slurs.ly @@ -0,0 +1,12 @@ +\score{ + \notes \relative c''{ + \property Voice.slurVerticalDirection = #1 + \property Voice.slurBeginAttachment = #'head + \property Voice.slurEndAttachment = #'head + g16()g()g()g()d'()d()d()d + } + \paper{ + indent = 0.0; + linewidth = 60.0\mm; + } +} diff --git a/input/test/simple-slur-endings.ly b/input/test/simple-slur-endings.ly new file mode 100644 index 0000000000..03e482615b --- /dev/null +++ b/input/test/simple-slur-endings.ly @@ -0,0 +1,13 @@ +\score{ + \notes \relative c''{ + \property Voice.slurVerticalDirection = #1 c()a d()g,\break + \property Voice.slurVerticalDirection = #-1 c()a d()g,\break + \property Voice.slurVerticalDirection = #1 a()c d()g,\break + \property Voice.slurVerticalDirection = #-1 a()c d()g,\break + \property Voice.slurVerticalDirection = #-1 a()c d()g,\break + } + \paper{ + indent = 0.0; + linewidth = 60.0\mm; + } +} diff --git a/input/test/slur-attachment.ly b/input/test/slur-attachment.ly new file mode 100644 index 0000000000..4f7e8d4991 --- /dev/null +++ b/input/test/slur-attachment.ly @@ -0,0 +1,17 @@ +\score{ + \notes \relative c''{ + % URG, make stem length match beam! + \property Voice.stemLength = #5 + + \property Voice.slurVerticalDirection = #1 + \property Voice.slurEndAttachment = #'stem + a8(a)a4 + \property Voice.slurEndAttachment = ##f + \property Voice.slurBeginAttachment = #'stem + a4(a8)a + } + \paper{ + indent = 0.0; + linewidth = 60.0\mm; + } +} diff --git a/lily/slur-engraver.cc b/lily/slur-engraver.cc index ccb3a9a360..7987187335 100644 --- a/lily/slur-engraver.cc +++ b/lily/slur-engraver.cc @@ -22,14 +22,14 @@ class Slur_engraver :public Engraver { void set_melisma (bool); protected: virtual bool do_try_music (Music*); - virtual void do_process_music(); + virtual void do_process_music (); virtual void acknowledge_element (Score_element_info); - virtual void do_pre_move_processing(); - virtual void do_post_move_processing(); + virtual void do_pre_move_processing (); + virtual void do_post_move_processing (); virtual void do_removal_processing (); public: - VIRTUAL_COPY_CONS(Translator); + VIRTUAL_COPY_CONS (Translator); }; @@ -59,9 +59,9 @@ Slur_engraver::acknowledge_element (Score_element_info info) if (dynamic_cast (info.elem_l_)) { Note_column *col_l =dynamic_cast (info.elem_l_) ;// ugh - for (int i = 0; i < slur_l_stack_.size(); i++) + for (int i = 0; i < slur_l_stack_.size (); i++) slur_l_stack_[i]->add_column (col_l); - for (int i = 0; i < end_slur_l_arr_.size(); i++) + for (int i = 0; i < end_slur_l_arr_.size (); i++) end_slur_l_arr_[i]->add_column (col_l); } } @@ -69,7 +69,7 @@ Slur_engraver::acknowledge_element (Score_element_info info) void Slur_engraver::do_removal_processing () { - for (int i = 0; i < slur_l_stack_.size(); i++) + for (int i = 0; i < slur_l_stack_.size (); i++) { typeset_element (slur_l_stack_[i]); } @@ -77,60 +77,70 @@ Slur_engraver::do_removal_processing () SCM wg = get_property ("weAreGraceContext"); bool wgb = to_boolean (wg); if (!wgb) - for (int i=0; i < requests_arr_.size(); i++) + for (int i=0; i < requests_arr_.size (); i++) { requests_arr_[i]->warning (_ ("unterminated slur")); } } void -Slur_engraver::do_process_music() +Slur_engraver::do_process_music () { Array start_slur_l_arr_; - for (int i=0; i< new_slur_req_l_arr_.size(); i++) + for (int i=0; i< new_slur_req_l_arr_.size (); i++) { Span_req* slur_req_l = new_slur_req_l_arr_[i]; // end slur: move the slur to other array if (slur_req_l->span_dir_ == STOP) { - if (slur_l_stack_.empty()) + if (slur_l_stack_.empty ()) - slur_req_l->warning (_f ("can't find both ends of %s", _("slur"))); + slur_req_l->warning (_f ("can't find both ends of %s", _ ("slur"))); else { - end_slur_l_arr_.push (slur_l_stack_.pop()); - requests_arr_.pop(); + Slur* slur = slur_l_stack_.pop (); + SCM s = get_property ("slurEndAttachment"); + if (gh_symbol_p (s)) + { + index_set_cell (slur->get_elt_property ("attachment"), STOP, s); + } + end_slur_l_arr_.push (slur); + requests_arr_.pop (); } } else if (slur_req_l->span_dir_ == START) { // push a new slur onto stack. - //(use temp. array to wait for all slur STOPs) - Slur * s_p =new Slur (get_property ("basicSlurProperties")); - + // (use temp. array to wait for all slur STOPs) + Slur* slur = new Slur (get_property ("basicSlurProperties")); + SCM s = get_property ("slurBeginAttachment"); + if (gh_symbol_p (s)) + { + index_set_cell (slur->get_elt_property ("attachment"), START, s); + } + start_slur_l_arr_.push (slur); requests_arr_.push (slur_req_l); - start_slur_l_arr_.push (s_p); - announce_element (Score_element_info (s_p, slur_req_l)); + announce_element (Score_element_info (slur, slur_req_l)); } } - for (int i=0; i < start_slur_l_arr_.size(); i++) + for (int i=0; i < start_slur_l_arr_.size (); i++) slur_l_stack_.push (start_slur_l_arr_[i]); } void -Slur_engraver::do_pre_move_processing() +Slur_engraver::do_pre_move_processing () { - for (int i = 0; i < end_slur_l_arr_.size(); i++) + for (int i = 0; i < end_slur_l_arr_.size (); i++) { typeset_element (end_slur_l_arr_[i]); } - end_slur_l_arr_.clear(); + end_slur_l_arr_.clear (); } void -Slur_engraver::do_post_move_processing() +Slur_engraver::do_post_move_processing () { - new_slur_req_l_arr_.clear(); + new_slur_req_l_arr_.clear (); SCM m = get_property ("automaticMelismata"); if (to_boolean (m)) { @@ -139,4 +149,4 @@ Slur_engraver::do_post_move_processing() } -ADD_THIS_TRANSLATOR(Slur_engraver); +ADD_THIS_TRANSLATOR (Slur_engraver); diff --git a/lily/slur.cc b/lily/slur.cc index aaed8b51a1..3ca85469ce 100644 --- a/lily/slur.cc +++ b/lily/slur.cc @@ -11,6 +11,7 @@ [TODO] * begin and end should be treated as a/acknowledge Scripts. * broken slur should have uniform trend + * smart changing of endings and offsets to avoid ugly beziers. */ #include "directional-element-interface.hh" @@ -32,11 +33,7 @@ Slur::Slur (SCM s) : Spanner (s) { - /* - silly value for testing - */ - set_elt_property ("attachment", gh_cons (ly_symbol2scm ("alongside-stem"), - ly_symbol2scm ("alongside-stem"))); + set_elt_property ("attachment", gh_cons (SCM_BOOL_F, SCM_BOOL_F)); set_elt_pointer ("note-columns", SCM_EOL); set_elt_property ("control-points", SCM_EOL); } @@ -210,19 +207,23 @@ Slur::set_extremities () Direction dir = LEFT; do { - // for (SCM s = get_elt_property ("slur-extremity-rules"); s != SCM_EOL; s = gh_cdr (s)) - for (SCM s = scm_eval (ly_symbol2scm ("slur-extremity-rules")); - s != SCM_EOL; s = gh_cdr (s)) + if (!gh_symbol_p (index_cell (get_elt_property ("attachment"), dir))) { - SCM r = scm_eval (scm_listify (gh_caar (s), - this->self_scm_, - gh_int2scm ((int)dir), - SCM_UNDEFINED)); - if (r != SCM_BOOL_F) + + // for (SCM s = get_elt_property ("slur-extremity-rules"); s != SCM_EOL; s = gh_cdr (s)) + for (SCM s = scm_eval (ly_symbol2scm ("slur-extremity-rules")); + s != SCM_EOL; s = gh_cdr (s)) { - index_set_cell (get_elt_property ("attachment"), dir, - gh_cdar (s)); - break; + SCM r = scm_eval (scm_listify (gh_caar (s), + this->self_scm_, + gh_int2scm ((int)dir), + SCM_UNDEFINED)); + if (r != SCM_BOOL_F) + { + index_set_cell (get_elt_property ("attachment"), dir, + gh_cdar (s)); + break; + } } } } @@ -245,14 +246,33 @@ Slur::get_attachment (Direction dir) const if (str == "head") { o = Offset (0, st->chord_start_f ()); + /* + Default position is centered in X, on outer side of head Y + */ + o += Offset (0.5 * n->extent (X_AXIS).length (), + 0.5 * ss * directional_element (this).get ()); } else if (str == "alongside-stem") { o = Offset (0, st->chord_start_f ()); + /* + Default position is on stem X, on outer side of head Y + */ + o += Offset (n->extent (X_AXIS).length () + * (1 + st->get_direction ()), + 0.5 * ss * directional_element (this).get ()); } else if (str == "stem") { o = Offset (0, st->stem_end_position () * hs); + /* + Default position is on stem X, at stem end Y + */ + o += Offset (0.5 * + (n->extent (X_AXIS).length () + - st->extent (X_AXIS).length ()) + * (1 + st->get_direction ()), + 0); } else if (str == "loose-end") { @@ -263,8 +283,6 @@ Slur::get_attachment (Direction dir) const } } - o += Offset (0.5 * st->get_direction () - * n->extent (X_AXIS).length (), 0); SCM l = scm_assoc (scm_listify (a, diff --git a/scm/slur.scm b/scm/slur.scm index ce6f4be123..13a756b3b9 100644 --- a/scm/slur.scm +++ b/scm/slur.scm @@ -20,43 +20,51 @@ (define slur-extremity-rules '( - ;;if (stem_l->beam_l () && (stem_l->beam_count (-d) >= 1)) ((lambda (slur dir) ;; urg, code dup - ;; if attached-to-stem (let* ((note-columns (get-pointer slur 'note-columns)) (col (if (= dir 1) (car note-columns) (car (reverse note-columns)))) (stem (get-pointer col 'stem))) - (and - (and - (eq? col (get-bound slur dir)) - stem - (get-pointer stem 'heads)) - ;; and got beam - (and (get-pointer stem 'beam) - ;; and beam on same side as slur - (let ((beaming (get-property stem 'beaming))) - (if (pair? beaming) - (>= 1 - (if (= dir -1) (car beaming) (cdr beaming))) - #f)))))) . stem) + (and stem + (not (= (get-property slur 'direction) + (get-property stem 'direction)))))) . head) + + ((lambda (slur dir) + ;; if attached-to-stem + (and (attached-to-stem slur dir) + ;; and got beam + ;; urg, code dup + (let* ((note-columns (get-pointer slur 'note-columns)) + (col (if (= dir 1) (car note-columns) (car (reverse note-columns)))) + (stem (get-pointer col 'stem))) + (and stem + (get-pointer stem 'beam) + ;; and beam on same side as slur + (let ((beaming (get-property stem 'beaming))) + (if (pair? beaming) + (>= 1 + (if (= dir -1) (car beaming) (cdr beaming))) + #f)))))) . stem) + ((lambda (slur dir) (not (attached-to-stem slur dir))) . loose-end) + ;; default case, attach to head ((lambda (x y) #t) . head) - ;; silly rule, just to check - ((lambda (slur dir) + ;; silly rule, just to check + ((lambda (slur dir) (and (attached-to-stem slur dir) (= (get-property slur 'direction) dir))) . stem) - )) + )) (define slur-extremity-offset-alist '( ((head 1 1) . (-0.25 . 0.2)) - ((head 1 -1) . (-0.25 . -0.75)) - ((head -1 1) . (-0.25 . 0.75)) - ((head -1 -1) . (-0.75 . 1.2)) - ((stem 1 1) . (0 . 0.2)) - ((stem -1 -1) . (0 . 0.2)) + ((head 1 -1) . (-0.25 . -0.25)) + ((head -1 1) . (-0.25 . 0.25)) + ((head -1 -1) . (-0.85 . -0.2)) + + ((stem 1 1) . (0 . 0.5)) + ((stem -1 -1) . (0 . -0.5)) )) -- 2.39.5