lilypond-user
[Top][All Lists]
Advanced

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

Re: Leadsheet with cadenza / ad lib.


From: Valentin Petzel
Subject: Re: Leadsheet with cadenza / ad lib.
Date: Thu, 08 Jun 2023 15:28:57 +0200

Hello Stephan, hello Leo,

depending on the circumstances it might be useful to replace cadenzas with 
scaled duration such that the music fits a whole measue. Using a small helper 
function one might do something like this:

%%%%%
scaleMusicTo =
#(define-music-function (duration mus) (fraction? ly:music?)
   (let* ((mdur (ly:music-length mus))
          (mdur (/ (ly:moment-main-numerator mdur) (ly:moment-main-denominator 
mdur)))
          (tdur (/ (car duration) (cdr duration))))
     (scaleDurations (/ tdur mdur) mus)))

melody = \relative c'' {
   \global
   \scaleMusicTo 1/1 {
     \repeat unfold 19 { a16 }
   }
   R1\fermata
   \scaleMusicTo 1/1 {
     \repeat unfold 21 { f16 } f16\fermata
   }
   R1
   \fine
}
%%%%%

The disadvantage of this is of course that Lilypond is going to treat these 
note values as smaller note values than what is notated, which will affect 
spacing. Alternatively you could define your cadenzas outside and automatically 
have correct length rests and skips done:

%%%%%
cadenza =
#(define-music-function (n) (number?)
   #{
     \cadenzaOn
     $(assoc-get n cadenzas)
     \cadenzaOff
     \bar "|"
   #})

cadenzaD =
#(define-scheme-function (n) (number?)
   (let* ((c (assoc-get n cadenzas))
          (dur (ly:music-length c))
          (dur (/ (ly:moment-main-numerator dur) (ly:moment-main-denominator 
dur))))
     dur))

cadenzaR =
#(define-music-function (n) (number?)
   #{ R1*$(cadenzaD n) #})

cadenzaS =
#(define-music-function (n) (number?)
   #{ s1*$(cadenzaD n) #})

cadenzas.1 = \repeat unfold 19 { a16 }
cadenzas.2 = { \repeat unfold 21 { f16 } f16\fermata }


melody = \relative c'' {
   \global
   \cadenza 1
   R1\fermata
   \cadenza 2
   R1
   \fine
}

harmonies = \chordmode {
   \global
   \cadenzaS 1
   a1:m
   \cadenzaS 2
   f1:m
   \fine
}
%%%%%

But note that this still causes bugs, because cadenzas do not play well with 
multimeasure rests:

{
  \cadenzaOn
  c8
  \cadenzaOff
  \bar "|"
  R1
}

This is because Lilypond does not handle cadenzas as an arbitrary length 
measure, but simply stops timing. So instead of \cadenzaOn and \cadenzaOff you 
could automatically use a suitable \partial:

%%%%%
cadenza =
#(define-music-function (n) (number?)
   #{
     \partial #(ly:make-duration 0 0 (cadenzaD n))
     $(assoc-get n cadenzas)
   #})
%%%%%

Cheers,
Valentin

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

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