]> git.donarmstrong.com Git - lilypond.git/commitdiff
(try_music): new file, handle
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 21 May 2003 23:55:59 +0000 (23:55 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 21 May 2003 23:55:59 +0000 (23:55 +0000)
slash repeats separately. Slash repeats and %
repeats can now be nested.

ChangeLog
Documentation/user/refman.itely
input/regression/percent-repeat-skipbars.ly [deleted file]
input/regression/percent-repeat.ly [deleted file]
input/regression/repeat-percent-skipbars.ly [new file with mode: 0644]
input/regression/repeat-percent.ly [new file with mode: 0644]
input/regression/repeat-slash.ly [new file with mode: 0644]
lily/percent-repeat-engraver.cc
lily/slash-repeat-engraver.cc [new file with mode: 0644]
ly/engraver-init.ly

index ccd6c65cd3924779add46a67a3779a628143e6c2..40b302145b198238f45affd51a0c1bbd0a06cf02 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2003-05-22  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
+
+       * lily/slash-repeat-engraver.cc (try_music): new file, handle
+       slash repeats separately. Slash repeats and %
+       repeats can now be nested.
+
 2003-05-22  Heikki Junes  <hjunes@cc.hut.fi>
 
        * lilypond-indent.el: Add preliminary test for closing \] and \).
index c4092ebcc7167cb717ba6375d5457dd359fcce30..f57d77e8b2d4ecfe2b165785e76dce5aa2cd4c1b 100644 (file)
@@ -2273,7 +2273,8 @@ example file @inputfileref{input/test,unfold-all-repeats.ly}.
 Timing information is not remembered at the start of an alternative,
 so you have to reset timing information after a repeat, e.g. using a
 bar-check (See @ref{Bar check}), setting @code{Score.measurePosition}
-or entering @code{\partial}.  Slurs or ties are also not repeated.
+or entering @code{\partial}.  Similarly, slurs or ties are also not
+repeated.
 
 
 @node Manual repeat commands
@@ -2391,8 +2392,7 @@ patterns that divide the measure length are replaced by slashes.
 
 @refbugs
 
-You cannot nest percent repeats, e.g. by filling in the first measure
-with slashes, and repeating that measure with percents.
+Single measure and double measure percent-repeats cannot be nested.
 
 @node Rhythmic music
 @section Rhythmic music
