Skip to main content
edited body
Source Link
Lazy
  • 23.1k
  • 1
  • 16
  • 47

It would be possible to wrap each part in music functions that keep track of the time signatures (if we only have one part we would not in fact need this and would be able to do this on toplevel). There are some big caveats with this: This will fail if one autoRest is executed before a time command that takes effect before this onethe rest. This means that you need to specify time for each Element of Simultaneous Music, else you will not get the right duration.

It would be possible to wrap each part in music functions that keep track of the time signatures (if we only have one part we would not in fact need this and would be able to do this on toplevel). There are some big caveats with this: This will fail if one autoRest is executed before a time command that takes effect before this one. This means that you need to specify time for each Element of Simultaneous Music, else you will not get the right duration.

It would be possible to wrap each part in music functions that keep track of the time signatures (if we only have one part we would not in fact need this and would be able to do this on toplevel). There are some big caveats with this: This will fail if one autoRest is executed before a time command that takes effect before the rest. This means that you need to specify time for each Element of Simultaneous Music, else you will not get the right duration.

Source Link
Lazy
  • 23.1k
  • 1
  • 16
  • 47

It would be possible to wrap each part in music functions that keep track of the time signatures (if we only have one part we would not in fact need this and would be able to do this on toplevel). There are some big caveats with this: This will fail if one autoRest is executed before a time command that takes effect before this one. This means that you need to specify time for each Element of Simultaneous Music, else you will not get the right duration.

See this code for details how this could be done:

partA =
#(define-music-function () ()
   (let* ((measure-length 1)
          (old-time time)
          (time (define-music-function (d n) (number? number?)
                  (set! measure-length (/ d n))
                  (old-time (cons d n))))
          (aR (lambda* (#:optional (times 1))
                (make-music
                  'MultiMeasureRestMusic
                  'duration
                  (ly:make-duration 0 0 (* measure-length times))))))
     #{
       $(time 3 4)
       c'2. |
       $(aR) |
       $(time 5 4)
       $(aR 3) |
       d'4 e' c' f' g'
     #}))

partB =
#(define-music-function () ()
   (let* ((measure-length 1)
          (old-time time)
          (time (define-music-function (d n) (number? number?)
                  (set! measure-length (/ d n))
                  (old-time (cons d n))))
          (aR (lambda* (#:optional (times 1))
                (make-music
                  'MultiMeasureRestMusic
                  'duration
                  (ly:make-duration 0 0 (* measure-length times))))))
     #{
       $(time 3 4)
       e'4 f' d' |
       e' f' d' |
       $(time 5 4)
       c'2. d'2 |
       c'2. d'2 |
       c'2. b2 |
       $(aR)
     #}))

<<
  \new Staff \partA
  \new Staff \partB
>>