lilypond-user
[Top][All Lists]
Advanced

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

Re: Scaled grace


From: Malte Meyn
Subject: Re: Scaled grace
Date: Tue, 21 Mar 2017 11:44:01 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0


Am 21.03.2017 um 11:04 schrieb Urs Liska:
> 
> 
> 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?

Yes. I would prefer a duration (\scaledGrace 4) over a rational number
{\scaledGrace 1/4) but that’s easy to change:

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

Or you just assume that if you really want to synchronize graces in this
way all graces in all voices start at the same time. (I think that’s
probable. If you don’t have simultaneously starting graces they probably
are notated in a way that needs no scaling, therefore \grace is
sufficient.) Then you could use a default value of 1:

scaledGrace =
#(define-music-function (mus) (ly:music?)
  (let* ((real-len (ly:music-length mus))
         (ratio (cons (ly:moment-main-denominator real-len)
                  (ly:moment-main-numerator real-len))))
    #{
      \grace \scaleDurations #ratio #mus
    #}))

Or if you don’t want variants for all \grace variants (i. e. \grace,
\slashedGrace, \appoggiatura, \acciaccatura, \afterGrace), just make a
function that takes a music expression and scales it to 1. Maybe this
could also be nice for cadenza-like things in real time notes (if you
combine it with \newSpacingSection or a duration argument):

\version "2.19.56"

autoScale =
#(define-music-function (mus) (ly:music?)
   (let* ((real-len (ly:music-length mus))
          (ratio (cons (ly:moment-main-denominator real-len)
                   (ly:moment-main-numerator real-len))))
     #{
       \scaleDurations #ratio #mus
     #}))

{
  <<
    {
      c''2
      \grace \autoScale {
        c''16 [ d'' e'' ]
      }
      f''2
    }
    \\
    {
      c'2
      \appoggiatura \autoScale {
        c'16 b c' d' e'
      }
      f'2
    }
  >>
}



reply via email to

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