]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/beam.cc (brew_molecule): read gap-count to determine
authorJan Nieuwenhuizen <janneke@gnu.org>
Sun, 21 Sep 2003 17:18:56 +0000 (17:18 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Sun, 21 Sep 2003 17:18:56 +0000 (17:18 +0000)
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

ChangeLog
flower/include/array.hh
input/regression/chord-tremolo-short.ly [new file with mode: 0644]
lily/beam.cc
lily/chord-tremolo-engraver.cc
scm/define-grobs.scm

index be6d5be8ea43edc2b1e7b45cc9430488bef0efa9..0ee849e148e5dbdf500f3e523568716ba90162dd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2003-09-21  Jan Nieuwenhuizen  <janneke@gnu.org>
 
+       * 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.*
index 15cacd63691c56a8a43917351d761443255f2cbf..704e964ef755a3b2ed1826a78fb2b65b9c8af87d 100644 (file)
@@ -243,6 +243,17 @@ public:
   void reverse ();
 };
 
+template<class T>
+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 (file)
index 0000000..2c10fb6
--- /dev/null
@@ -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 %%
+
index ebec7111a432c1a2944d619bd7b8fa70b02f627f..8d5f1bb2246a5ceb937a0023220772f3c35eccf9 100644 (file)
@@ -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<int> fullbeams;
+      Array<int> full_beams;
       Array<int> lfliebertjes;
       Array<int> 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;
index 983676ccc3e2b55003f2836acf67d3c628b3eb9e..6d4160ea66036dc7df5904197c7b4714e328f126 100644 (file)
@@ -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"))
        {
index 664a65003caa4b0d879efa4ffaa97b1f02e2592a..80ae2e3650b2b695585748de08ec298426d6b348 100644 (file)
        (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