Michael Meixner <[EMAIL PROTECTED]> writes:
> dottedHalf =
> #(define-music-function (parser location note)
> (ly:music?)
>
> (set! (ly:music-property
> (first (ly:music-property note 'elements)) 'duration)
> (ly:make-duration 1 1 1 1))
> note)
> 1) Could this be simplified with " ly:music-set-property!" ?
Using (set! (accessor object) value) is the idiomatic way to set some
place. Behind the scene, (set! (ly:music-property ...) ...) uses
ly:music-set-property!.
> 2) In the case of a chord, e.g. "{ \dottedHalf <c' e'>4 }" in the
> above example, this doesn't work, because the function "catches" the
> first NoteEvent only, so I would need to "drill" (recursively?) into
> the EventChord. Are there any examples showing this? (So far I only
> found examples of ADDING things to an EventChord, but not replacing).
Map a function setting the duration on events having a duration
property.
(for-each (lambda (event)
(if (not (null? (ly:music-property event 'duration)))
(set! (music-property event 'duration)
(ly:make-duration 1 1 1 1))))
(ly:music-property chord 'elements)
[not tested]
> [Additional question: "first" is a GUILE feature?]
first is defined in srfi-1 AFAIR: see the guile manual. When you want
to access the first, second, third, etc element of a list, use the
function that have this semantic: first, second, third, etc. The
functions car, cadr, caddr, etc, do the same thing, but have a different
semantic: access elements of a cons cell tree.
nicolas
_______________________________________________
lilypond-user mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-user