]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/include/repeated-music.hh (class Repeated_music): change
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 16 Jan 2005 18:31:36 +0000 (18:31 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 16 Jan 2005 18:31:36 +0000 (18:31 +0000)
into "namespace" class.

* lily/event.cc: remove Key_change_event.

* lily/include/transposed-music.hh (class Transposed_music): remove.

* lily/transposed-music.cc: remove

* lily/include/relative-music.hh: remove.

* lily/include/music-sequence.hh (struct Music_sequence): change
into "namespace" class.

* lily/untransposable-music.cc (Module): remove

* lily/include/un-relativable-music.hh (Module): remove

* lily/include/untransposable-music.hh (Module): remove

* lily/un-relativable-music.cc: remove file.

16 files changed:
ChangeLog
lily/chord-tremolo-engraver.cc
lily/chord-tremolo-iterator.cc
lily/event.cc
lily/folded-repeat-iterator.cc
lily/include/event.hh
lily/include/music-sequence.hh
lily/include/music.hh
lily/include/repeated-music.hh
lily/key-performer.cc
lily/music.cc
lily/percent-repeat-engraver.cc
lily/percent-repeat-iterator.cc
lily/relative-octave-music.cc
lily/repeated-music.cc
lily/slash-repeat-engraver.cc

index fa7b5bbd835e4f041e0d1e3286ebaee112720dd7..ca13b974a3bc07bce0bfcb0b191f02fd7422a07b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2005-01-16  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * lily/include/repeated-music.hh (class Repeated_music): change
+       into "namespace" class.
+
+       * lily/event.cc: remove Key_change_event.
+
        * lily/include/transposed-music.hh (class Transposed_music): remove.
 
        * lily/transposed-music.cc: remove
index e2f5d9516f19921c6d0d4d09265e74121c53acaa..382bf8a4c4776582fcbbd580e96741cdb6eddfb1 100644 (file)
@@ -41,7 +41,7 @@ class Chord_tremolo_engraver : public Engraver
   void typeset_beam ();
   TRANSLATOR_DECLARATIONS (Chord_tremolo_engraver);
 protected:
-  Repeated_music * repeat_;
+  Music * repeat_;
 
   /// moment (global time) where beam started.
   Moment start_mom_;
@@ -52,7 +52,7 @@ protected:
   /// location  within measure where beam started.
   Moment beam_start_location_;
 
-  bool sequential_body_b_;
+  bool body_is_sequential_;
   Spanner * beam_;
   Spanner * finished_beam_;
   Item * stem_tremolo_;
@@ -71,37 +71,37 @@ Chord_tremolo_engraver::Chord_tremolo_engraver ()
   repeat_ = 0;
   flags_ = 0;
   stem_tremolo_ = 0;
-  sequential_body_b_ = false;
+  body_is_sequential_ = false;
 }
 
 bool
 Chord_tremolo_engraver::try_music (Music * m)
 {
-  Repeated_music * rp = dynamic_cast<Repeated_music*> (m);
-  if (rp
-      && rp->get_property ("iterator-ctor") == Chord_tremolo_iterator::constructor_proc
+  if (m->is_mus_type ("repeated-music")
+      && m->get_property ("iterator-ctor") == Chord_tremolo_iterator::constructor_proc
       && !repeat_) 
     {
-      Moment l = rp->get_length ();
-      repeat_ = rp;
+      Moment l = m->get_length ();
+      repeat_ = m;
       start_mom_ = now_mom ();
       stop_mom_ = start_mom_ + l;
 
-      
-      sequential_body_b_ = rp->body()->is_mus_type ("sequential-music");
 
-      int elt_count = sequential_body_b_ ? scm_ilength (rp->body()->get_property ("elements")) : 1;
+      Music *body = Repeated_music::body (m);
+      body_is_sequential_ = body->is_mus_type ("sequential-music");
+
+      int elt_count = body_is_sequential_ ? scm_ilength (body->get_property ("elements")) : 1;
 
-      if (sequential_body_b_ && elt_count != 2)
+      if (body_is_sequential_ && elt_count != 2)
        {
-         rp->origin ()->warning (_f ("Chord tremolo with %d elements. Must have two elements.", elt_count));
+         m->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 (elt_count * repeat_->repeat_count ());
+      Rational note_dur = total_dur / Rational (elt_count * Repeated_music::repeat_count (repeat_));
 
       total_duration_flags_ = 0 >? (intlog2 (total_dur.den ()) - 2);
       
@@ -116,7 +116,7 @@ Chord_tremolo_engraver::try_music (Music * m)
 void
 Chord_tremolo_engraver::process_music ()
 {
-  if (repeat_ && sequential_body_b_ && !beam_)
+  if (repeat_ && body_is_sequential_ && !beam_)
     {
       beam_ = make_spanner ("Beam", repeat_->self_scm ());
       beam_->set_property ("chord-tremolo", SCM_BOOL_T);
@@ -173,7 +173,7 @@ Chord_tremolo_engraver::acknowledge_grob (Grob_info info)
        }
     }
   else if (repeat_ &&
-          flags_ && !sequential_body_b_ && Stem::has_interface (info.grob_))
+          flags_ && !body_is_sequential_ && Stem::has_interface (info.grob_))
     {
       stem_tremolo_ = make_item ("StemTremolo", repeat_->self_scm ());
       stem_tremolo_->set_property ("flag-count",
index 36e8697426e4b6d00e25adff55d545aad73c0dc7..e698183f403f49436c7a8dc77dc8fa0ac7fa804c 100644 (file)
 void
 Chord_tremolo_iterator::construct_children ()
 {
-  Repeated_music * rep = dynamic_cast<Repeated_music*> (get_music ());
+  Music *m = get_music();
+  
   factor_  = Moment (Rational (1, 1));
-  child_iter_ = unsmob_iterator (get_iterator (rep->body ()));
+  child_iter_ = unsmob_iterator (get_iterator (Repeated_music::body (m)));
 }
 
 Chord_tremolo_iterator::Chord_tremolo_iterator ()
index c11c2b0ac7b2346c5097cfeb11407e5802b3ec3c..848162fda6ec7301421a51c4dd40bc63a290df19 100644 (file)
@@ -35,17 +35,5 @@ Event::Event (SCM i)
 
 ADD_MUSIC (Event);
 
-Key_change_ev::Key_change_ev (SCM x)
-  : Event (x)
-{
-}
-void
-Key_change_ev::transpose (Pitch p)
-{
-  SCM pa = get_property ("pitch-alist");
-  set_property ("pitch-alist", ly_transpose_key_alist (pa, p.smobbed_copy ()));
 
-  Event::transpose (p);
-}
 
-ADD_MUSIC (Key_change_ev);
index eaa110c5a88cdfc082b50207793b4fb1a53201d9..9f180c4b5e1db7b088612b01e495c94fb41a9a86 100644 (file)
@@ -46,8 +46,8 @@ Folded_repeat_iterator::pending_moment () const
 void
 Folded_repeat_iterator::construct_children ()
 {
-  Repeated_music  *  mus = dynamic_cast<Repeated_music*> (get_music ());
-  main_iter_ = unsmob_iterator (get_iterator (mus->body ()));
+  Music  *mus = get_music ();
+  main_iter_ = unsmob_iterator (get_iterator (Repeated_music::body (mus)));
   if (!main_iter_->ok ())
     {
       leave_body ();
@@ -91,18 +91,18 @@ Folded_repeat_iterator::process (Moment m)
 void
 Folded_repeat_iterator::leave_body ()
 {
-  Repeated_music *  mus = dynamic_cast<Repeated_music *> (get_music ());
+  Music *mus = get_music ();
 
   main_iter_->quit ();
   main_iter_ = 0;
-  main_length_mom_ +=  mus->body ()->get_length ();
+  main_length_mom_ +=  Repeated_music::body (mus)->get_length ();
 }
 
 void
 Folded_repeat_iterator::enter_alternative ()
 {
-  Repeated_music *  mus = dynamic_cast<Repeated_music *> (get_music ());  
-  if (mus->alternatives ())
+  Music *mus = get_music (); 
+  if (scm_is_pair (Repeated_music::alternatives (mus)))
     {
       /*
        ugh.
index 2c3272552dd551887f36b0054479d0cfc1f5bd16..470fef4fec7597657bd235ddb9c82969ccf563aa 100644 (file)
@@ -26,21 +26,6 @@ public:
 };
 
 
-/**
-    Handle key changes.
-*/
-class Key_change_ev  : public Event
-{
-public:
-  Key_change_ev (SCM);
-  SCM pitch_alist ();
-  
-protected:
-  VIRTUAL_COPY_CONSTRUCTOR (Music, Key_change_ev);
-  void transpose (Pitch  d);
-};
-
-SCM ly_transpose_key_alist (SCM,SCM);
 
 
 
index 398c20297d89c0ca9f0ad560868cf97488d58b4b..bff8922fbcb5a9e152c6b3c05ff774b33cc9fd9a 100644 (file)
@@ -30,6 +30,7 @@ public:
   static Moment minimum_start (SCM list);
 };
 
+SCM ly_transpose_key_alist (SCM l, SCM pit);
 Pitch music_list_to_relative (SCM l,Pitch p, bool ret_first);
 void transpose_music_list (SCM , Pitch);
 void compress_music_list (SCM, Moment);
index c8fec91cd5a534fc411be1719843bab0c83baf78..4f66611355d0419e7b75720114a72ce02446fe3a 100644 (file)
@@ -28,12 +28,13 @@ public:
 
   SCM internal_get_property (SCM) const;
   void internal_set_property (SCM , SCM val);
-  SCM get_property_alist (bool mut) const;
+  SCM get_property_alist (bool mutble) const;
   bool internal_is_music_type (SCM) const;
   int duration_log () const;
   
   DECLARE_SCHEME_CALLBACK(relative_callback,(SCM,SCM));
-  virtual Pitch to_relative_octave (Pitch);
+  Pitch to_relative_octave (Pitch);
+  Pitch generic_to_relative_octave (Pitch);  
   String name () const;
   Moment get_length () const;
   Moment start_mom () const;
index 7d8141dc4fc702e8d772cb74280f108b017bdac4..bd6e7aea9db841188e47667f853612806f3b6160 100644 (file)
    the first alternative is assumed to be repeated.
    
 */
-class Repeated_music : public Music
+class Repeated_music
 {
 public:
-  Repeated_music (SCM);
-  VIRTUAL_COPY_CONSTRUCTOR (Music, Repeated_music);
-
-  Music *body () const;
-  SCM alternatives () const;
+  static Music *body (Music*);
+  static SCM alternatives (Music*);
 
   /* How often do we repeat? */
-  int repeat_count () const;
+  static int repeat_count (Music*);
   DECLARE_SCHEME_CALLBACK(relative_callback,(SCM,SCM));
 
-  virtual Pitch to_relative_octave (Pitch);
-
-  Moment body_get_length () const;
-  Moment alternatives_get_length (bool fold) const;
-  Moment alternatives_volta_get_length () const;  
+  static Moment body_get_length (Music*);
+  static Moment alternatives_get_length (Music *, bool fold);
+  static Moment alternatives_volta_get_length (Music *);  
 
   DECLARE_SCHEME_CALLBACK (unfolded_music_length, (SCM));
   DECLARE_SCHEME_CALLBACK (volta_music_length, (SCM));
index 92f8f16f6628ffe360de7e2c8369742dabd4f785..f77c1dfce3def90c8ec679117a92f0320bbf7579 100644 (file)
@@ -6,6 +6,7 @@
   (c) 1997--2004 Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
+#include "music-sequence.hh"
 #include "audio-item.hh"
 #include "performer.hh"
 #include "warn.hh"
@@ -17,18 +18,18 @@ public:
   ~Key_performer ();
 
 protected:
-  virtual bool try_music (Music* req);
+  virtual bool try_music (Music* ev);
   virtual void create_audio_elements ();
   virtual void stop_translation_timestep ();
 
 private:
-  Key_change_ev* key_req_;
+  Event* key_ev_;
   Audio_key* audio_;
 };
 
 Key_performer::Key_performer ()
 {
-  key_req_ = 0;
+  key_ev_ = 0;
   audio_ = 0;
 }
 
@@ -39,9 +40,9 @@ Key_performer::~Key_performer ()
 void
 Key_performer::create_audio_elements ()
 {
-  if (key_req_) 
+  if (key_ev_) 
     {
-      SCM pitchlist = key_req_->get_property ("pitch-alist");
+      SCM pitchlist = key_ev_->get_property ("pitch-alist");
       SCM proc = ly_lily_module_constant ("alterations-in-key");
       
       SCM acc = scm_call_1 (proc, pitchlist);
@@ -62,9 +63,9 @@ Key_performer::create_audio_elements ()
       audio_ = new Audio_key (scm_to_int (acc),
                              SCM_BOOL_T != scm_equal_p (minor, c_pitchlist));
 
-      Audio_element_info info (audio_, key_req_);
+      Audio_element_info info (audio_, key_ev_);
       announce_element (info);
-      key_req_ = 0;
+      key_ev_ = 0;
     }
 }
 
@@ -79,14 +80,14 @@ Key_performer::stop_translation_timestep ()
 }
 
 bool
-Key_performer::try_music (Music* req)
+Key_performer::try_music (Music* ev)
 {
-  if (Key_change_ev *kc = dynamic_cast <Key_change_ev *> (req))
+  if (Event *kc = dynamic_cast <Event *> (ev))
     {
-      if (key_req_)
+      if (key_ev_)
        warning (_ ("FIXME: key change merge"));
 
-      key_req_ = kc;
+      key_ev_ = kc;
       return true;
     }
 
index 04ab151b25943409840973a55a81f367789b6ee3..13ca15e5420e179e6697baf1d4babe39d34a1198 100644 (file)
@@ -157,15 +157,8 @@ Music::print_smob (SCM s, SCM p, scm_print_state*)
 }
 
 Pitch
-Music::to_relative_octave (Pitch last)
+Music::generic_to_relative_octave (Pitch last)
 {
-  SCM callback = get_property ("to-relative-callback");
-  if (ly_c_procedure_p (callback))
-    {
-      Pitch * p = unsmob_pitch (scm_call_2 (callback, self_scm(), last.smobbed_copy ()));
-      return *p;
-    }
-
   SCM elt = get_property ("element");
   Pitch *old_pit = unsmob_pitch (get_property ("pitch"));
   if (old_pit)
@@ -191,7 +184,6 @@ Music::to_relative_octave (Pitch last)
       last = new_pit;
     }
 
-  
   if (Music *m = unsmob_music (elt))
     last = m->to_relative_octave (last);
 
@@ -199,6 +191,19 @@ Music::to_relative_octave (Pitch last)
   return last;
 }
 
+Pitch
+Music::to_relative_octave (Pitch last)
+{
+  SCM callback = get_property ("to-relative-callback");
+  if (ly_c_procedure_p (callback))
+    {
+      Pitch * p = unsmob_pitch (scm_call_2 (callback, self_scm(), last.smobbed_copy ()));
+      return *p;
+    }
+
+  return generic_to_relative_octave (last);
+}
+
 void
 Music::compress (Moment factor)
 {
@@ -243,6 +248,16 @@ Music::transpose (Pitch delta)
     m->transpose (delta);
 
   transpose_music_list (get_property ("elements"), delta);
+
+  /*
+    UGH - how do this more generically? 
+  */
+  SCM pa = get_property ("pitch-alist");
+  if (scm_is_pair (pa))
+    {
+      set_property ("pitch-alist", ly_transpose_key_alist (pa, delta.smobbed_copy ()));
+    }
+
 }
 
 IMPLEMENT_TYPE_P (Music, "ly:music?");
index 118d59100f74037e96c45f00364cdce2553ad772..58063603084d279ae2c6630d2381c8d15bc99679 100644 (file)
@@ -34,7 +34,7 @@ class Percent_repeat_engraver : public Engraver
 public:
   TRANSLATOR_DECLARATIONS (Percent_repeat_engraver);
 protected:
-  Repeated_music * repeat_;
+  Music *repeat_;
 
   /// moment (global time) where beam started.
   Moment start_mom_;
@@ -74,14 +74,13 @@ Percent_repeat_engraver::Percent_repeat_engraver ()
 bool
 Percent_repeat_engraver::try_music (Music * m)
 {
-  Repeated_music * rp = dynamic_cast<Repeated_music*> (m);
-  if (rp
-      && rp->get_property ("iterator-ctor")
+  if (m->is_mus_type ("repeated-music")
+      && m->get_property ("iterator-ctor")
          == Percent_repeat_iterator::constructor_proc
       && !repeat_)
     {
-      body_length_ = rp->body_get_length ();
-      int count =   rp->repeat_count ();
+      body_length_ = Repeated_music::body_get_length (m);
+      int count = Repeated_music::repeat_count (m);
       
       Moment now = now_mom ();
       start_mom_ = now;
@@ -102,7 +101,7 @@ Percent_repeat_engraver::try_music (Music * m)
          return false;
        }
 
-      repeat_ = rp;
+      repeat_ = m;
 
       
       Global_context *global = get_global_context ();
index 56b477b45e49bfc2849afafefe025d873d7fd597..107e1dd63d05d92d6c5117cdba3bc71fe2ff0934 100644 (file)
@@ -36,9 +36,9 @@ Percent_repeat_iterator::ok () const
 void
 Percent_repeat_iterator::construct_children ()
 {
-  Repeated_music * mus = dynamic_cast<Repeated_music *> (get_music ());
+  Music *mus = get_music ();
   finish_mom_ = mus->get_length ();
-  child_iter_ = unsmob_iterator (get_iterator (mus->body ()));
+  child_iter_ = unsmob_iterator (get_iterator (Repeated_music::body (mus)));
 }
 
 
index 3732808d09dd016a3e42b5f63e0c185527f4c22d..ef090a9ef7c56ecefe930bce900afbfff21f78c4 100644 (file)
@@ -38,7 +38,7 @@ Relative_octave_music::relative_callback (SCM music, SCM pitch)
       lily_1_8_compatibility_used = true;
       /*  last-pitch should be junked some time, when
          we ditch 1.8 compat too.
-cvs-
+
         When you do, B should start where A left off.
 
        \relative { A \relative { ...} B }  */
index 37735679138ac244d6340d516ddb90bbf7be8886..3a527c151abc4216a0d878982acd16e43338891f 100644 (file)
 #include "scm-option.hh"
 
 Music *
-Repeated_music::body ()const
+Repeated_music::body (Music *me)
 {
-  return unsmob_music (get_property ("element"));
+  return unsmob_music (me->get_property ("element"));
 }
 
 SCM
-Repeated_music::alternatives ()const
+Repeated_music::alternatives (Music *me)
 {
-  return get_property ("elements");
+  return me->get_property ("elements");
 }
 
-Pitch
-Repeated_music::to_relative_octave (Pitch p)
+MAKE_SCHEME_CALLBACK(Repeated_music,relative_callback, 2);
+SCM
+Repeated_music::relative_callback (SCM music, SCM pitch)
 {
+  Pitch p = *unsmob_pitch (pitch);
+  Music *me = unsmob_music (music); 
   if (lily_1_8_relative)
     {
-      if (body ())
-       p = body ()->to_relative_octave (p);
+      Music *body = unsmob_music (me->get_property ("element"));
+      if (body)
+       p = body->to_relative_octave (p);
 
-      Pitch last = p ; 
-      if (alternatives ())
-       {
-         lily_1_8_compatibility_used = true; 
+      Pitch last = p ;
+      SCM alternatives = me->get_property ("elements");
 
-         for (SCM s = alternatives (); scm_is_pair (s);  s = scm_cdr (s))
-           unsmob_music (scm_car (s))->to_relative_octave (p);
-       }     
+      for (SCM s = alternatives; scm_is_pair (s);  s = scm_cdr (s))
+       {
+         lily_1_8_compatibility_used = true;
+         unsmob_music (scm_car (s))->to_relative_octave (p);
+       }
 
-      return last;
+      return last.smobbed_copy ();
     }
   else
     {
-      return Music::to_relative_octave (p);
+      return me->generic_to_relative_octave (p).smobbed_copy ();
     }
 }
 
 
 Moment
-Repeated_music::alternatives_get_length (bool fold) const
+Repeated_music::alternatives_get_length (Music *me, bool fold) 
 {
-  if (!alternatives ())
+  SCM alternative_list = alternatives (me);
+  int len = scm_ilength (alternative_list);
+  if (len <= 0)
     return 0;
   
   if (fold)
-    return Music_sequence::maximum_length (alternatives ());
+    return Music_sequence::maximum_length (alternative_list);
 
   Moment m = 0;
   int done = 0;
+  int count = robust_scm2int (me->get_property ("repeat-count"), 0);
 
-  SCM p = alternatives ();
-  while (scm_is_pair (p) && done < repeat_count ())
+  SCM p = alternative_list;
+  while (scm_is_pair (p) && done < count)
     {
       m = m + unsmob_music (scm_car (p))->get_length ();
       done ++;
-      if (repeat_count () - done < scm_ilength (alternatives ()))
+      if (count - done < len)
        p = scm_cdr (p);
     }
   return m;
@@ -79,19 +86,9 @@ Repeated_music::alternatives_get_length (bool fold) const
   of volta repeats, where the alternatives are iterated just as they
   were entered.  */
 Moment
-Repeated_music::alternatives_volta_get_length () const
+Repeated_music::alternatives_volta_get_length (Music *me)
 {
-  if (!alternatives ())
-    return 0;
-
-  Moment m;
-  SCM p = alternatives ();
-  while (scm_is_pair (p))
-    {
-      m = m + unsmob_music (scm_car (p))->get_length ();
-      p = scm_cdr (p);
-    }
-  return m;
+  return Music_sequence::cumulative_length (alternatives (me));
 }
 
 
@@ -99,67 +96,59 @@ Repeated_music::alternatives_volta_get_length () const
   Length of the body in THIS. Disregards REPEAT-COUNT. 
  */
 Moment
-Repeated_music::body_get_length () const
+Repeated_music::body_get_length (Music *me)
 {
   Moment m = 0;
-  if (body ())
+  if (Music *body = unsmob_music (me->get_property ("element")))
     {
-      m = body ()->get_length ();
+      m = body->get_length ();
     }
   return m;
 }
 
-int
-Repeated_music::repeat_count () const
-{
-  return scm_to_int (get_property ("repeat-count"));
-}
-
 
 MAKE_SCHEME_CALLBACK (Repeated_music,unfolded_music_length, 1);
-MAKE_SCHEME_CALLBACK (Repeated_music,folded_music_length, 1);
-MAKE_SCHEME_CALLBACK (Repeated_music,volta_music_length, 1);
 
 SCM
 Repeated_music::unfolded_music_length (SCM m)
 {
-  Repeated_music* r = dynamic_cast<Repeated_music*> (unsmob_music (m));
-  
-  Moment l = Moment (r->repeat_count ()) * r->body_get_length () + r->alternatives_get_length (false);
+  Music *me = unsmob_music (m);
+
+  Moment l = Moment (repeat_count (me)) * body_get_length (me) + alternatives_get_length (me, false);
   return l.smobbed_copy ();
 }
 
+MAKE_SCHEME_CALLBACK (Repeated_music,folded_music_length, 1);
 SCM
 Repeated_music::folded_music_length (SCM m)
 {
-  Repeated_music* r = dynamic_cast<Repeated_music*> (unsmob_music (m));
-  Moment l =  r->body_get_length () + r->alternatives_get_length (true);
+  Music *me = unsmob_music (m);
+
+  Moment l =  body_get_length (me) + alternatives_get_length (me, true);
   return l.smobbed_copy ();
 }
 
-SCM
-Repeated_music::volta_music_length (SCM m)
+int
+Repeated_music::repeat_count (Music *me) 
 {
-  Repeated_music* r = dynamic_cast<Repeated_music*> (unsmob_music (m));
-  Moment l =  r->body_get_length () + r->alternatives_volta_get_length ();
-  return l.smobbed_copy ();
+  return scm_to_int (me->get_property ("repeat-count"));
 }
 
-ADD_MUSIC (Repeated_music);
-
-Repeated_music::Repeated_music (SCM x)
-  : Music (x)
+MAKE_SCHEME_CALLBACK (Repeated_music,volta_music_length, 1);
+SCM
+Repeated_music::volta_music_length (SCM m)
 {
+  Music *me = unsmob_music (m);
+  Moment l = body_get_length (me) + alternatives_volta_get_length (me);
+  return l.smobbed_copy ();
 }
 
-
 MAKE_SCHEME_CALLBACK (Repeated_music,minimum_start, 1);
 SCM
 Repeated_music::minimum_start (SCM m)
 {
-  Music * me = unsmob_music (m);
-  Music * body = unsmob_music (me->get_property ("element"));
+  Music *me = unsmob_music (m);
+  Music *body = unsmob_music (me->get_property ("element"));
 
   if (body)
     return body->start_mom ().smobbed_copy ();
index 7020be066f3144ff389110c8fdb59bbf29f94742..3f1614f6cd1600ec8c621e7efb0aa27774ed92bf 100644 (file)
@@ -33,7 +33,7 @@ class Slash_repeat_engraver : public Engraver
 public:
   TRANSLATOR_DECLARATIONS (Slash_repeat_engraver);
 protected:
-  Repeated_music * repeat_;
+  Music *repeat_;
 
   /// moment (global time) where beam started.
   Moment start_mom_;
@@ -62,30 +62,25 @@ Slash_repeat_engraver::Slash_repeat_engraver ()
 bool
 Slash_repeat_engraver::try_music (Music * m)
 {
-  Repeated_music * rp = dynamic_cast<Repeated_music*> (m);
-  if (rp
+  if (m->is_mus_type ("repeated-music")
       && !repeat_
-      && rp->get_property ("iterator-ctor")
+      && m->get_property ("iterator-ctor")
       == Percent_repeat_iterator::constructor_proc)
     {
-      body_length_ = rp->body_get_length ();
-      int count =   rp->repeat_count ();
+      body_length_ = Repeated_music::body_get_length (m);
+      int count =   Repeated_music::repeat_count (m);
       
       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;
-
+      Moment meas_len = robust_scm2moment (m->get_property ("measureLength"), Moment (0));
       if (body_length_ < meas_len 
          && meas_len.main_part_.mod_rat (body_length_.main_part_)
          == Moment (Rational (0,0)))
        {
-         repeat_ = rp;
+         repeat_ = m;
        }
       else
        return false;