lilypond-user
[Top][All Lists]
Advanced

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

Help with function to output formatted \mark


From: Stefano Troncaro
Subject: Help with function to output formatted \mark
Date: Fri, 16 Dec 2016 04:17:11 -0300

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.

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.

reply via email to

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