Hi,

On Thu, Dec 28, 2017 at 10:23 AM, Caagr98 <[email protected]> wrote:
> Sometimes when having a long section of staccato, it's a bit tedious to add 
> -. to all notes, so then it's useful to have a function which automatically 
> adds an articulation to all notes. I have one such function here:
>
> addArticulation =
> #(define-music-function (event music) (ly:event? ly:music?)
>    (music-map
>     (lambda (mus)
>      (if (music-is-of-type? mus 'note-event)
>       (if (not (memq 'articulations ; Don't add staccato if there already 
> exist an articulation
>                      (map car (ly:music-mutable-properties mus))))
>         (ly:music-set-property! mus 'articulations (list event))))
>      mus)
>     music))
>
> However, this function adds the articulation to all notes in chords (leading 
> to multiple staccato dots), which is not what I want. Is there any better way 
> to do this?
>

This works, but I'm guessing there's a better way:

\version "2.19.65"

addArticulation =
#(define-music-function (event music) (ly:event? ly:music?)
   (define (add mus)
     (if (not (memq 'articulations ; Don't add staccato if there
already exist an articulation
                (map car (ly:music-mutable-properties mus))))
         (ly:music-set-property! mus 'articulations (list event))))
   (for-some-music
    (lambda (mus)
      (cond
       ((music-is-of-type? mus 'event-chord) (add mus))
       ((music-is-of-type? mus 'note-event) (add mus))
       (else #f)))
    music)
   music)

{
  \addArticulation \staccato { c <c e g> d c' }
}

HTH,
David

_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to