lilypond-user
[Top][All Lists]
Advanced

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

Scaled grace (was: What can Premusic do that others can't?)


From: Urs Liska
Subject: Scaled grace (was: What can Premusic do that others can't?)
Date: Tue, 21 Mar 2017 11:04:33 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0


Am 21.03.2017 um 10:46 schrieb Malte Meyn:
> (By the way: I think that the way LilyPond handles it (using “grace” and
> “real time”) is pretty good but not perfect. \grace only needs grace
> time but \afterGrace needs real time for vertical alignment (but not for
> input of the notes)—it would be nice to have 1. \grace before barlines
> and 2. grace/afterGrace notes that are vertically aligned indepentently
> from real time notes if you don’t want them between the real notes. And
> maybe 3. some function that helps to align f. e. 7 grace notes in the
> right and 6 in the left hand without having to scale them by hand -> a
> function that takes notes and scales them so that they get a given total
> length. Maybe if I find some time I’ll make some sketches that
> illustrate 2. and pseudo code that illustrates 3.)


Something like this?

\version "2.19.54"

scaledGrace =
#(define-music-function (duration mus)(fraction? ly:music?)
   (let* ((real-len (ly:music-length mus))
         (dur (ly:make-moment (/ (car duration) (cdr duration))))
         (ratio-mom (ly:moment-div dur real-len))
         (ratio (cons (ly:moment-main-numerator ratio-mom)
                  (ly:moment-main-denominator ratio-mom))))
     #{
       \grace \scaleDurations #ratio #mus
     #}))

{
  <<
    {
      c''2
      \scaledGrace 1/4 {
        c''16 [ d'' e'' ]
      }
      f''2
    }
    \\
    {
      c'2
      \scaledGrace 1/4 {
        c'16 b c' d' e'
      }
      f'2
    }
  >>
}





reply via email to

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