Hello everyone,

I finally decided to start using Scheme functions. For learning purposes,
I'm trying to write a function that will imitate the output from this
snippet from the repository <http://lsr.di.unimi.it/LSR/Snippet?id=1008>.

I achieved the look of the output but I can't seem to figure out how to
make a function that accepts different types of parameters. Example:

\version "2.19.52"

%Properties of the customMark
#(define characters.thinSpace (ly:wide-char->utf-8 #x2009))
#(define customMark.parenthesized #t)
#(define customMark.tempoEqText "= ca.")

textandnotemark =
#(define-music-function
    (text dur val)
    (markup? ly:duration? number?)
  #{
    \mark \markup { \line { \upright { \fontsize #-2 {
       \larger { \bold { #text } }
       \concat {
         #(if customMark.parenthesized "(")
         \fontsize #-3 { \general-align #Y #DOWN { \note
#(ly:duration->string dur) #1 } }
         " "
         #customMark.tempoEqText
         #characters.thinSpace
         #(number->string val)
         #(if customMark.parenthesized ")")
       }
     } } } }
  #})

allegro = \textandnotemark "Allegro." 4 120
%ceder = \textandnotemark "ceder..."
metromark = \textandnotemark "" 4 120

\relative c' {
  \allegro c4 d e f \metromark
}

The line that is commented near the end of the example represents the
behavior that I'd like to achieve, that is, the case where there is only
text. I thought it would be easy to do it by setting defaults, leaving the
duration and value parameters blank, and managing the special case, but I
can't figure out how to make it work.

Thanks in advance for your time!
Stéfano.
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to