]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/parser.yy (Repeated_music): bug fix beam multiplicity was
authorhanwen <hanwen>
Wed, 2 Jul 2003 16:15:24 +0000 (16:15 +0000)
committerhanwen <hanwen>
Wed, 2 Jul 2003 16:15:24 +0000 (16:15 +0000)
completely borked

* lily/chord-tremolo-engraver.cc (try_music): warnings for user-errors.
(try_music): bug fix: beam multiplicity was completely borked.

ChangeLog
input/regression/chord-tremolo.ly
lily/chord-tremolo-engraver.cc
lily/duration.cc
lily/parser.yy
scm/define-music-types.scm

index 890a39f5348070f8e0d8e199ec5a3dfd33352db2..17a831b2ada1db88dd8d46f6313ca4d8f2208667 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2003-07-02  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
 
+       * lily/parser.yy (Repeated_music): bug fix beam multiplicity was
+       completely borked 
+
+       * lily/chord-tremolo-engraver.cc (try_music): warnings for user-errors.
+       (try_music): bug fix: beam multiplicity was completely borked.
+
        * scm/lily.scm: remove tail, filter-list, filter-out-list,
        first-n, butfirst-n in favor of srfi-1 functions.
        remove string-join, string-pad in favor of srfi-13 functions.
index 4a7cddf3ff19fe593e44c49da0f6dcd0caf00224..8312a186f171e92c9ee7797d8333be89b1ae1778 100644 (file)
@@ -8,33 +8,36 @@ leave a gap.  Chord tremolo beams on half notes are not ambiguous,
 as half notes cannot appear in a regular beam, and should reach the 
 stems.
 
+In this example, each tremolo lasts exactly one measure.
+
 (To ensure that the spacing engine is not confused we add some regular notes as well.) 
 "
 }
   
 \score { 
   \context Voice \notes\relative c' {
-        % huh -> one beam missing!
-       \repeat "tremolo" 16 { d16 e }
+       \time 4/4
+       \repeat "tremolo" 16 { d32 e }
        \repeat "tremolo" 8 { d16 e }
-       \repeat "tremolo" 4 { d e }
-       \repeat "tremolo" 2 { d e }
-       c4
-       \break
-       \repeat "tremolo" 4 { f'8 e }
-       \repeat "tremolo" 2 { f e }
-       c4 c4
-
-       \repeat "tremolo" 3 { f8 e }
-       c4
-       c4 c4 c4 c4
-       c4 c4 c4 c4
-       c4 c4 c4 c4
+       \repeat "tremolo" 4 { d8 e }
+
+       \time 3/4
+       \repeat "tremolo" 12 { d32 e }
+       \repeat "tremolo" 6 { d16 e } 
+       \repeat "tremolo" 3 { d8 e } 
+
+       \time 2/4
+       \repeat "tremolo" 8 { d32 e }
+       \repeat "tremolo" 4 { d16 e }
+       \repeat "tremolo" 2 { d8 e }
 
+       \time 1/4
+       \repeat "tremolo" 4 { d32 e }
+       \repeat "tremolo" 2 { d16 e }
+
+       c4 c4 c4 c4 c4 
   }
-  \paper {
-    linewidth = 90*\staffspace
-  }  
+
   \midi { }
 }
 %% new-chords-done %%
index 9f418058050299288fa87c053a62dea96958387a..ad72b7f769caa53e8ac076f7a2e9d08358e3b287 100644 (file)
@@ -86,11 +86,33 @@ Chord_tremolo_engraver::try_music (Music * m)
       repeat_ = rp;
       start_mom_ = now_mom ();
       stop_mom_ = start_mom_ + l;
-      sequential_body_b_ = dynamic_cast<Sequential_music*> (rp->body ());
 
+      Sequential_music * seq = dynamic_cast<Sequential_music*> (rp->body ());
+      sequential_body_b_ = seq;
+
+      int elt_count = seq ? scm_ilength (seq-> music_list ()) : 1;
+
+      if (elt_count != 2)
+       {
+         rp->origin ()->warning (_f ("Chord tremolo with %d elements. Must have two elements.", elt_count));
+       }
+
+      if (elt_count <= 0)
+       elt_count = 1;
+         
       Rational total_dur = l.main_part_;
-      Rational note_dur = (total_dur / Rational (repeat_->repeat_count ()));
-       flags_ = intlog2 ((total_dur / note_dur).num ());
+      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.");
+       }
+      
+      Rational written_note_dur = total_dur / Rational (elt_count);
+      flags_ = intlog2 (note_dur.den ()) -2 ;
       
       return true;
     }
