6

The LilyPond code below creates two notes, including their names on top and the corresponding fingering chart for saxophone.

\version "2.22.0"
#(print-keys-verbose 'saxophone)
#(set-global-staff-size 38)
\score{
    \relative {
        \textLengthOn
        d'1_\markup {
            \woodwind-diagram
            #'saxophone
            #'((cc . (one two three four five six))
               (lh . ())
               (rh . ()))
        }^\markup{D}
        e1_\markup {
            \woodwind-diagram
            #'saxophone
            #'((cc . (one two three four five))
               (lh . ())
               (rh . ()))
        }^\markup{E}
    }
}

example output from LilyPond sample code

I have the feeling that LilyPond uses something like Lisp syntax, but I'm more a Python person.

I want to write multiple constructs like that for each note (that I know currently), and I wonder how to create a function to reuse that code by just giving parameters in it; e.g., note (d in the example), notename (D in the example) and something for the fingers (one two three four five six).

1

1 Answer 1

6

The fragment you wrote could be spelled as

\version "2.22.0"
#(print-keys-verbose 'saxophone)
#(set-global-staff-size 38)
mydiag =
#(define-music-function (note notename fingers)
  (ly:pitch? markup? symbol-list?)
  #{
    $note 1_\markup {
      \woodwind-diagram
      #'saxophone
      #`((cc . ,fingers)
     (lh . ())
     (rh . ()))
     }^\markup #notename
    #})


\score {
  \relative {
    \textLengthOn
    \mydiag d' "D" one,two,three,four,five,six
    \mydiag e "E" one,two,three,four,five
  }
}

There may be some different requirements of yours that require additional changes, but that's sort of how it could be done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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