--- ../lilypond29/scm/define-music-types.scm	2006-05-09 17:03:24.000000000 +0200
+++ scm/define-music-types.scm	2006-05-14 11:13:49.000000000 +0200
@@ -397,7 +397,13 @@
 	(types . (layout-instruction general-music))
 	(iterator-ctor . ,ly:property-unset-iterator::constructor)
 	))
-    
+
+    (PercentEvent
+     . (
+	(description .	"Used internally to signal percent repeats.")
+	(types . (general-music event percent-event))
+	))
+
     (PesOrFlexaEvent
      . (
 	(description .	"Within a ligature, mark the previous and the
@@ -534,19 +540,6 @@
 	(types . (general-music span-event event trill-span-event))
 	))
     
-    (TimeScaledMusic
-     . (
-	(description .	"Multiply durations, as in tuplets. 
-
-Syntax @code{\\times @var{fraction} @var{music}}, e.g.
-@code{\\times 2/3 @{ ... @}} for triplets.
- ")
-	(length-callback . ,ly:music-wrapper::length-callback)
-	(start-callback . ,ly:music-wrapper::start-callback)
-	(iterator-ctor . ,ly:time-scaled-music-iterator::constructor)
-	(types . (time-scaled-music music-wrapper-music general-music))
-	))
-    
     (TransposedMusic
      . (
 	(description .	"Music that has been transposed.")
@@ -557,6 +550,12 @@
 	(types . (music-wrapper-music general-music transposed-music))
 	))
 
+    (TupletEvent
+     . (
+	(description .  "Used internally to signal where tuplet brackets start and stop.")
+	(types . (tuplet-spanner-event span-event event general-music))
+       ))
+
     (UnrelativableMusic
      . (
 	(description .	"Music that can not be converted from relative to absolute notation.
--- ../lilypond29/scm/music-functions.scm	2006-05-09 17:03:24.000000000 +0200
+++ scm/music-functions.scm	2006-05-14 15:59:47.000000000 +0200
@@ -202,6 +202,36 @@
   (music-map (lambda (x) (shift-one-duration-log x shift dot))
 	     music))
 
+(define-public (make-repeat name times main alts)
+  "create a repeat music expression, with all properties initialized properly"
+  (let ((talts (if (< times (length alts))
+		   (begin
+		     (ly:warning (_ "More alternatives than repeats. Junking excess alternatives"))
+		     (take alts times))
+		   alts))
+	(r (make-repeated-music name)))
+    (set! (ly:music-property r 'element) main)
+    (set! (ly:music-property r 'repeat-count) (max times 1))
+    (set! (ly:music-property r 'elements) talts)
+    (if (equal? name "tremolo")
+	(let* ((dot? (zero? (modulo times 3)))
+	       (dots (if dot? 1 0))
+	       (mult (if dot?
+			 (quotient (* times 2) 3)
+			 times))
+	       (shift (- (ly:intlog2 mult))))
+	  
+	  (if (memq 'sequential-music (ly:music-property main 'types))
+	      ;; \repeat "tremolo" { c4 d4 }
+	      (let ((children (length (ly:music-property main 'elements))))
+		(if (not (= children 2))
+		    (ly:warning (_ "expecting 2 elements for chord tremolo, found ~a") children))
+		(ly:music-compress r (ly:make-moment 1 children))
+		(shift-duration-log r (1- shift) dots))
+	      ;; \repeat "tremolo" c4
+	      (shift-duration-log r shift dots)))
+	r)))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; clusters.
 
--- ../lilypond29/lily/parser.yy	2006-04-07 03:05:57.000000000 +0200
+++ lily/parser.yy	2006-05-14 16:01:07.000000000 +0200
@@ -872,57 +872,14 @@
 Repeated_music:
 	REPEAT simple_string bare_unsigned Music Alternative_music
 	{
-		/*TODO: move to Scheme.*/
-		Music *beg = $4;
-		int times = $3;
+		SCM proc = ly_lily_module_constant ("make-repeat");
 		SCM alts = scm_is_pair ($5) ? scm_car ($5) : SCM_EOL;
-		if (times < scm_ilength (alts)) {
-		  unsmob_music (scm_car (alts))
-		    ->origin ()->warning (
-		    _ ("more alternatives than repeats"));
-		    warning ("junking excess alternatives");
-		  alts = ly_truncate_list (times, alts);
-		}
-
-
-		SCM proc = ly_lily_module_constant ("make-repeated-music");
-
-		SCM mus = scm_call_1 (proc, $2);
+		assert ($4);
+		SCM mus = scm_call_4 (proc, $2, scm_int2num ($3), $4->self_scm (), alts);
 		Music *r = unsmob_music (mus);
-		r->protect ();
-		if (beg)
-			{
-			r-> set_property ("element", beg->self_scm ());
-			beg->unprotect ();
-			}
-		r->set_property ("repeat-count", scm_from_int (max (times, 1)));
-
-		r-> set_property ("elements",alts);
-		if (ly_is_equal ($2, scm_makfrom0str ("tremolo"))) {
-			/*
-			TODO: move this code to Scheme.
-			*/
-
-			/* we cannot get durations and other stuff
-			   correct down the line,
-			   so we have to add to the duration log here. */
-			SCM func = ly_lily_module_constant ("shift-duration-log");
-
-			int dots = ($3 % 3) ? 0 : 1;
-			int shift = -intlog2 ((dots) ? ($3*2/3) : $3);
 
-			
-			if ($4->is_mus_type ("sequential-music"))
-			{
-				int list_len = scm_ilength ($4->get_property ("elements"));
-				if (list_len != 2)
-					$4->origin ()->warning (_f ("expect 2 elements for Chord tremolo, found %d", list_len));
-				shift -= 1;
-				r->compress (Moment (Rational (1, list_len)));
-			}
-			scm_call_3 (func, r->self_scm (), scm_from_int (shift), scm_from_int (dots));
-
-		}
+		r->protect ();
+		$4->unprotect ();
 		r->set_spot (*$4->origin ());
 
 		$$ = r;
@@ -1069,15 +1026,30 @@
 		int d = scm_to_int (scm_cdr ($2));
 		Music *mp = $3;
 
-		$$= MY_MAKE_MUSIC ("TimeScaledMusic");
-		$$->set_spot (@$);
-
-		$$->set_property ("element", mp->self_scm ());
-		mp->unprotect();
-		$$->set_property ("numerator", scm_from_int (n));
-		$$->set_property ("denominator", scm_from_int (d));
-		$$->compress (Moment (Rational (n,d)));
+                mp->compress (Moment (Rational (n,d)));
 
+                if (mp->is_mus_type ("event-chord"))
+                  $$ = mp;
+                else
+                  {
+                    /* Create tuplet start/stop span events before/after the music */
+		    SCM tuplet_symbol = ly_symbol2scm ("TupletEvent");
+		    SCM start_event = scm_call_2 (ly_lily_module_constant ("make-span-event"), tuplet_symbol, scm_from_int (START));
+		    Music *start = unsmob_music (start_event);
+		    start->set_spot (@$);
+                    start->set_property ("numerator", scm_int2num (n));
+                    start->set_property ("denominator", scm_int2num (d));
+		    start_event = scm_call_1 (ly_lily_module_constant ("make-event-chord"), scm_list_1 (start_event));
+		    unsmob_music (start_event)->set_spot (@$);
+		    
+		    SCM stop_event = scm_call_2 (ly_lily_module_constant ("make-span-event"), tuplet_symbol, scm_from_int (STOP));
+		    unsmob_music (stop_event)->set_spot (@$);
+		    stop_event = scm_call_1 (ly_lily_module_constant ("make-event-chord"), scm_list_1 (stop_event));
+		    unsmob_music (stop_event)->set_spot (@$);
+
+                    $$ = MY_MAKE_MUSIC ("SequentialMusic");
+                    $$->set_property ("elements", scm_list_3 (start_event, mp->self_scm (), stop_event));
+                  }
 	}
 	| Repeated_music		{ $$ = $1; }
 	| TRANSPOSE pitch_also_in_chords pitch_also_in_chords Music {
--- ../lilypond29/lily/include/percent-repeat-iterator.hh	2006-01-06 10:13:24.000000000 +0100
+++ lily/include/percent-repeat-iterator.hh	2006-05-14 16:01:53.000000000 +0200
@@ -9,28 +9,20 @@
 #ifndef PERCENT_REPEAT_ITERATOR_HH
 #define PERCENT_REPEAT_ITERATOR_HH
 
-#include "music-iterator.hh"
+#include "sequential-iterator.hh"
 
-class Percent_repeat_iterator : public Music_iterator
+class Percent_repeat_iterator : public Sequential_iterator
 {
 public:
   DECLARE_CLASSNAME(Percent_repeat_iterator);
   DECLARE_SCHEME_CALLBACK (constructor, ());
   Percent_repeat_iterator ();
 protected:
-  virtual void derived_substitute (Context *f, Context *t);
-
+  virtual SCM get_music_list () const;
   virtual void derived_mark () const;
-  virtual Moment pending_moment () const;
-  virtual void do_quit ();
   virtual void construct_children ();
-  virtual bool ok () const;
-  virtual void process (Moment);
-  virtual Music_iterator *try_music_in_children (Music *) const;
-
 private:
-  Music_iterator *child_iter_;
-  Moment finish_mom_;
+  SCM child_list_;
 };
 
 #endif /* PERCENT_REPEAT_ITERATOR_HH */
