From: Han-Wen Nienhuys Date: Sun, 6 Oct 2002 12:53:20 +0000 (+0000) Subject: * lily/dynamic-engraver.cc (process_music): take dynamic direction X-Git-Tag: release/1.7.2~2 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=09213819f91a17bb6e4f391c589550d440916410;p=lilypond.git * lily/dynamic-engraver.cc (process_music): take dynamic direction from ^_ for crescendi. Idem for slurs and phrasing slurs. * ly/grace-init.ly: add-to-grace-init: function to portably add settings to \grace. * lily/dynamic-engraver.cc (process_music): finish (de)crescendo if we get an absolute dynamic event. * lily/time-signature-engraver.cc (process_music): warn for \time 5/5 * lily/source-file.cc (get_line): oops. All line numbers were off by 2. Fix that. --- diff --git a/ChangeLog b/ChangeLog index aacd97572c..13b7cfdc74 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2002-10-06 Han-Wen Nienhuys + * lily/dynamic-engraver.cc (process_music): take dynamic direction + from ^_ for crescendi. Idem for slurs and phrasing slurs. + + * ly/grace-init.ly: add-to-grace-init: function to portably add + settings to \grace. + + * lily/dynamic-engraver.cc (process_music): finish (de)crescendo + if we get an absolute dynamic event. + + * lily/time-signature-engraver.cc (process_music): warn for \time 5/5 + * lily/source-file.cc (get_line): oops. All line numbers were off by 2. Fix that. diff --git a/lily/duration.cc b/lily/duration.cc index 2ad688ec5f..436f659df4 100644 --- a/lily/duration.cc +++ b/lily/duration.cc @@ -203,8 +203,7 @@ Extract the dot count from @var{dur}" LY_DEFINE(ly_intlog2, "intlog2", 1, 0, 0, (SCM d), - " -Extract the dot count from @var{dur}" + "The 2-logarithm of 1/@var{d}." ) { SCM_ASSERT_TYPE(gh_number_p (d), d, SCM_ARG1, __FUNCTION__, "integer"); diff --git a/lily/dynamic-engraver.cc b/lily/dynamic-engraver.cc index 660efc4921..61ba3b5141 100644 --- a/lily/dynamic-engraver.cc +++ b/lily/dynamic-engraver.cc @@ -43,9 +43,9 @@ class Dynamic_engraver : public Engraver Spanner * finished_cresc_; Spanner * cresc_; - Music* script_req_; + Music* script_ev_; - Music * current_cresc_req_; + Music * current_cresc_ev_; Drul_array accepted_spanreqs_drul_; Spanner* line_spanner_; @@ -76,10 +76,10 @@ Dynamic_engraver::Dynamic_engraver () finished_cresc_ = 0; line_spanner_ = 0; finished_line_spanner_ = 0; - current_cresc_req_ = 0; + current_cresc_ev_ = 0; cresc_ =0; - script_req_ = 0; + script_ev_ = 0; accepted_spanreqs_drul_[START] = 0; accepted_spanreqs_drul_[STOP] = 0; } @@ -87,7 +87,7 @@ Dynamic_engraver::Dynamic_engraver () void Dynamic_engraver::start_translation_timestep () { - script_req_ = 0; + script_ev_ = 0; accepted_spanreqs_drul_[START] = 0; accepted_spanreqs_drul_[STOP] = 0; } @@ -100,7 +100,7 @@ Dynamic_engraver::try_music (Music * m) /* TODO: probably broken. */ - script_req_ = m; + script_ev_ = m; return true; } else if (m->is_mus_type ("abort-event")) @@ -131,15 +131,15 @@ Dynamic_engraver::try_music (Music * m) void Dynamic_engraver::process_music () { - if (accepted_spanreqs_drul_[START] || accepted_spanreqs_drul_[STOP] || script_req_) + if (accepted_spanreqs_drul_[START] || accepted_spanreqs_drul_[STOP] || script_ev_) { if (!line_spanner_) { line_spanner_ = new Spanner (get_property ("DynamicLineSpanner")); Music * rq = accepted_spanreqs_drul_[START]; - if (script_req_) - rq = script_req_ ; + if (script_ev_) + rq = script_ev_ ; announce_grob(line_spanner_, rq ? rq->self_scm(): SCM_EOL); } } @@ -159,35 +159,33 @@ Dynamic_engraver::process_music () maybe we should leave dynamic texts to the text-engraver and simply acknowledge them? */ - if (script_req_) + if (script_ev_) { script_ = new Item (get_property ("DynamicText")); script_->set_grob_property ("text", - script_req_->get_mus_property ("text")); + script_ev_->get_mus_property ("text")); - if (Direction d = to_dir (script_req_->get_mus_property ("direction"))) + if (Direction d = to_dir (script_ev_->get_mus_property ("direction"))) Directional_element_interface::set (line_spanner_, d); Axis_group_interface::add_element (line_spanner_, script_); - announce_grob(script_, script_req_->self_scm()); + announce_grob(script_, script_ev_->self_scm()); } - if (accepted_spanreqs_drul_[STOP]) + Music *stop_ev = accepted_spanreqs_drul_ [STOP] ? + accepted_spanreqs_drul_[STOP] : script_ev_; + + if (accepted_spanreqs_drul_[STOP] || script_ev_) { /* finish side position alignment if the (de)cresc ends here, and there are no new dynamics. */ - - if (!cresc_) - { - accepted_spanreqs_drul_[STOP]->origin ()->warning - (_ ("can't find start of (de)crescendo")); - accepted_spanreqs_drul_[STOP] = 0; - } - else + + + if (cresc_) { assert (!finished_cresc_ && cresc_); @@ -199,32 +197,41 @@ Dynamic_engraver::process_music () finished_cresc_ = cresc_; cresc_ = 0; - current_cresc_req_ = 0; + current_cresc_ev_ = 0; } + else if (accepted_spanreqs_drul_[STOP] ) + { + accepted_spanreqs_drul_[STOP]->origin ()->warning(_ ("can't find start of (de)crescendo")); + stop_ev = 0; + } + } if (accepted_spanreqs_drul_[START]) { - if (current_cresc_req_) + if (current_cresc_ev_) { - Direction sd = to_dir (current_cresc_req_->get_mus_property ("span-direction")); + Direction sd = to_dir (current_cresc_ev_->get_mus_property ("span-direction")); String msg = sd == 1 ? _ ("already have a crescendo") : _ ("already have a decrescendo"); accepted_spanreqs_drul_[START]->origin ()->warning (msg); - current_cresc_req_->origin ()->warning (_("Cresc started here")); + current_cresc_ev_->origin ()->warning (_("Cresc started here")); } else { - current_cresc_req_ = accepted_spanreqs_drul_[START]; + current_cresc_ev_ = accepted_spanreqs_drul_[START]; + + if (Direction d = to_dir (current_cresc_ev_->get_mus_property ("direction"))) + Directional_element_interface::set (line_spanner_, d); /* TODO: Use symbols. */ String start_type = - ly_symbol2string (current_cresc_req_->get_mus_property ("name")); + ly_symbol2string (current_cresc_ev_->get_mus_property ("name")); /* ugh. Use push/pop? @@ -243,6 +250,9 @@ Dynamic_engraver::process_music () ? BIGGER : SMALLER)); } + + + /* This is a convenient (and legacy) interface to TextSpanners for use in (de)crescendi. @@ -284,7 +294,7 @@ void Dynamic_engraver::stop_translation_timestep () { typeset_all (); - if (!current_cresc_req_) + if (!current_cresc_ev_) { finished_line_spanner_ = line_spanner_; line_spanner_ =0; @@ -311,7 +321,7 @@ Dynamic_engraver::finalize () cresc_ = 0; if (cresc_) { - current_cresc_req_->origin ()->warning (_ ("unterminated (de)crescendo")); + current_cresc_ev_->origin ()->warning (_ ("unterminated (de)crescendo")); cresc_->suicide (); cresc_ = 0; } diff --git a/lily/phrasing-slur-engraver.cc b/lily/phrasing-slur-engraver.cc index 6eb01c6d8d..6395cfb115 100644 --- a/lily/phrasing-slur-engraver.cc +++ b/lily/phrasing-slur-engraver.cc @@ -12,10 +12,17 @@ #include "engraver.hh" #include "spanner.hh" +/* + TODO: + + ALGRGRRGRG + + Derive this from Slur_engraver. This code is completely duplicate. + */ class Phrasing_slur_engraver : public Engraver { Link_array eventses_; - Link_array new_phrasing_slur_reqs_; + Link_array new_phrasing_slur_evs_; Link_array phrasing_slur_l_stack_; Link_array end_phrasing_slurs_; Moment last_start_; @@ -39,9 +46,9 @@ Phrasing_slur_engraver::Phrasing_slur_engraver () } bool -Phrasing_slur_engraver::try_music (Music *req) +Phrasing_slur_engraver::try_music (Music *ev) { - if (req->is_mus_type ("abort-event")) + if (ev->is_mus_type ("abort-event")) { for (int i = 0; i < phrasing_slur_l_stack_.size (); i++) { @@ -54,28 +61,28 @@ Phrasing_slur_engraver::try_music (Music *req) } end_phrasing_slurs_.clear (); eventses_.clear (); - new_phrasing_slur_reqs_.clear (); + new_phrasing_slur_evs_.clear (); } - else if (req->is_mus_type ("phrasing-slur-event")) + else if (ev->is_mus_type ("phrasing-slur-event")) { /* Let's not start more than one phrasing slur per moment. */ - Direction d = to_dir (req->get_mus_property ("span-direction")); + Direction d = to_dir (ev->get_mus_property ("span-direction")); if (d == START) { if (now_mom () > last_start_) { - new_phrasing_slur_reqs_.push (req); + new_phrasing_slur_evs_.push (ev); last_start_ = now_mom (); return true; } } else { - new_phrasing_slur_reqs_.push (req); + new_phrasing_slur_evs_.push (ev); return true; } } @@ -121,17 +128,17 @@ void Phrasing_slur_engraver::process_acknowledged_grobs () { Link_array start_phrasing_slurs; - for (int i=0; i< new_phrasing_slur_reqs_.size (); i++) + for (int i=0; i< new_phrasing_slur_evs_.size (); i++) { - Music* phrasing_slur_req = new_phrasing_slur_reqs_[i]; + Music* phrasing_slur_ev = new_phrasing_slur_evs_[i]; // end phrasing slur: move the phrasing slur to other array - Direction d = to_dir (phrasing_slur_req->get_mus_property ("span-direction")); + Direction d = to_dir (phrasing_slur_ev->get_mus_property ("span-direction")); if (d == STOP) { if (phrasing_slur_l_stack_.empty ()) - phrasing_slur_req->origin ()->warning (_f ("can't find start of phrasing slur")); + phrasing_slur_ev->origin ()->warning (_f ("can't find start of phrasing slur")); else { Grob* phrasing_slur = phrasing_slur_l_stack_.pop (); @@ -145,14 +152,21 @@ Phrasing_slur_engraver::process_acknowledged_grobs () // (use temp. array to wait for all phrasing_slur STOPs) Grob* phrasing_slur = new Spanner (get_property ("PhrasingSlur")); Slur::set_interface (phrasing_slur); // can't remove. + + + if (Direction updown = to_dir (phrasing_slur_ev->get_mus_property ("direction"))) + { + phrasing_slur->set_grob_property ("direction", gh_int2scm (updown)); + } + start_phrasing_slurs.push (phrasing_slur); - eventses_.push (phrasing_slur_req); - announce_grob(phrasing_slur, phrasing_slur_req->self_scm()); + eventses_.push (phrasing_slur_ev); + announce_grob(phrasing_slur, phrasing_slur_ev->self_scm()); } } for (int i=0; i < start_phrasing_slurs.size (); i++) phrasing_slur_l_stack_.push (start_phrasing_slurs[i]); - new_phrasing_slur_reqs_.clear (); + new_phrasing_slur_evs_.clear (); } void @@ -168,7 +182,7 @@ Phrasing_slur_engraver::stop_translation_timestep () void Phrasing_slur_engraver::start_translation_timestep () { - new_phrasing_slur_reqs_.clear (); + new_phrasing_slur_evs_.clear (); } @@ -178,5 +192,5 @@ ENTER_DESCRIPTION(Phrasing_slur_engraver, /* creats*/ "PhrasingSlur", /* accepts */ "phrasing-slur-event", /* acks */ "note-column-interface", -/* reads */ "slurMelismaBusy", +/* reads */ "", /* write */ ""); diff --git a/lily/slur-engraver.cc b/lily/slur-engraver.cc index 77942bf6c8..010ce63fa7 100644 --- a/lily/slur-engraver.cc +++ b/lily/slur-engraver.cc @@ -18,7 +18,7 @@ class Slur_engraver : public Engraver { Link_array events_; - Link_array new_slur_reqs_; + Link_array new_slur_evs_; Link_array slur_stack_; Link_array end_slurs_; Moment last_start_; @@ -43,9 +43,9 @@ Slur_engraver::Slur_engraver () } bool -Slur_engraver::try_music (Music *req) +Slur_engraver::try_music (Music *ev) { - if (req->is_mus_type ("abort-event")) + if (ev->is_mus_type ("abort-event")) { for (int i = 0; i < slur_stack_.size (); i++) { @@ -58,19 +58,19 @@ Slur_engraver::try_music (Music *req) } end_slurs_.clear (); events_.clear (); - new_slur_reqs_.clear (); + new_slur_evs_.clear (); } - else if (req->is_mus_type ("slur-event")) + else if (ev->is_mus_type ("slur-event")) { /* Let's not start more than one slur per moment. */ - Direction d = to_dir (req->get_mus_property ("span-direction")); + Direction d = to_dir (ev->get_mus_property ("span-direction")); if (d == START) { if (now_mom () > last_start_) { - new_slur_reqs_.push (req); + new_slur_evs_.push (ev); last_start_ = now_mom (); } @@ -86,15 +86,15 @@ Slur_engraver::try_music (Music *req) /* Swallow other events. */ - for (int j = new_slur_reqs_.size(); j--;) + for (int j = new_slur_evs_.size(); j--;) { - Direction nd = to_dir (new_slur_reqs_[j]->get_mus_property ("span-direction")); + Direction nd = to_dir (new_slur_evs_[j]->get_mus_property ("span-direction")); if (nd == STOP) return true; } - new_slur_reqs_.push (req); + new_slur_evs_.push (ev); return true; } } @@ -146,17 +146,17 @@ void Slur_engraver::process_acknowledged_grobs () { Link_array start_slurs; - for (int i=0; i< new_slur_reqs_.size (); i++) + for (int i=0; i< new_slur_evs_.size (); i++) { - Music* slur_req = new_slur_reqs_[i]; + Music* slur_ev = new_slur_evs_[i]; // end slur: move the slur to other array - Direction d = to_dir (slur_req->get_mus_property ("span-direction")); - if (d== STOP) + Direction d = to_dir (slur_ev->get_mus_property ("span-direction")); + if (d== STOP) { if (slur_stack_.empty ()) /* How to shut up this warning, when Voice_devnull_engraver has eaten start event? */ - slur_req->origin ()->warning (_f ("can't find start of slur")); + slur_ev->origin ()->warning (_f ("can't find start of slur")); else { Grob* slur = slur_stack_.pop (); @@ -171,14 +171,21 @@ Slur_engraver::process_acknowledged_grobs () // (use temp. array to wait for all slur STOPs) Grob* slur = new Spanner (get_property ("Slur")); Slur::set_interface (slur); // cannot remove yet! + + + if (Direction updown = to_dir (slur_ev->get_mus_property ("direction"))) + { + slur->set_grob_property ("direction", gh_int2scm (updown)); + } + start_slurs.push (slur); - events_.push (slur_req); - announce_grob (slur, slur_req->self_scm ()); + events_.push (slur_ev); + announce_grob (slur, slur_ev->self_scm ()); } } for (int i=0; i < start_slurs.size (); i++) slur_stack_.push (start_slurs[i]); - new_slur_reqs_.clear (); + new_slur_evs_.clear (); } void @@ -194,7 +201,7 @@ Slur_engraver::stop_translation_timestep () void Slur_engraver::start_translation_timestep () { - new_slur_reqs_.clear (); + new_slur_evs_.clear (); SCM m = get_property ("automaticMelismata"); if (to_boolean (m)) { @@ -205,7 +212,7 @@ Slur_engraver::start_translation_timestep () ENTER_DESCRIPTION (Slur_engraver, -/* descr */ "Build slurs from Slur_reqs", +/* descr */ "Build slurs from Slur_evs", /* creats*/ "Slur", /* accepts */ "slur-event", /* acks */ "note-column-interface", diff --git a/lily/source-file.cc b/lily/source-file.cc index 0520502e54..f56c406638 100644 --- a/lily/source-file.cc +++ b/lily/source-file.cc @@ -275,7 +275,9 @@ Source_file::get_line (char const* pos_str0) const pos_str0, Link_array::default_compare, &lo, &hi); - + + if (*pos_str0 == '\n') + lo --; return lo + 2; } diff --git a/lily/time-signature-engraver.cc b/lily/time-signature-engraver.cc index 11bc922e4c..20d1196cac 100644 --- a/lily/time-signature-engraver.cc +++ b/lily/time-signature-engraver.cc @@ -7,9 +7,11 @@ */ #include "time-signature.hh" +#include "warn.hh" #include "engraver.hh" #include "engraver-group-engraver.hh" +#include "misc.hh" /** generate time_signatures. @@ -40,8 +42,25 @@ Time_signature_engraver::process_music () not rigorously safe, since the value might get GC'd and reallocated in the same spot */ SCM fr= get_property ("timeSignatureFraction"); - if (!time_signature_ && last_time_fraction_ != fr) + if (!time_signature_ + && last_time_fraction_ != fr + && gh_pair_p (fr)) { + int den = gh_scm2int (gh_cdr (fr)); + if (den != (1 << intlog2 (den))) + { + /* + Todo: should make typecheck? + + OTOH, Tristan Keuris writes 8/20 in his Intermezzi. + */ + warning (_f("Found strange time signature %d/%d.", + den, + gh_scm2int (gh_car (fr)) + )); + } + + last_time_fraction_ = fr; time_signature_ = new Item (get_property ("TimeSignature")); time_signature_->set_grob_property ("fraction",fr); diff --git a/ly/grace-init.ly b/ly/grace-init.ly index 186d87ae4d..e357e50242 100644 --- a/ly/grace-init.ly +++ b/ly/grace-init.ly @@ -56,3 +56,23 @@ stopGraceMusic = { \property Voice.fontSize \unset } + +#(define (add-to-grace-init context object prop val) + " Override context.object #'property before entering grace context, +and restore afterwards. Use this to add settings to default grace notes. +" + (set! stopGraceMusic + (make-sequential-music + (cons + (context-spec-music (make-grob-property-revert object prop) context) + (ly-get-mus-property stopGraceMusic 'elements) + ))) + (set! startGraceMusic + (make-sequential-music + (append + (ly-get-mus-property startGraceMusic 'elements) + (list (context-spec-music (make-grob-property-set object prop val) context)) + ) + ))) + +