Advanced tweaks with Scheme - GNU LilyPond
Description: GNU LilyPond

Next: Avoiding tweaks with slower processing, Previous: Fitting music onto fewer pages, Up: Tweaking output

### 5.6 Advanced tweaks 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 explantion of this, see the Scheme tutorial and Interfaces for programmers.

We can use Scheme to simply `\override` commands,

>          padText = #(define-music-function (parser location padding) (number?)
>          #{
>            \once \override TextScript #'padding = #$padding
>          #})

>          \relative c''' {
>            c4^"piu mosso" b a b
>            \padText #1.8
>            c4^"piu mosso" d e f
>            \padText #2.6
>            c4^"piu mosso" fis a g
>          }

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 #'no-spacing-rods = ##t
>            \mark \markup { \bold $marktext }
>          #})

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

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 }
>          }

Next: Avoiding tweaks with slower processing, Previous: Fitting music onto fewer pages, Up: Tweaking output

This page is for LilyPond-2.10.33 (stable-branch).