Extending LilyPond: 2.1.4 Mathematics in functions

### 2.1.4 Mathematics in functions

Music functions can involve Scheme programming in addition to simple substitution,

>     AltOn =
>     #(define-music-function
>          (parser location mag)
>          (number?)
>        #{
>          \override Stem #'length = $(* 7.0 mag)
>          \override NoteHead #'font-size =
>            $(inexact->exact (* (/ 6.0 (log 2.0)) (log mag)))
>        #})

>     AltOff = {
>       \revert Stem #'length
>       \revert NoteHead #'font-size
>     }

>     \relative c' {
>       c2 \AltOn #0.5 c4 c
>       \AltOn #1.5 c c \AltOff c2
>     }

This example may be rewritten to pass in music expressions,

>     withAlt =
>     #(define-music-function
>          (parser location mag music)
>          (number? ly:music?)
>        #{
>          \override Stem #'length = $(* 7.0 mag)
>          \override NoteHead #'font-size =
>            $(inexact->exact (* (/ 6.0 (log 2.0)) (log mag)))
>          $music
>          \revert Stem #'length
>          \revert NoteHead #'font-size
>        #})

>     \relative c' {
>       c2 \withAlt #0.5 { c4 c }
>       \withAlt #1.5 { c c } c2
>     }

其它语言：deutsch, español。

#### LilyPond — Extending