lilypond-user
[Top][All Lists]
Advanced

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

Re: Function to add articulation to all notes


From: David Nalesnik
Subject: Re: Function to add articulation to all notes
Date: Thu, 28 Dec 2017 14:42:24 -0600

Hi,

On Thu, Dec 28, 2017 at 1:37 PM, Caagr98 <address@hidden> wrote:
> That function seems rather destructive: removes all properties on existing 
> articulations (including tweaks, direction, and midi stuff), and doesn't seem 
> to handle anything other than ArticulationEvents at all. Dynamics, slurs, 
> ties, etc are removed. Also, this version has no way to exclude a note from 
> being articulated, unlike the earlier versions (where you can set 
> 'articulations to an empty list to exclude it).
>

OK, this will preserve what's already there:
addArticulation =
#(define-music-function (scripts music) (list? ly:music?)
   (define (add mus)
     (let* ((art (ly:music-property mus 'articulations))
            (types (map (lambda (a) (ly:music-property a 'articulation-type))
                     art)))
       (for-each
        (lambda (x)
          (if (not (member x types))
              (ly:music-set-property! mus 'articulations
               (append! (ly:music-property mus 'articulations)
                 (list (make-articulation x))))))
        scripts)))
   (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" "accent") { c~ c <c e g>->\f d d' c'^! }
}

You'll note the wrong behavior at ties.  This could be fixed with a
bunch more code.  I should note in this connection that the original
definition of addArticulation which you inherited is flawed in regard
to ties::

{
  \addArticulation \accent { c~ c } % use original definition from top of thread
  \addArticulation \staccato { c~ c }
}

It would be helpful if you would provide a test example so we could
get an idea of what you want to work.

Thanks,
David



reply via email to

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