| [ << Interfaces for programmers ] | [Top][Contents][Index][ ? ] | [ LilyPond Scheme interfaces >> ] | ||
| [ < Callback functions ] | [ Up : Interfaces for programmers ] | [ Difficult tweaks > ] | ||
2.8 Inline Scheme code
TODO: after this section had been written, LilyPond has improved to the point that finding a simple example where one would have to revert to Scheme has become rather hard.
Until this section gets a rewrite, let’s pretend we don’t know.
The main disadvantage of \tweak is its syntactical
inflexibility. For example, the following produces a syntax error
(or rather, it did so at some point in the past).
F = \tweak font-size #-3 -\flageolet
\relative c'' {
c4^\F c4_\F
}
Using Scheme, this problem can be avoided. The route to the
result is given in Adding articulation to notes (example),
especially how to use \displayMusic as a helping guide.
F = #(let ((m (make-music 'ArticulationEvent
'articulation-type "flageolet")))
(set! (ly:music-property m 'tweaks)
(acons 'font-size -3
(ly:music-property m 'tweaks)))
m)
\relative c'' {
c4^\F c4_\F
}
Here, the tweaks properties of the flageolet object
m (created with make-music) are extracted with
ly:music-property, a new key-value pair to change the
font size is prepended to the property list with the
acons Scheme function, and the result is finally
written back with set!. The last element of the
let block is the return value, m itself.
| [ << Interfaces for programmers ] | [Top][Contents][Index][ ? ] | [ LilyPond Scheme interfaces >> ] | ||
| [ < Callback functions ] | [ Up : Interfaces for programmers ] | [ Difficult tweaks > ] | ||
Other languages: deutsch, español, français.
About automatic language selection.