lilypond-user
[Top][All Lists]
Advanced

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

Re: addFingering


From: David Nalesnik
Subject: Re: addFingering
Date: Fri, 13 Jan 2017 20:03:19 -0600

On Fri, Jan 13, 2017 at 7:21 PM, David Nalesnik
<address@hidden> wrote:
> On Fri, Jan 13, 2017 at 11:50 AM, Gilles THIBAULT
> <address@hidden> wrote:
>> Le vendredi 13 janvier 2017, 14:06:23 Gianmaria Lari a écrit :
>>> I have a problem with (the fantastic) addFingering snippet.
>>>
>>> Here it is my simple code.
>>>
>>> \version "2.19.54"
>>> \include "addFingering.ly"
>>>
>>> {
>>>   \addFingering  {a b a b} #"12"
>>> }
>>>
>>> {
>>>   \addFingering  {\repeat unfold 2 {a b}} #"12"
>>> }
>>
>> You can create your own repeat function :
>>
>> %%%
>>
>> nCopy = #(define-music-function (parser location n music)(integer? ly:music?)
>> (cond
>>   ((> n 1)(ly:music-deep-copy (make-sequential-music (make-list n music))))
>>   ((= n 1) music)
>>   (else (make-music 'Music 'void #t))))
>>
>>
>>  \addFingering  { \nCopy #2 {a b} } #"12"
>>
>> %%%
>>
>
> You could also do this without \addFingering:
>
> nCopyNoFingerings =
> #(define-music-function (parser location n music) (integer? ly:music?)
>    (cond
>     ((= n 1)
>      music)
>     ((> n 1)
>      (let ((stripped
>             (music-filter
>              (lambda (m) (not (music-is-of-type? m 'fingering-event)))
>              (ly:music-deep-copy music))))
>        (make-sequential-music
>         (cons music
>           (make-list (1- n) stripped)))))
>     (else (make-music 'Music 'void #t))))
>
>
> { \nCopyNoFingerings #3 { a-1 b-2 } }

And you could omit other things besides fingerings with this definition:

nCopyWithout =
#(define-music-function (parser location n types music)
   (integer? list? ly:music?)
   (cond
    ((= n 1)
     music)
    ((> n 1)
     (let* ((cpy (ly:music-deep-copy music))
            (stripped
             (let loop ((t types) (result cpy))
               (if (null? t)
                   result
                   (loop (cdr t)
                     (music-filter
                      (lambda (m) (not (music-is-of-type? m (car t))))
                      cpy))))))
       (make-sequential-music
        (cons music
          (make-list (1- n) stripped)))))
    (else (make-music 'Music 'void #t))))

{ \nCopyWithout #3 #'(fingering-event dynamic-event script-event) {
a-1\f b-2-> } }

-DN



reply via email to

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