[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: functions in \with
From: |
Nicolas Sceaux |
Subject: |
Re: functions in \with |
Date: |
Thu, 31 Aug 2006 22:22:48 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin) |
"Trevor Daniels" <address@hidden> writes:
> Being relatively new to lilypond I wanted to encapsulate useful expressions
> in variables and functions as I came across them. For music-related
> expressions I find these very useful, and I wanted to do the same for other
> types of sequences. Here's a simple example (thanks, Kieren) to reduce the
> size of a piano grand staff which I've failed to recast as a more general
> function for use in a \with clause:
>
> \new PianoStaff \with {
> fontSize = #-2 % reduce size of all fonts
> \override StaffSymbol #'staff-space = #(magstep -2) % reduce size of staves
> by same amount
> \override VerticalAlignment #'forced-distance = #11 % increase distance
> between staves for piano dynamics
> }
> ... rest of staves and music
>
> I wanted to define a void function something like
>
> staffSize=#(
> define-music-function (parser location fontsize separation) (number?
> number?) #{
> fontSize = #$fontsize % change size of all fonts
> \override StaffSymbol #'staff-space = #(magstep #$fontsize) % change size
> of staves by same amount
> \override VerticalAlignment #'forced-distance = #$separation % change
> distance between staves for piano dynamics
> #}
> (make-music 'SequentialMusic 'void #t)
> )
[not tested]
staffWithSize =
#(define-music-function (parser location size distance music)
(number? number? ly:music?)
#{
\new PianoStaff \with {
fontSize = #$size
\override StaffSymbol #'staff-space = #(magstep $size)
\override VerticalAlignment #'forced-distance = #$distance
}
$music
#})
==>
\staffWithSize #-2 #11 { ..music.. }
nicolas