From: Jan Nieuwenhuizen Date: Sun, 21 Sep 2003 17:18:56 +0000 (+0000) Subject: * lily/beam.cc (brew_molecule): read gap-count to determine X-Git-Tag: release/1.9.9~14 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=5320f6d196dd67186178adcb6e5debdbbec8aee8;p=lilypond.git * lily/beam.cc (brew_molecule): read gap-count to determine number of tremolo (gapped) beams. * lily/chord-tremolo-engraver.cc (acknowledge_grob): repeats shorter than 1/8 * flower/include/array.hh (default_compare): new function --- diff --git a/ChangeLog b/ChangeLog index be6d5be8ea..0ee849e148 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2003-09-21 Jan Nieuwenhuizen + * lily/beam.cc (brew_molecule): read gap-count to determine + number of tremolo (gapped) beams. + + * lily/chord-tremolo-engraver.cc (acknowledge_grob): repeats + shorter than 1/8 + + * flower/include/array.hh (default_compare): new function + * cygwin/mknetrel: Native fixes. * cygwin/GNUmakefile (EXTRA_DIST_FILES): Add mknetrel.* diff --git a/flower/include/array.hh b/flower/include/array.hh index 15cacd6369..704e964ef7 100644 --- a/flower/include/array.hh +++ b/flower/include/array.hh @@ -243,6 +243,17 @@ public: void reverse (); }; +template +int default_compare (T const&a , T const&b) +{ + if (a < b) + return -1; + else if (a > b) + return 1; + else + return 0; +} + #include "array.icc" #endif diff --git a/input/regression/chord-tremolo-short.ly b/input/regression/chord-tremolo-short.ly new file mode 100644 index 0000000000..2c10fb62d5 --- /dev/null +++ b/input/regression/chord-tremolo-short.ly @@ -0,0 +1,18 @@ +\version "1.9.8" +\header { + texidoc = " + Tremolo repeats can be constructed for short tremolos (total duration smaller than 1/8) too. Only some of the beams are connected to the stems. + " +} + +\score { + \context Staff \notes \relative c' { + \repeat "tremolo" 2 { c32 e32 } + \stemDown + \repeat "tremolo" 2 { c32 e32 } + } + \paper { raggedright = ##t } +} + +%% new-chords-done %% + diff --git a/lily/beam.cc b/lily/beam.cc index ebec7111a4..8d5f1bb224 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -336,7 +336,11 @@ Beam::brew_molecule (SCM grob) Real last_width = -1 ; - SCM gap = me->get_grob_property ("gap"); + Real gap_length =0.0; + SCM scm_gap = me->get_grob_property ("gap"); + if (gh_number_p (scm_gap)) + gap_length = gh_scm2double (scm_gap); + Molecule the_beam; Real lt = me->get_paper ()->get_realvar (ly_symbol2scm ("linethickness")); @@ -347,7 +351,7 @@ Beam::brew_molecule (SCM grob) SCM this_beaming = st ? st->get_grob_property ("beaming") : SCM_EOL; Real xposn = st ? st->relative_coordinate (xcommon, X_AXIS) : 0.0; Real stem_width = st ? gh_scm2double (st->get_grob_property ("thickness")) *lt : 0 ; - + Direction stem_dir = st ? to_dir (st->get_grob_property ("direction")) : CENTER; /* We do the space left of ST, with lfliebertjes pointing to the right from the left stem, and rfliebertjes pointing left from @@ -356,7 +360,7 @@ Beam::brew_molecule (SCM grob) SCM left = (i>0) ? gh_cdr (last_beaming) : SCM_EOL; SCM right = st ? gh_car (this_beaming) : SCM_EOL; - Array fullbeams; + Array full_beams; Array lfliebertjes; Array rfliebertjes; @@ -366,7 +370,7 @@ Beam::brew_molecule (SCM grob) int b = gh_scm2int (gh_car (s)); if (scm_memq (gh_car(s), right) != SCM_BOOL_F) { - fullbeams.push (b); + full_beams.push (b); } else { @@ -401,22 +405,39 @@ Beam::brew_molecule (SCM grob) width_corr += stem_width/2; } - if (gh_number_p (gap)) - { - Real g = gh_scm2double (gap); - stem_offset += g; - width_corr -= 2*g; - } Molecule whole = Lookup::beam (dydx, w + width_corr, thick); - for (int j = fullbeams.size(); j--;) + Molecule gapped; + + int gap_count = 0; + if (gh_number_p (me->get_grob_property ("gap-count"))) + { + gap_count = gh_scm2int (me->get_grob_property ("gap-count")); + gapped = Lookup::beam (dydx, w + width_corr - 2 * gap_length, thick); + + full_beams.sort (default_compare); + if (stem_dir == UP) + full_beams.reverse (); + } + + int k = 0; + for (int j = full_beams.size (); j--;) { Molecule b (whole); + + if (k++ < gap_count) + { + b = gapped; + b.translate_axis (gap_length, X_AXIS); + } b.translate_axis (last_xposn - x0 + stem_offset, X_AXIS); - b.translate_axis (dydx * (last_xposn - x0) + bdy * fullbeams[j], Y_AXIS); + b.translate_axis (dydx * (last_xposn - x0) + bdy * full_beams[j], Y_AXIS); + the_beam.add_molecule (b); } + + if (lfliebertjes.size() || rfliebertjes.size()) { Real nw_f; diff --git a/lily/chord-tremolo-engraver.cc b/lily/chord-tremolo-engraver.cc index 983676ccc3..6d4160ea66 100644 --- a/lily/chord-tremolo-engraver.cc +++ b/lily/chord-tremolo-engraver.cc @@ -50,6 +50,8 @@ protected: Moment start_mom_; Moment stop_mom_; int flags_ ; + int total_duration_flags_; + /// location within measure where beam started. Moment beam_start_location_; @@ -104,13 +106,7 @@ Chord_tremolo_engraver::try_music (Music * m) Rational total_dur = l.main_part_; Rational note_dur = total_dur / Rational (elt_count * repeat_->repeat_count ()); - if (total_dur < Rational (1,4)) - { - /* - This would require beams between flagged (8th) notes. - */ - rp->origin ()->warning ("Chord tremolo is too short to denote properly."); - } + total_duration_flags_ = 0 >? (intlog2 (total_dur.den ()) - 2); flags_ = intlog2 (note_dur.den ()) -2 ; @@ -181,12 +177,10 @@ Chord_tremolo_engraver::acknowledge_grob (Grob_info info) else Stem::set_beaming (s, flags_, LEFT); - SCM d = s->get_grob_property ("direction"); if (Stem::duration_log (s) != 1) { - beam_->set_grob_property ("gap", gh_double2scm (0.8)); + beam_->set_grob_property ("gap-count", gh_int2scm (flags_ - total_duration_flags_)); } - s->set_grob_property ("direction", d); if (info.music_cause ()->is_mus_type ("rhythmic-event")) { diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 664a65003c..80ae2e3650 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -137,7 +137,7 @@ (molecule-callback . ,Beam::brew_molecule) (concaveness-gap . 2.0) (concaveness-threshold . 0.08) - + (gap . 0.8) (positions . (#f . #f)) (position-callbacks . (,Beam::least_squares ,Beam::check_concave