On Wednesday 05 April 2006 13:19, Erik Sandberg wrote:
> On Tuesday 04 April 2006 20.42, Han-Wen Nienhuys wrote:
> > I'd start with 4. because they're independent from the rest, and we can
> > readily test the rest of those.
>
> I'm now reworking repeats.
I'm more or less done with repeats now. Patch attached.
Known issue: unfold-repeats will probably not work for percent repeats. (the
repeat will be unfolded, but percents will still remain). I'd suggest to fix
this by scrapping percent-repeat-iterator, and to create a SequentialMusic of
percent-repeat-events instead. So
\repeat percent 4 c4
=>
{c4 <pre> <pre> <pre> }
where <pre> is a percent-repeat-event. This requires that
percent-repeat-engraver and slash-repeat-engraver are changed (simplified) as
well.
BTW, is there any particular reason why percent-repeat-engraver and
slash-repeat-engraver are not merged?
BTW2, percent/slash repeats look a bit ugly in current CVS: The slash is far
too thick.
--
Erik
? .sconf_temp
? build-stamp
? context-unique.diff
? debug
? def-rel-music-funciton.diff
? delay-music-functions.diff
? exjobb.diff3
? fonts
? lib
? lilypond.kdevelop
? lilypond.kdevelop.pcs
? lilypond.kdevses
? optimized
? ref1.diff
? ref2.diff
? repeat.diff
? scons.cache
? Documentation/out
? Documentation/out-www
? Documentation/bibliography/out
? Documentation/bibliography/out-www
? Documentation/misc/out
? Documentation/misc/out-www
? Documentation/pictures/out
? Documentation/pictures/out-www
? Documentation/topdocs/out
? Documentation/topdocs/out-www
? Documentation/user/out
? Documentation/user/out-www
? buildscripts/out
? buildscripts/out-www
? cygwin/out
? cygwin/out-www
? debian/out
? debian/out-www
? elisp/out
? elisp/out-www
? flower/out
? flower/out-scons
? flower/out-www
? flower/include/.sconsign
? flower/include/out
? flower/include/out-www
? input/Diagram1.dia.autosave
? input/les-nereides.pdf
? input/les-nereides.ps
? input/out
? input/out-www
? input/mutopia/out
? input/mutopia/out-www
? input/mutopia/E.Satie/out
? input/mutopia/E.Satie/out-www
? input/mutopia/F.Schubert/out
? input/mutopia/F.Schubert/out-www
? input/mutopia/J.S.Bach/out
? input/mutopia/J.S.Bach/out-www
? input/mutopia/R.Schumann/out
? input/mutopia/R.Schumann/out-www
? input/mutopia/W.A.Mozart/out
? input/mutopia/W.A.Mozart/out-www
? input/no-notation/out
? input/no-notation/out-www
? input/no-notation/to-xml.pdf
? input/no-notation/to-xml.ps
? input/regression/chord-tremolo.pdf
? input/regression/chord-tremolo.ps
? input/regression/out
? input/regression/out-www
? input/template/out
? input/test/out
? input/test/out-www
? input/tutorial/out
? input/tutorial/out-www
? kpath-guile/out
? kpath-guile/out-scons
? kpath-guile/out-www
? lily/On
? lily/foo.pdf
? lily/foo.ps
? lily/lilypond
? lily/lilypond.gdt
? lily/lilypond.gpr
? lily/out
? lily/out-scons
? lily/out-www
? lily/include/.sconsign
? lily/include/out
? lily/include/out-www
? ly/out
? ly/out-www
? make/out
? make/out-www
? mf/feta-alphabet11.600pk
? mf/feta-alphabet13.600pk
? mf/feta-alphabet14.600pk
? mf/feta-alphabet16.600pk
? mf/feta-alphabet18.600pk
? mf/feta-alphabet20.600pk
? mf/feta-alphabet23.600pk
? mf/feta-alphabet26.600pk
? mf/feta-braces-a.600pk
? mf/feta-braces-b.600pk
? mf/feta-braces-c.600pk
? mf/feta-braces-d.600pk
? mf/feta-braces-e.600pk
? mf/feta-braces-f.600pk
? mf/feta-braces-g.600pk
? mf/feta-braces-h.600pk
? mf/feta-braces-i.600pk
? mf/feta11.600pk
? mf/feta13.600pk
? mf/feta14.600pk
? mf/feta16.600pk
? mf/feta18.600pk
? mf/feta20.600pk
? mf/feta23.600pk
? mf/feta26.600pk
? mf/out
? mf/out-scons
? mf/out-www
? mf/parmesan11.600pk
? mf/parmesan13.600pk
? mf/parmesan14.600pk
? mf/parmesan16.600pk
? mf/parmesan18.600pk
? mf/parmesan20.600pk
? mf/parmesan23.600pk
? mf/parmesan26.600pk
? po/out
? po/out-www
? ps/out
? ps/out-www
? python/convertrules.pyc
? python/fontextract.pyc
? python/lilylib.pyc
? python/out
? python/out-www
? scm/define-event-classes.scm
? scm/out
? scm/out-www
? scripts/lilypond-book-36.py
? scripts/lilypond-book.py.new
? scripts/out
? scripts/out-www
? stepmake/out
? stepmake/out-www
? stepmake/bin/out
? stepmake/bin/out-www
? stepmake/bin/packagepython.pyc
? stepmake/stepmake/out
? stepmake/stepmake/out-www
? tex/out
? tex/out-www
? ttftool/out
? ttftool/out-scons
? ttftool/out-www
? ttftool/include/.sconsign
? ttftool/include/out
? ttftool/include/out-www
? vim/out
? vim/out-www
Index: lily/folded-repeat-iterator.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/folded-repeat-iterator.cc,v
retrieving revision 1.42
diff -u -r1.42 folded-repeat-iterator.cc
--- lily/folded-repeat-iterator.cc 26 Jan 2006 11:17:01 -0000 1.42
+++ lily/folded-repeat-iterator.cc 10 May 2006 06:02:12 -0000
@@ -56,13 +56,6 @@
void
Folded_repeat_iterator::process (Moment m)
{
- if (!m.to_bool ())
- {
- bool success = try_music (get_music ());
- if (!success)
- get_music ()->origin ()->warning (_ ("no one to print a repeat brace"));
- }
-
if (main_iter_)
{
main_iter_->process (m);
Index: lily/parser.yy
===================================================================
RCS file: /sources/lilypond/lilypond/lily/parser.yy,v
retrieving revision 1.511
diff -u -r1.511 parser.yy
--- lily/parser.yy 7 Apr 2006 01:05:57 -0000 1.511
+++ lily/parser.yy 10 May 2006 06:02:12 -0000
@@ -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,25 @@
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
+ {
+ Music *br = MY_MAKE_MUSIC ("TupletSpannerEvent");
+ br->set_spot (@$);
+ br->set_property ("numerator", scm_int2num (n));
+ br->set_property ("denominator", scm_int2num (d));
+ br->set_property ("length", mp->get_length ().smobbed_copy ());
+ Music *ev = MY_MAKE_MUSIC ("EventChord");
+ ev->set_property ("elements", scm_cons (br->self_scm (), SCM_EOL));
+ Music *sim = MY_MAKE_MUSIC ("SimultaneousMusic");
+ sim->set_property ("elements", scm_list_2 (ev->self_scm (), mp->self_scm ()));
+ sim->set_spot (@$);
+ $$ = context_spec_music (ly_symbol2scm ("Bottom"),
+ SCM_UNDEFINED, sim, SCM_EOL, false);
+ }
}
| Repeated_music { $$ = $1; }
| TRANSPOSE pitch_also_in_chords pitch_also_in_chords Music {
Index: lily/percent-repeat-engraver.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/percent-repeat-engraver.cc,v
retrieving revision 1.56
diff -u -r1.56 percent-repeat-engraver.cc
--- lily/percent-repeat-engraver.cc 9 May 2006 08:21:17 -0000 1.56
+++ lily/percent-repeat-engraver.cc 10 May 2006 06:02:12 -0000
@@ -87,14 +87,12 @@
bool
Percent_repeat_engraver::try_music (Music *m)
{
- if (m->is_mus_type ("repeated-music")
- && m->get_property ("iterator-ctor")
- == Percent_repeat_iterator::constructor_proc
+ if (m->is_mus_type ("percent-repeat-event")
&& !repeat_)
{
- body_length_ = Repeated_music::body_get_length (m);
- total_count_ = Repeated_music::repeat_count (m);
-
+ body_length_ = m->get_length ();
+ total_count_ = scm_to_int (m->get_property ("repeat-count"));
+
Moment now = now_mom ();
start_mom_ = now;
stop_mom_ = start_mom_ + Moment (total_count_) * body_length_;
@@ -103,7 +101,7 @@
Moment meas_len (robust_scm2moment (get_property ("measureLength"),
Moment (1)));
-
+
if (meas_len == body_length_)
repeat_sign_type_ = MEASURE;
else if (Moment (2) * meas_len == body_length_)
@@ -265,7 +263,7 @@
"DoublePercentRepeatCounter",
/* accept */
- "repeated-music",
+ "percent-repeat-event",
/* read */
"measureLength "
Index: lily/percent-repeat-iterator.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/percent-repeat-iterator.cc,v
retrieving revision 1.26
diff -u -r1.26 percent-repeat-iterator.cc
--- lily/percent-repeat-iterator.cc 26 Jan 2006 11:16:51 -0000 1.26
+++ lily/percent-repeat-iterator.cc 10 May 2006 06:02:12 -0000
@@ -43,15 +43,6 @@
void
Percent_repeat_iterator::process (Moment m)
{
- if (!m.to_bool ())
- {
- Music_iterator *yeah = try_music (get_music ());
- if (yeah)
- set_context (yeah->get_outlet ());
- else
- get_music ()->origin ()->warning (_ ("no one to print a percent"));
- }
-
if (child_iter_->ok ())
child_iter_->process (m);
Index: lily/slash-repeat-engraver.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/slash-repeat-engraver.cc,v
retrieving revision 1.29
diff -u -r1.29 slash-repeat-engraver.cc
--- lily/slash-repeat-engraver.cc 6 Jan 2006 09:13:25 -0000 1.29
+++ lily/slash-repeat-engraver.cc 10 May 2006 06:02:12 -0000
@@ -59,13 +59,10 @@
bool
Slash_repeat_engraver::try_music (Music *m)
{
- if (m->is_mus_type ("repeated-music")
- && !repeat_
- && m->get_property ("iterator-ctor")
- == Percent_repeat_iterator::constructor_proc)
+ if (m->is_mus_type ("percent-repeat-event"))
{
- body_length_ = Repeated_music::body_get_length (m);
- int count = Repeated_music::repeat_count (m);
+ body_length_ = m->get_length ();
+ int count = scm_to_int (m->get_property ("repeat-count"));
Moment now = now_mom ();
start_mom_ = now;
@@ -114,6 +111,6 @@
ADD_TRANSLATOR (Slash_repeat_engraver,
/* doc */ "Make beat repeats.",
/* create */ "RepeatSlash",
- /* accept */ "repeated-music",
+ /* accept */ "percent-repeat-event",
/* read */ "measureLength",
/* write */ "");
Index: lily/tuplet-engraver.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/tuplet-engraver.cc,v
retrieving revision 1.94
diff -u -r1.94 tuplet-engraver.cc
--- lily/tuplet-engraver.cc 11 Feb 2006 11:35:17 -0000 1.94
+++ lily/tuplet-engraver.cc 10 May 2006 06:02:12 -0000
@@ -52,23 +52,19 @@
bool
Tuplet_engraver::try_music (Music *music)
{
- if (music->is_mus_type ("time-scaled-music"))
+ if (music->is_mus_type ("tuplet-spanner-event"))
{
- Music *el = unsmob_music (music->get_property ("element"));
- if (el && !el->is_mus_type ("event-chord"))
- {
- Tuplet_description d;
- d.music_ = music;
- d.length_ = music->get_length ().main_part_;
- d.stop_ = now_mom ().main_part_ + d.length_;
- d.span_stop_ = d.stop_;
-
- SCM s = get_property ("tupletSpannerDuration");
- if (unsmob_moment (s))
- d.span_stop_ = min (d.span_stop_, (now_mom () + *unsmob_moment (s)).main_part_);
+ Tuplet_description d;
+ d.music_ = music;
+ d.length_ = music->get_length ().main_part_;
+ d.stop_ = now_mom ().main_part_ + d.length_;
+ d.span_stop_ = d.stop_;
+
+ SCM s = get_property ("tupletSpannerDuration");
+ if (unsmob_moment (s))
+ d.span_stop_ = min (d.span_stop_, (now_mom () + *unsmob_moment (s)).main_part_);
- tuplets_.push_back (d);
- }
+ tuplets_.push_back (d);
return true;
}
return false;
@@ -189,8 +185,8 @@
ADD_ACKNOWLEDGER (Tuplet_engraver, note_column);
ADD_TRANSLATOR (Tuplet_engraver,
- /* doc */ "Catch Time_scaled_music and generate appropriate bracket ",
+ /* doc */ "Catch TupletSpannerEvent and generate appropriate bracket ",
/* create */ "TupletBracket TupletNumber",
- /* accept */ "time-scaled-music",
+ /* accept */ "tuplet-spanner-event",
/* read */ "tupletNumberFormatFunction tupletSpannerDuration tupletFullLength",
/* write */ "");
Index: lily/volta-engraver.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/volta-engraver.cc,v
retrieving revision 1.75
diff -u -r1.75 volta-engraver.cc
--- lily/volta-engraver.cc 26 Jan 2006 11:16:41 -0000 1.75
+++ lily/volta-engraver.cc 10 May 2006 06:02:12 -0000
@@ -22,7 +22,7 @@
/*
Create Volta spanners, by reading repeatCommands property, usually
- set by Unfolded_repeat_iterator.
+ set by Volta_repeat_iterator.
*/
class Volta_engraver : public Engraver
{
Index: scm/define-music-types.scm
===================================================================
RCS file: /sources/lilypond/lilypond/scm/define-music-types.scm,v
retrieving revision 1.78
diff -u -r1.78 define-music-types.scm
--- scm/define-music-types.scm 9 May 2006 02:15:57 -0000 1.78
+++ scm/define-music-types.scm 10 May 2006 06:02:12 -0000
@@ -398,6 +398,12 @@
(iterator-ctor . ,ly:property-unset-iterator::constructor)
))
+ (PercentRepeatEvent
+ . (
+ (description . "Used internally to signal percent repeats.")
+ (types . (general-music percent-repeat-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.
[EMAIL PROTECTED] 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))
))
+ (TupletSpannerEvent
+ . (
+ (description . "Used internally to signal tuplet brackets.")
+ (types . (tuplet-spanner-event event general-music))
+ ))
+
(UnrelativableMusic
. (
(description . "Music that can not be converted from relative to absolute notation.
Index: scm/music-functions.scm
===================================================================
RCS file: /sources/lilypond/lilypond/scm/music-functions.scm,v
retrieving revision 1.168
diff -u -r1.168 music-functions.scm
--- scm/music-functions.scm 9 May 2006 02:15:57 -0000 1.168
+++ scm/music-functions.scm 10 May 2006 06:02:12 -0000
@@ -202,6 +202,49 @@
(music-map (lambda (x) (shift-one-duration-log x shift dot))
music))
+(define (truncate-list! ls n)
+ "destructively truncate a list to n elements"
+ (set-cdr! (list-tail ls (1- n)) '())
+ ls)
+
+(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"))
+ (truncate-list! 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)
+ (cond
+ ((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))))
+ ((equal? name "percent")
+ (let* ((percent (make-music 'PercentRepeatEvent
+ 'repeat-count times
+ 'length (ly:music-length main)))
+ (chord (make-event-chord (list percent)))
+ (sim (make-simultaneous-music (list r chord))))
+ (context-spec-music sim 'Bottom)))
+ (else r))))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; clusters.
_______________________________________________
lilypond-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-devel