diff --git a/input/regression/percent-repeat-skipbars.ly b/input/regression/percent-repeat-skipbars.ly
deleted file mode 100644 (file)
index 0ecf396..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-\header {
-texidoc = "Percent repeats are not skipped, even when skipBars is set.  "
-}
-
-
-\include "paper20.ly"
-
-\score {
-     \context Staff <
-       \property Score.skipBars = ##t
-       \notes {
-       \repeat "percent" 2 { g2 a g a }
-       }
-     >
-}
-
diff --git a/input/regression/percent-repeat.ly b/input/regression/percent-repeat.ly
deleted file mode 100644 (file)
index 04ac83e..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-\version "1.7.18"
-\header {
-texidoc = "Measure and beat repeats are supported."
-}
-       
-\score { \notes \relative c' \context Voice { \time 4/4
-   \repeat "percent" 2 { c2 }
-
-   % the chairman dances
-   \repeat "percent" 2 { g'8 g c, c  }   
-   \repeat "percent" 4 { b8 b8  }
-   \repeat "percent" 2 { c8 d es f g4 r4  }   
-   
-   % riff
-   \repeat "percent" 2 { r8. a16 g8. a16 bes8. a16 f8 d |  a c8 ~ c8 d8 ~ d8 r8 r4 }
-   
-
-
-     }}
-%% new-chords-done %%
diff --git a/input/regression/repeat-percent-skipbars.ly b/input/regression/repeat-percent-skipbars.ly
new file mode 100644 (file)
index 0000000..0ecf396
--- /dev/null
@@ -0,0 +1,16 @@
+\header {
+texidoc = "Percent repeats are not skipped, even when skipBars is set.  "
+}
+
+
+\include "paper20.ly"
+
+\score {
+     \context Staff <
+       \property Score.skipBars = ##t
+       \notes {
+       \repeat "percent" 2 { g2 a g a }
+       }
+     >
+}
+
diff --git a/input/regression/repeat-percent.ly b/input/regression/repeat-percent.ly
new file mode 100644 (file)
index 0000000..b28f6cb
--- /dev/null
@@ -0,0 +1,13 @@
+\version "1.7.18"
+\header {
+texidoc = "Measure  repeats are supported, and may be nested with beat repeats."
+}
+       
+\score { \notes \relative c'' \context Voice { \time 4/4
+   % riff
+   \repeat "percent" 2 { r8. a16 g8. a16 bes8. a16 f8 d |  a c8 ~ c8 d8 ~ d8 r8 r4 }
+   
+   \repeat "percent" 2 { \repeat "percent" 4 { c8 es } }   
+  }
+}
+%% new-chords-done %%
diff --git a/input/regression/repeat-slash.ly b/input/regression/repeat-slash.ly
new file mode 100644 (file)
index 0000000..f572ed0
--- /dev/null
@@ -0,0 +1,15 @@
+\version "1.7.18"
+\header {
+texidoc = "Beat repeats are supported."
+}
+
+\score { \notes \relative c'
+        \context Voice { \time 4/4
+   \repeat "percent" 2 { c2 }
+
+   % the chairman dances
+   \repeat "percent" 2 { g'8 g c, c  }   
+   \repeat "percent" 4 { b8 b8  }
+  }
+        \paper { raggedright = ##t }
+}
index 63ff323b14dd4a8f745edd7e619e155dfc700779..517ba465611af3ba8536b89e8a1c3284d5c4d710 100644 (file)
@@ -51,16 +51,13 @@ protected:
 
   enum {
     UNKNOWN,
-    BEAT,
     MEASURE,
     DOUBLE_MEASURE,
   } repeat_sign_type_ ;
 
-  Item * beat_slash_;
   Item * double_percent_;
   Spanner * perc_;
   Spanner * finished_perc_;
-  Item * stem_tremolo_;
 protected:
   virtual void finalize ();
   virtual bool try_music (Music*);
@@ -71,11 +68,10 @@ protected:
 
 Percent_repeat_engraver::Percent_repeat_engraver ()
 {
-  perc_  = finished_perc_ = 0;
+  perc_  = 0;
+  finished_perc_ = 0;
   repeat_ =0;
-  stem_tremolo_ = 0;
 
-  beat_slash_ = 0;
   double_percent_ = 0;
 }
 
@@ -101,10 +97,7 @@ Percent_repeat_engraver::try_music (Music * m)
       if (unsmob_moment (m))
        meas_len = *unsmob_moment (m);
 
-      if (body_length_ < meas_len &&
-         meas_len.main_part_.mod_rat (body_length_.main_part_) == Moment (Rational (0,0)))
-       repeat_sign_type_ = BEAT;
-      else if (meas_len == body_length_)
+      if (meas_len == body_length_)
        repeat_sign_type_ = MEASURE;
       else if (Moment (2)* meas_len == body_length_)
        {
@@ -135,12 +128,7 @@ Percent_repeat_engraver::process_music ()
 {
   if (repeat_ && now_mom () == next_moment_)
     {
-      if (repeat_sign_type_ == BEAT)
-       {
-         beat_slash_ = new Item (get_property ("RepeatSlash"));
-         announce_grob(beat_slash_, repeat_->self_scm());
-       }
-      else if (repeat_sign_type_ == MEASURE)
+      if (repeat_sign_type_ == MEASURE)
        {
          finished_perc_ = perc_;
          typeset_perc ();
@@ -172,7 +160,7 @@ Percent_repeat_engraver::finalize ()
   typeset_perc ();
   if (perc_)
     {
-      repeat_->origin ()->warning (_ ("unterminated chord tremolo"));
+      repeat_->origin ()->warning (_ ("unterminated percent repeat"));
       perc_->suicide ();
     }
 }
@@ -188,12 +176,6 @@ Percent_repeat_engraver::typeset_perc ()
       finished_perc_ = 0;
     }
 
-  if (beat_slash_)
-    {
-      typeset_grob (beat_slash_);
-      beat_slash_ = 0;
-    }
-
   if (double_percent_)
     {
       typeset_grob (double_percent_);
@@ -231,8 +213,8 @@ Percent_repeat_engraver::stop_translation_timestep ()
 
 
 ENTER_DESCRIPTION(Percent_repeat_engraver,
-/* descr */       "Make beat, whole bar and double bar repeats.",
-/* creats*/       "PercentRepeat RepeatSlash DoublePercentRepeat",
+/* descr */       "Make whole bar and double bar repeats.",
+/* creats*/       "PercentRepeat DoublePercentRepeat",
 /* accepts */     "repeated-music",
 /* acks  */      "",
 /* reads */       "measureLength currentCommandColumn",
diff --git a/lily/slash-repeat-engraver.cc b/lily/slash-repeat-engraver.cc
new file mode 100644 (file)
index 0000000..456013b
--- /dev/null
@@ -0,0 +1,149 @@
+/*   
+     slash-repeat-engraver.cc --  implement Chord_tremolo_engraver
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 2000--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  
+ */
+
+#include "engraver.hh"
+#include "repeated-music.hh"
+#include "engraver-group-engraver.hh"
+#include "global-translator.hh"
+#include "warn.hh"
+#include "misc.hh"
+#include "spanner.hh"
+#include "item.hh"
+#include "percent-repeat-iterator.hh"
+#include "bar-line.hh"
+
+#include "score-engraver.hh"
+#include "translator-group.hh"
+
+/**
+  This acknowledges repeated music with "percent" style.  It typesets
+  a % sign.  
+
+  TODO:
+
+  - BEAT case: Create items for single beat repeats, i.e. c4 / / /
+
+  - DOUBLE_MEASURE case: attach a % to an appropriate barline.
+  
+*/
+class Slash_repeat_engraver : public Engraver
+{
+public:
+  TRANSLATOR_DECLARATIONS(Slash_repeat_engraver);
+protected:
+  Repeated_music * repeat_;
+
+  /// moment (global time) where beam started.
+  Moment start_mom_;
+  Moment stop_mom_;
+
+  /// location  within measure where beam started.
+  Moment beam_start_location_;
+  Moment next_moment_;
+  Moment body_length_;
+
+  Item * beat_slash_;
+  Item * double_percent_;
+protected:
+  virtual bool try_music (Music*);
+  virtual void stop_translation_timestep ();
+  virtual void start_translation_timestep ();
+  virtual void process_music ();
+};
+
+Slash_repeat_engraver::Slash_repeat_engraver ()
+{
+  repeat_ =0;
+  beat_slash_ = 0;
+}
+
+bool
+Slash_repeat_engraver::try_music (Music * m)
+{
+  Repeated_music * rp = dynamic_cast<Repeated_music*> (m);
+  if (rp
+      && !repeat_
+      && rp->get_mus_property ("iterator-ctor")
+      == Percent_repeat_iterator::constructor_proc)
+    {
+      body_length_ = rp->body_get_length ();
+      int count =   rp->repeat_count ();
+      
+      Moment now = now_mom ();
+      start_mom_ = now;
+      stop_mom_ = start_mom_ + Moment (count) * body_length_;
+      next_moment_ = start_mom_ + body_length_;
+
+      SCM m = get_property ("measureLength");
+      Moment meas_len;
+      if (Moment *mp = unsmob_moment (m))
+       meas_len = *mp;
+
+      if (body_length_ < meas_len 
+         && meas_len.main_part_.mod_rat (body_length_.main_part_)
+         == Moment (Rational (0,0)))
+       {
+         repeat_ = rp;
+       }
+      else
+       return false;
+      
+      Global_translator *global =top_engraver();
+      for (int i = 0; i < count; i++)  
+       global->add_moment_to_process (next_moment_ + Moment (i) * body_length_);
+  
+      return true;
+    }
+
+  return false;
+}
+
+void
+Slash_repeat_engraver::process_music ()
+{
+  if (repeat_ && now_mom () == next_moment_)
+    {
+      beat_slash_ = new Item (get_property ("RepeatSlash"));
+      announce_grob(beat_slash_, repeat_->self_scm());
+      next_moment_ = next_moment_ + body_length_;
+
+      top_engraver()->add_moment_to_process (next_moment_);
+    }
+}
+
+
+void
+Slash_repeat_engraver::start_translation_timestep ()
+{
+  if (stop_mom_ == now_mom ())
+    {
+      repeat_ = 0;
+    }
+}
+
+void
+Slash_repeat_engraver::stop_translation_timestep ()
+{
+ if (beat_slash_)
+    {
+      typeset_grob (beat_slash_);
+      beat_slash_ = 0;
+    }
+}
+
+
+
+
+ENTER_DESCRIPTION(Slash_repeat_engraver,
+/* descr */       "Make beat repeats.",
+/* creats*/       "RepeatSlash",
+/* accepts */     "repeated-music",
+/* acks  */      "",
+/* reads */       "measureLength currentCommandColumn",
+/* write */       "");
index 72066fe251419141de86e400e95595de9892f75a..cda7218df9e61e716415e309538b4a2dd51e88ba 100644 (file)
@@ -168,6 +168,7 @@ VoiceContext = \translator {
        \consists "New_fingering_engraver"
        \consists "Chord_tremolo_engraver"
        \consists "Percent_repeat_engraver"
+       \consists "Slash_repeat_engraver"
        \consists "Melisma_engraver"
 
 %{