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

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

Re: Gérer les silences d'église


From: Xavier Scheuer
Subject: Re: Gérer les silences d'église
Date: Wed, 14 Mar 2012 23:24:16 +0100

2012/3/10 legoss <address@hidden>:
> Merci pour l'éclaircissement. En fait je m'étais pris les pieds dans le bord
> du tapis en confondant "voiceOne" et "oneVoice".

Bonsoir,

On peut aussi conserver le fichier initial, sans silences invisibles
ou voix supplémentaires, sans devoir jongler avec les \voiceOne et
autres \oneVoice .

Pour cela j'utiliserais les "Merge Rests Engravers" développés par
Jay Anderson en réponse au bug #1228 .
http://lists.gnu.org/archive/html/lilypond-user/2012-02/msg00793.html
http://code.google.com/p/lilypond/issues/detail?id=1228

%%%% Snippet

\version "2.15.30"

%% merge-rests-engraver and merge-mmrests-engraver provided by
%% Jay Anderson
%% http://lists.gnu.org/archive/html/lilypond-user/2012-02/msg00793.html
%% See also issue #1228
%% http://code.google.com/p/lilypond/issues/detail?id=1228

#(define has-one-or-less (lambda (lst) (or (null? lst) (null? (cdr lst)))))
#(define has-at-least-two (lambda (lst) (not (has-one-or-less lst))))
#(define (all-equal lst pred)
  (or (has-one-or-less lst)
      (and (pred (car lst) (cadr lst)) (all-equal (cdr lst) pred))))

#(define merge-rests-engraver
   (lambda (context)
     (let ((rest-same-length
             (lambda (rest-a rest-b)
               (eq? (ly:grob-property rest-a 'duration-log)
(ly:grob-property rest-b 'duration-log))))
           (rests '()))
     `((start-translation-timestep . ,(lambda (trans)
                                        (set! rests '())))
       (stop-translation-timestep . ,(lambda (trans)
                                       (if (and (has-at-least-two
rests) (all-equal rests rest-same-length))
                                         (for-each
                                           (lambda (rest)
(ly:grob-set-property! rest 'Y-offset 0))
                                           rests))))
       (acknowledgers
         (rest-interface . ,(lambda (engraver grob source-engraver)
                              (if (eq? 'Rest (assoc-ref
(ly:grob-property grob 'meta) 'name))
                                (set! rests (cons grob rests))))))))))

#(define merge-mmrests-engraver
   (lambda (context)
     (let* ((mmrest-same-length
              (lambda (rest-a rest-b)
                (eq? (ly:grob-property rest-a 'measure-count)
(ly:grob-property rest-b 'measure-count))))
            (merge-mmrests
              (lambda (rests)
                (if (all-equal rests mmrest-same-length)
                  (let ((offset (if (eq? (ly:grob-property (car rests)
'measure-count) 1) 1 0)))
                    (for-each
                      (lambda (rest) (ly:grob-set-property! rest
'Y-offset offset))
                      rests)))))
            (curr-rests '())
            (rests '()))
     `((start-translation-timestep . ,(lambda (trans)
                                        (set! curr-rests '())))
       (stop-translation-timestep . ,(lambda (trans)
                                       (if (has-at-least-two curr-rests)
                                         (set! rests (cons curr-rests rests)))))
       (finalize . ,(lambda (translator)
                      (for-each merge-mmrests rests)))
       (acknowledgers
         (rest-interface . ,(lambda (engraver grob source-engraver)
                              (if (eq? 'MultiMeasureRest (assoc-ref
(ly:grob-property grob 'meta) 'name))
                                (set! curr-rests (cons grob curr-rests))))))))))

global = {\compressFullBarRests
  \override MultiMeasureRest #'expand-limit = #1 }

voixI = \relative c' {
  R1*4 g'1 a g
}
voixII = \relative c' {
  R1*4 e1 f e
}
voixIII = \relative c' {
  R1*4 c1 ~ c ~ c
}
voixIIII = \relative c' {
  R1*4 c,1 f c
}
paroles = \lyricmode {
 a b c d
}

\score {
  \new ChoirStaff
  <<
    \new Staff <<
      \new Voice = one {
        \voiceOne
        \global \voixI
      }
      \new Voice = two {
        \voiceTwo
        \global \voixII
      }
    >>
    \new Lyrics \lyricsto "one" { \paroles }
    \new Staff << \clef bass
      \new Voice = one {
        \voiceOne
        \global \voixIII
      }
      \new Voice = two {
        \voiceTwo
        \global \voixIIII
      }
    >>
  >>
  \layout {
    \context {
      \Staff
      \consists #merge-rests-engraver
      \consists #merge-mmrests-engraver
    }
  }
}

%%%% End of snippet

Cordialement,
Xavier

-- 
Xavier Scheuer <address@hidden>



reply via email to

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