2

I want to create a function in Lilypond that accepts one note as input and returns the note with some markup applied. Specifically, I want to simplify something like the following:

\relative c' { d^\markup{\hspace #2 \smaller +1}-\bendAfter #+1 }

to something along the lines of

\relative c' { \bend{d} }

Currently I have the following snippet:

mF = \markup{\hspace #2 \smaller +1}
bF = \bendAfter #+1

bendF = #(define-music-function (parser location note) (ly:music?)
        #{ $note^\mF-\bF #}
)

\relative c' { d^\mF-\bF }
\relative c' { \bendF{d} }

\version "2.16.2"

It seems that the data type ly:music? is not the right one, or it is impossible to append the markup directly, and I end up with not very descriptive interpreter errors.

What is the best way to achieve this effect?

mwil.me
  • 1,134
  • 1
  • 19
  • 33
  • Hi, did you considering joining the LilyPond mailing list, where you can get in touch with other LilyPond users and developers? That is usually the best (and fastest) way to solve a problem or get an answer. The address for signing in is: lilypond.org/contact.html – gilbertohasnofb Dec 04 '13 at 13:41
  • 1
    @gilberto.agostinho.f Thanks, that would be probably better, but I'm currently working on my "tumbleweed" badge :-) And if there are no Lilypond questions on SO people who can answer them also have no reason to look around here ... – mwil.me Dec 04 '13 at 14:04

1 Answers1

2

This may be not the solution you are looking for, but you might be able to solve your problem by using an event function with no arguments instead of a music function (thus working around the ly:music? problem). Try:

\version "2.17.95"

mF = \markup{\hspace #2 \smaller +1}
bF = \bendAfter #+1

bendF = #(define-event-function 
     (parser location )
     ( )
      #{
        ^\mF-\bF
      #}   
)

\relative c' { d^\mF-\bF }
\relative c' { d\bendF }
gilbertohasnofb
  • 1,984
  • 16
  • 28