lilypond-user-fr
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: \autochange


From: Valentin Villenave
Subject: Re: \autochange
Date: Fri, 22 Oct 2010 12:08:26 +0200

2010/10/22 Philhar <address@hidden>:
> le 2ème), et non au-dessus de la portée du bas.
> Dans un autre passage du même genre, un si doit rester lié à la portée
> supérieure. La commande le met logiquement sur la portée inférieure, puisque
> la note pivot est le do. Est-il possible d'imposer une autre  note pivot à
> la commande ?

En trafiquant un peu, oui.

#(define (sign x)
  (if (= x 0)
      0
      (if (< x 0) -1 1)))

#(define-public (make-autochange-music parser music . split-pitch)
  (define (generate-split-list change-moment event-list acc split-delta)
    (if (null? event-list)
        acc
        (let* ((now-tun (caar event-list))
               (evs (map car (cdar event-list)))
               (now (car now-tun))
               (notes (filter (lambda (x)
                                (equal? (ly:event-property  x 'class) 
'note-event))
                              evs))
               (pitch (if (pair? notes)
                          (ly:event-property (car notes) 'pitch)
                          #f)))
          ;; optional: do we have a different split-pitch?
          (if (and pitch split-delta)
              (set! pitch (ly:pitch-transpose pitch split-delta)))
          ;; tail recursive.
          (if (and pitch (not (= (ly:pitch-steps pitch) 0)))
              (generate-split-list #f
                                   (cdr event-list)
                                   (cons (cons

                                          (if change-moment
                                              change-moment
                                              now)
                                          (sign (ly:pitch-steps pitch))) acc)
                                   split-delta)
              (generate-split-list
               (if pitch #f now)
               (cdr event-list) acc split-delta)))))

  (let* ((m (make-music 'AutoChangeMusic))
         (m1 (make-non-relative-music (context-spec-music music 'Voice "one")))
         (context-list (recording-group-emulate music
                                                (ly:parser-lookup parser 
'partCombineListener)))
         (evs (car context-list))
         (rev (reverse! (cdar context-list)))
         (split-delta (if (ly:pitch? (car split-pitch))
                          (ly:pitch-negate (car split-pitch))
                          #f))
         (split (reverse! (generate-split-list
                           #f
                           rev
                           '()
                           split-delta)
                          '())))
    (set! (ly:music-property m 'element) music)
    (set! (ly:music-property m 'split-list) split)
    m))


autochangeWithPitch =
#(define-music-function (parser location ref music) (ly:music? ly:music?)
       (let* ((note (car (ly:music-property ref 'elements)))
              (ref-pitch (ly:music-property note 'pitch)))
   (make-autochange-music parser music
     (if (ly:pitch? ref-pitch) ref-pitch #f))))

\context PianoStaff <<
  \context Staff = "up" {
    \autochangeWithPitch a \new Voice << \relative c' {
        g4 c e d c r4 a g } >>
  }
  \context Staff = "down" {
    \clef bass
    s1*2
  }
>>

Je vais proposer un patch à ce sujet.

Cordialement,
V. Villenave.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]