@@ -116,14 +138,12 @@ Chord_tremolo_engraver::process_music ()
        }
       else if (!sequential_body_b_ && !stem_tremolo_)
        {
-
          if (flags_)
            {
              stem_tremolo_ = new Item (get_property ("StemTremolo"));
              announce_grob(stem_tremolo_, repeat_->self_scm());
              stem_tremolo_->set_grob_property ("flag-count",
                                                scm_int2num (flags_));
-
            }
        }
     }
index 3847353d2678cf09ad68b8a9b4acea301ec02a7a..6443153f5166ae8e02cf101f2ef3cd8aeb711b3f 100644 (file)
@@ -180,7 +180,10 @@ LY_DEFINE(make_duration,
     num = gh_int2scm (1);
   
   if (den != SCM_UNDEFINED)
-    SCM_ASSERT_TYPE(gh_number_p (den), length, SCM_ARG4, __FUNCTION__, "integer");
+    {
+      SCM_ASSERT_TYPE(gh_number_p (den), length, SCM_ARG4, __FUNCTION__, "integer");
+      compress = true;
+    }
   else
     den = gh_int2scm (1);
   
index 72086b41a899d963e767ab706fd98ca1b0d7cc6a..aff60db1e302edd97daa20ed821d645d705638c3 100644 (file)
@@ -71,7 +71,7 @@ TODO:
 #include "input-smob.hh"
 #include "event.hh"
 #include "text-item.hh"
-
+#include "music-list.hh"
 
 
 #define MY_MAKE_MUSIC(x)  make_music_by_name (ly_symbol2scm (x))
@@ -794,17 +794,30 @@ Repeated_music:
                r->set_mus_property ("repeat-count", gh_int2scm (times >? 1));
 
                r-> set_mus_property ("elements",alts);
-               if (gh_equal_p ($2, scm_makfrom0str ("tremolo")))
-               {
-               /*
-               we can not get durations and other stuff correct down the line, so we have to
-               add to the duration log here.
-               */
-                       SCM func = scm_primitive_eval (ly_symbol2scm ("shift-duration-log"));
-                       if (($3 % 3) == 0)
-                         gh_call3 (func, r->self_scm (), gh_int2scm(-intlog2 ($3*2/3)),gh_int2scm(1));
-                       else
-                         gh_call3 (func, r->self_scm (), gh_int2scm(-intlog2 ($3)), gh_int2scm(0));
+               if (gh_equal_p ($2, scm_makfrom0str ("tremolo"))) {
+                       /*
+                       we can not get durations and other stuff correct down the line, so we have to
+                       add to the duration log here.
+                       */
+                       static SCM func;
+
+                       if (!func)
+                               func = scm_primitive_eval (ly_symbol2scm ("shift-duration-log"));
+
+                       int dots = ($3 % 3) ? 0 : 1;
+                       int shift = -intlog2 ((dots) ? ($3*2/3) : $3);
+
+                       Sequential_music * seq = dynamic_cast<Sequential_music*> ($4);
+                       
+                       if (seq) {
+                               int list_len =scm_ilength (seq->music_list ());
+                               if (list_len != 2)
+                                       seq->origin ()->warning ("Chord tremolo must have 2 elements.");
+                               shift -= 1;
+                               r->compress (Moment (Rational (1,list_len)));
+                               }
+                       gh_call3 (func, r->self_scm (), gh_int2scm(shift),gh_int2scm(dots));
+
                }
                r->set_spot (*$4->origin ());
 
index e44981c1764d7f49995c4ac6d4ddcc955bf5b977..d0fdce20c8b4a0a97e80c1cb3dd64d41838da019 100644 (file)
@@ -607,7 +607,7 @@ For example, transposed music.")
        (types . (general-music repeated-music percent-repeated-music))
        ))
     
-    (TremoloRepeteadMusic
+    (TremoloRepeatedMusic
      . (
        (iterator-ctor . ,Chord_tremolo_iterator::constructor)
        (description .  "Repeated notes denoted by tremolo beams.")
@@ -682,7 +682,7 @@ For example, transposed music.")
                '(("volta" . VoltaRepeatedMusic)
                  ("unfold" . UnfoldedRepeatedMusic)
                  ("percent" . PercentRepeatedMusic)
-                 ("tremolo" . TremoloRepeteadMusic)
+                 ("tremolo" . TremoloRepeatedMusic)
                  ("fold" . FoldedRepeatedMusic)
                  )))
        (music-name