On 2022-03-19 5:46 pm, Thomas Morley wrote:
Am So., 20. März 2022 um 00:02 Uhr schrieb Aaron Hill
<lilyp...@hillvisions.com>:
Here would be a possible refactoring:
%%%%
\version "2.22.0"
partial =
#(define-music-function (mus) (ly:music?)
(_i "Make a partial measure.")
(let* ((mom (ly:music-length mus))
(dur (make-duration-of-length mom)))
(make-music 'SequentialMusic
'elements
(list (context-spec-music
(make-music 'PartialSet
'origin (*location*)
'duration dur)
'Timing)
mus))))
\fixed c' {
\time 3/4
\partial { g8 a4 }
| g2. \bar "||"
\partial { \grace { g16 } a8 b }
| a2. \bar "||"
\partial \tuplet 3/2 { g8 fis }
| g2. \bar "|."
}
%%%%
A convert-ly rule would probably not be possible given the limited
power
of regular expressions. As such, \partial might need to support both
duration and music arguments. Initially I thought this might not be
possible, given that a naked duration can be treated as music; but the
following does seem to work:
%%%%
\version "2.22.0"
#(define (duration-or-music? arg)
(or (ly:duration? arg) (ly:music? arg)))
partial =
#(define-music-function (arg) (duration-or-music?)
(_i "Make a partial measure.")
(if (ly:duration? arg)
(context-spec-music
(make-music 'PartialSet
'origin (*location*)
'duration arg)
'Timing)
(let* ((mom (ly:music-length arg))
(dur (make-duration-of-length mom)))
(make-music 'SequentialMusic
'elements
(list (context-spec-music
(make-music 'PartialSet
'origin (*location*)
'duration dur)
'Timing)
arg)))))
\fixed c' {
\time 3/4
\partial 4. g8 a4 %% Original syntax works.
| g2. \bar "||"
\partial { \grace { g16 } a8 b }
| a2. \bar "||"
\partial \tuplet 3/2 { g8 fis }
| g2. \bar "|."
}
%%%%
-- Aaron Hill
Hi Aaron,
I really like it! Always wondered why we need to specify a duration,
if it can be taken from the music.
I'd suggest to propose it on devel. Preferable the second coding,
because we could nicely deprecate the old syntax for some versions.
*facepalm* I thought I was sending to devel. Well, folks on user might
want to chime in too.
-- Aaron Hill