lilypond-user
[Top][All Lists]
Advanced

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

Re: Batch-apply tremolo markings? (Frescobaldi)


From: Thomas Morley
Subject: Re: Batch-apply tremolo markings? (Frescobaldi)
Date: Mon, 4 Jun 2018 23:16:49 +0200

2018-06-04 22:55 GMT+02:00 Aaron Hill <address@hidden>:
> On 2018-06-04 12:09, Ben wrote:
>>
>> Wow. Um, this is awesome. Yes it works beautifully. How difficult
>> would it be to allow this function to accept chords? Or would that
>> simply be best served as creating another function like \addTremChords
>> or something?
>
>
> Not that hard.  You just need to accept both NoteEvent and EventChord:
>
> %%%%
>   \version "2.19.81"
>   addTremolos =
>   #(define-music-function (number music) (integer? ly:music?)
>      (music-map
>       (lambda (mus)
>         (if (or (eq? 'NoteEvent (ly:music-property mus 'name))
>                 (eq? 'EventChord (ly:music-property mus 'name)))
>             (let ((art (ly:music-property mus 'articulations '())))
>               (ly:music-set-property!
>                mus
>                'articulations
>                (cons
>                 (make-music
>                  'TremoloEvent
>                  'tremolo-type number)
>                 art))))
>         mus)
>       music))
>   \addTremolos 16 { b' r a' <e' g'> }
> %%%%
>
> -- Aaron Hill

This will add the tremolo to each note of a chord and to the
'articulations of said EventChord, whereas by default it should sit in
the 'elements of the chord and not been added to the notes.
Although it seems to work in the minimal I'm not sure it will always
do (without undesired side-effects).

music-map is not the right tool anyway, it will always iterate deeper.
I'd prefer map-some-music and come up with the code below, build after
`addStacc'. I think it is originally coded by David Kastrup, can't
find it right now , though.

\version "2.19.81"

#(define (make-tremolo x)
   (make-music 'TremoloEvent
               'tremolo-type x))

#(define (add-tremolo x)
 (lambda (m)
   (case (ly:music-property m 'name)
     ((NoteEvent) (set! (ly:music-property m 'articulations)
                      (append (ly:music-property m 'articulations)
                         (list (make-tremolo x))))
                   m)
     ((EventChord)(set! (ly:music-property m 'elements)
                      (append (ly:music-property m 'elements)
                         (list (make-tremolo x))))
                   m)
     (else #f))))

addTrem = #(define-music-function (int music)
                 (index? ly:music?)
           (map-some-music (add-tremolo int) music))

\addTrem 32 {
  c'1
  R1
  <c' e'>1
}


Cheers,
  Harm



reply via email to

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