From 309a9435d778ed2db26363f6be32e6a100cd630d Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Wed, 25 May 2005 10:22:34 +0000 Subject: [PATCH] * scm/define-music-properties.scm (all-music-properties): document length-callback and start-callback as "read-only". * scm/music-functions.scm (unfold-repeats): rewrite. Cannot set length-callback after creation. --- ChangeLog | 6 ++++++ lily/global-context.cc | 4 +++- scm/define-grobs.scm | 2 +- scm/define-music-properties.scm | 15 +++++++++------ scm/lily-library.scm | 7 +++++++ scm/music-functions.scm | 24 +++++++++++++----------- 6 files changed, 39 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index dbd9be457c..acf72389c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2005-05-25 Han-Wen Nienhuys + * scm/define-music-properties.scm (all-music-properties): document + length-callback and start-callback as "read-only". + + * scm/music-functions.scm (unfold-repeats): rewrite. Cannot set + length-callback after creation. + * scripts/convert-ly.py (conv): unfoldrepeats -> unfoldRepeats, compressmusic -> compressMusic. diff --git a/lily/global-context.cc b/lily/global-context.cc index 3a251eb891..df9187d1e5 100644 --- a/lily/global-context.cc +++ b/lily/global-context.cc @@ -155,7 +155,8 @@ Global_context::run_iterator_on_me (Music_iterator *iter) if (!get_score_context ()) { SCM sym = ly_symbol2scm ("Score"); - Context_def *t = unsmob_context_def (find_context_def (get_output_def (), sym)); + Context_def *t = unsmob_context_def (find_context_def (get_output_def (), + sym)); if (!t) error (_f ("can't find `%s' context", "Score")); @@ -177,6 +178,7 @@ Global_context::apply_finalizations () SCM lst = get_property ("finalizations"); set_property ("finalizations", SCM_EOL); for (SCM s = lst; scm_is_pair (s); s = scm_cdr (s)) + /* TODO: make safe. */ scm_primitive_eval (scm_car (s)); } diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 6c535a8c76..4e0d9708c7 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -861,7 +861,7 @@ (before-line-breaking-callback . ,Paper_column::before_line_breaking) (X-extent-callback . ,Axis_group_interface::group_extent_callback) -; (print-function . ,Paper_column::print) (font-name . "ecrm8") (Y-extent-callback . #f) + (print-function . ,Paper_column::print) (font-name . "ecrm8") (Y-extent-callback . #f) (meta . ((interfaces . (paper-column-interface axis-group-interface spaceable-grob-interface item-interface )))) )) diff --git a/scm/define-music-properties.scm b/scm/define-music-properties.scm index 9d789dbbd1..ef68b93f24 100644 --- a/scm/define-music-properties.scm +++ b/scm/define-music-properties.scm @@ -58,7 +58,8 @@ e.g. @code{\\tag #'part ...} could tag a piece of music as only being active in (label ,markup? "label of a mark.") (last-pitch ,ly:pitch? "The last pitch after relativization.") (length ,ly:moment? "The duration of this music") - (length-callback ,procedure? "How to compute the duration of this music") + (length-callback ,procedure? "How to compute the duration of this music. This property +can only be defined as initializer in @file{define-music-types.scm}.") (internal-class-name ,string? "C++ class to use for this Music object") (name ,symbol? "Name of this music object") (numerator ,integer? "numerator of a time signature") @@ -73,7 +74,8 @@ For chord inversions, this is negative.") (pitch-alist ,list? "list of pitches jointly forming the scale of a key signature") (pop-first ,boolean? "Do a revert before we try to do a override on some grob property.") (procedure ,procedure? - "The function to run with \\applycontext. It must take a single argument, being the context.") + "The function to run with \\applycontext. +It must take a single argument, being the context.") (property-operations ,list? "Do these operations for instantiating the context.") (predicate ,procedure? "the predicate of a \\outputproperty.") @@ -86,9 +88,10 @@ For chord inversions, this is negative.") (repeat-count ,integer? "do a @code{\repeat} how ofen?") (span-direction ,ly:dir? "Does this start or stop a spanner?") (split-list ,list? "splitting moments for part combiner.") - (start-callback ,procedure? "Function to compute the negative length of -starting grace notes.") - (string-number ,integer? "The number of the string in a String_number_req") + (start-callback ,procedure? "Function to compute the negative +length of starting grace notes. This property can only be defined as +initializer in @file{define-music-types.scm}.") + (string-number ,integer? "The number of the string in a StringNumberEvent") (symbol ,symbol? "Grob name to perform an override/revert on.") (text ,markup? "markup expression to be printed") (tremolo-type ,integer? "") @@ -106,7 +109,7 @@ solo1, solo2 and unisono") a string) for figured bass") (alteration ,number? "alteration for figured bass") (bracket-start ,boolean? "start a bracket -here. TODO: use span requests?") +here. TODO: use SpanEvents?") (bracket-stop ,boolean? "stop a bracket here.") (untransposable ,boolean? "If set, this music is not transposed.") ))) diff --git a/scm/lily-library.scm b/scm/lily-library.scm index 3f77e9a174..4683ccead2 100644 --- a/scm/lily-library.scm +++ b/scm/lily-library.scm @@ -134,6 +134,13 @@ found." (let ((k (assoc (car keys) lst))) (if k k (first-assoc (cdr keys) lst))))) +(define-public (flatten-alist alist) + (if (null? alist) + '() + (cons (caar alist) + (cons (cdar alist) + (flatten-alist (cdr alist)))))) + ;;;;;;;;;;;;;;;; ;; vector (define-public (vector-for-each proc vec) diff --git a/scm/music-functions.scm b/scm/music-functions.scm index bab748a7c0..45f3fada95 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -213,14 +213,21 @@ Returns `obj'. (define-public (unfold-repeats music) " This function replaces all repeats with unfold repeats. " - + (let ((es (ly:music-property music 'elements)) (e (ly:music-property music 'element)) ) (if (memq 'repeated-music (ly:music-property music 'types)) - (begin - (if (equal? (ly:music-property music 'iterator-ctor) - Chord_tremolo_iterator::constructor) + (let* + ((props (ly:music-mutable-properties music)) + (old-name (ly:music-property music 'name)) + (flattened (flatten-alist props))) + + (set! music (apply make-music (cons 'UnfoldedRepeatedMusic + flattened))) + + (display old-name) + (if (equal? old-name 'TremoloRepeatedMusic) (let* ((seq-arg? (memq 'sequential-music (ly:music-property e 'types))) (count (ly:music-property music 'repeat-count)) @@ -234,14 +241,9 @@ This function replaces all repeats with unfold repeats. " (ly:intlog2 count)) dot-shift) (if seq-arg? - (ly:music-compress e (ly:make-moment (length (ly:music-property e 'elements)) 1))))) + (ly:music-compress e (ly:make-moment (length (ly:music-property + e 'elements)) 1))))))) - (set! (ly:music-property music 'length-callback) - Repeated_music::unfolded_music_length) - (set! (ly:music-property music 'start-callback) - Repeated_music::first_start) - (set! (ly:music-property music 'iterator-ctor) - Unfolded_repeat_iterator::constructor))) (if (pair? es) (set! (ly:music-property music 'elements) -- 2.39.2