B.1 Tweaking with Scheme

We have seen how LilyPond output can be heavily modified using commands like \override TextScript #'extra-offset = ( 1 . -1). But we have even more power if we use Scheme. For a full explanation of this, see the Scheme tutorial, and Interfaces for programmers.

We can use Scheme to simply \override commands,

TODO Find a simple example

We can use it to create new commands:

tempoMark = #(define-music-function (parser location padding marktext)
                                    (number? string?)
  \once \override Score . RehearsalMark #'padding = $padding
  \once \override Score . RehearsalMark #'extra-spacing-width = #'(+inf.0 . -inf.0)
  \mark \markup { \bold $marktext }

\relative c'' {
  c2 e
  \tempoMark #3.0 #"Allegro"
  g c

[image of music]

Even music expressions can be passed in:

pattern = #(define-music-function (parser location x y) (ly:music? ly:music?)
  $x e8 a b $y b a e

\relative c''{
  \pattern c8 c8\f
  \pattern {d16 dis} { ais16-> b\p }

[image of music]

Other languages: espaƱol, deutsch.

Learning Manual