4

Could someone provide me with a minimal example of a new, custom articulation in LilyPond?

Let's say, for the sake of simplicity, that we use glyph "a" as the articulation, and let's call it \newArticulation.

Now I can use \markup as a workaround for creating something similar:

c'4^\markup{"a"}

but markup is not an articulation, and I would like to learn how to make a proper articulation, equivalent to the built-in ones, like \accent or \trill. Also, how would one make it turn upside down when it is below the note, like \fermata or \portato?

I've seen some examples on the LilyPond mailing list, but they seem to be very specific and mostly outdated.

1 Answer 1

4
\layout {
  \context {
    \Score
    scriptDefinitions =
    #(acons
      'a
      `((stencil . ,(lambda (grob)
                      (let ((d (ly:grob-property grob 'direction UP))
                            (mstc (grob-interpret-markup
                                   grob
                                   (markup #:override '(font-encoding . latin1)
                                           #:center-align
                                           "a"))))
                        (if (= d UP)
                            mstc
                            (ly:stencil-rotate
                             mstc 180 0 (interval-center (ly:stencil-extent mstc Y)))))))
        (direction . ,UP))
      default-script-alist)
  }
}

"a" =
#(make-articulation 'a)

{
  c' d'-\a e'^\a f'_\a
  e'' f''-\a g''^\a a''_\a
}
3
  • Thank you, that's exactly what I was looking for!
    – Kresimir
    Commented Mar 12 at 5:46
  • Just one question. Is it possible to move scriptDefinitions = #(acons ...) outside the layout context, so that this definition of a new articulation can be placed in the include file? Also, when adding multiple new articulations in this way, only the last one added works, as it always uses default-script-alist.
    – Kresimir
    Commented Mar 12 at 6:20
  • 1
    @Kresimir A layout block can be placed in an include file. If you want to be able to stepwise create multiple new articulations you can assign the result to a variable: #(define my-script-alist default-script-alist) #(set! my-script-alist (acons ... my-script-alist)) ... \layout { \context { \Score scriptDefinitions = #my-script-alist } }.
    – Lazy
    Commented Mar 12 at 7:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.