Nicolas Sceaux <[EMAIL PROTECTED]> writes: > Erik Sandberg <[EMAIL PROTECTED]> writes: > >> I don't understand what rule you are using. It produces some strange results, >> e.g. \tuplify \repeat unfold 12 c32*2/3 produces a "9" over it, not a 12 as >> would be expected. >> >> More importantly, I can't convince it to place a 6 over six c8*2/3:s, as in: >> >> 6 >> ------ >> |||||| >> ****** >> >> and {c16*2/3 c c} gets a 6, I expected a 3. Both cases occur in real music; >> 6/4 usually just means that one tuplet number is written above each 6 equally >> long notes.
Well, I can't find out how to do that, at least for tonight. The attached version simply uses the fraction part. > I don't know if this is possible (I'll figure out after having tried), > but setting a dont-tuplify property to the music seen in \noTuplify { ... } > might do it. Then, \tuplify could look at that property in order to > check if its music can be tuplified. A \notuplefy command has been added. The more I look at it, the less I am convinced that it saves key strokes to use \tuplefy with all the "*2/3", instead of \times 2/3 { ... } nicolas
\version "2.3.13" %% $Id: tuplefy.ly,v 1.3 2004/09/11 17:18:12 nicolas Exp nicolas $ #(use-modules (srfi srfi-1)) %% We add a `not-tuplefiable' music property #(let ((my-prop 'not-tuplefiable)) (set-object-property! my-prop 'music-type? boolean?) (set-object-property! my-prop 'music-doc "Set to #t if the sequence should not be tuplefied by \\tuplefy") (set! all-music-properties (cons my-prop all-music-properties))) #(define-public (tuplefiable-music? music) (let ((not-tuplefiable (ly:music-property music 'not-tuplefiable))) (or (null? not-tuplefiable) (not not-tuplefiable)))) #(define-public (music-duration music) "If `music' has a duration (for instance, a chord), return it; otherwise, return #f" (cond ((member 'rhythmic-event (ly:music-property music 'types)) (ly:music-property music 'duration)) ((member 'event-chord (ly:music-property music 'types)) (let ((dur-event (find (lambda (elt) (member 'rhythmic-event (ly:music-property elt 'types))) (ly:music-property music 'elements)))) (and dur-event (ly:music-property dur-event 'duration)))) (else #f))) #(define-public (tuplefy-sequence seq-music) (let ((current-tuple-numerator 1) (current-tuple-denominator 1) (current-tuple (list)) (result-notes (list))) ;; push a non tuplet chord into the result (define (push-not-tuple elt) (push-current-tuple-group) (set! result-notes (cons elt result-notes))) ;; push a tuplet chord (define (push-tuple chord) (let* ((duration (music-duration chord)) (length (ly:duration-log duration)) (dot-count (ly:duration-dot-count duration)) (dur-factor (ly:duration-factor duration)) (num (car dur-factor)) (den (cdr dur-factor))) (if (and (not (null? current-tuple)) (= num current-tuple-numerator) (= den current-tuple-denominator)) ;; a chord with same fraction than the previous chord ;; just push it in the tuplet accumulator (set! current-tuple (cons chord current-tuple)) ;; otherwise, push the existing accumulator (if not empty) in the result ;; and start a new accumulator, storing the new fraction. (begin (push-current-tuple-group) (set! current-tuple-numerator num) (set! current-tuple-denominator den) (set! current-tuple (list chord)))))) ;; push a tuplet group into the result (define (push-current-tuple-group) (if (not (null? current-tuple)) (begin (set! result-notes (cons (make-music 'TimeScaledMusic 'denominator current-tuple-denominator 'numerator current-tuple-numerator 'element (make-music 'SequentialMusic 'elements (reverse! current-tuple))) result-notes)) (set! current-tuple (list))))) ;; body (map (lambda (music) (if (member 'sequential-music (ly:music-property music 'types)) (begin ;; a inner sequential music (push-current-tuple-group) (set! result-notes (cons (if (tuplefiable-music? music) (tuplefy-sequence music) music) result-notes))) (let ((duration (music-duration music))) (if (and (tuplefiable-music? music) duration (not (= 1 (cdr (ly:duration-factor duration))))) ;; a tuple (push-tuple music) ;; not a tuple (push-not-tuple music))))) (ly:music-property seq-music 'elements)) (push-current-tuple-group) (make-music 'SequentialMusic 'elements (reverse! result-notes)))) tuplefy = #(def-music-function (location music) (ly:music?) (tuplefy-sequence music)) notuplefy = #(def-music-function (location music) (ly:music?) (set! (ly:music-property music 'not-tuplefiable) #t) music) \score { \context StaffGroup << \new Staff \relative c' { #(override-auto-beam-setting '(end * * * *) 1 4 'Staff) \set tupletSpannerDuration = #(ly:make-moment 1 4) \tuplefy { c4 c8*2/3 d16*2/3 e d8*2/3 f8*2/3 g16*2/3 a g8*2/3 \notuplefy r2*1/2 { c16*4/6 d e f e d c d e f e d } c2 } } \new Staff \relative c' { #(override-auto-beam-setting '(end * * * *) 1 4 'Staff) \set tupletSpannerDuration = #(ly:make-moment 1 4) c4 \times 2/3 { c8 d16 e d8 } \times 2/3 { f8 g16 a g8 } r2*1/2 \times 4/6 { c16 d e f e d c d e f e d } c2 } >> }
_______________________________________________ lilypond-devel mailing list [EMAIL PROTECTED] http://lists.gnu.org/mailman/listinfo/lilypond-devel