"Fairchild" <[EMAIL PROTECTED]> writes: > 3) I don't understand some elements, and hope for enlightenment about: > a) def-music-function (location MagArg) (number?)
This is the way to define new LilyPond "keywords", eg functions manipulating their argument in order to build some music expression programatically. See the LilyPond manual, http://lilypond.org/doc/v2.4/Documentation/user/out-www/lilypond/Extending-music-syntax.html http://lilypond.org/doc/v2.6/Documentation/user/out-www/lilypond/Extending-music-syntax.html > b) #(use-modules (ice-9 optargs)) this asks to load a module, which makes it possible to define functions with variable number of arguments, keyword arguments, etc. Note that in the example that you show, it is not necesarry. Just change 'define*' by 'define'. See the guile manual, chapter on modules: http://www.gnu.org/software/guile/docs/guile-ref/Using-Guile-Modules.html > c) #(define* (AltOn MagArg) This should be define, not define*. define* is for defining function with more complex arguments, eg. keyword, rest or optional arguments. See the guile manual: http://www.gnu.org/software/guile/docs/guile-ref/define--Reference.html > d) (ly:export #{ . . . #} See the LilyPond-internal manual: http://lilypond.org/doc/v2.6/Documentation/user/out-www/lilypond-internals/Scheme-functions.html > %%%%%%%%%%%%%%%%%%%%%%%%%%% > > \version "2.4.6" > AltOn = #( def-music-function > (location MagArg) (number?) #{ > #( define Mag $MagArg ) > #( define SizeIE (*(/ 6.0 (log 2.0)) (log Mag))) > #( define Size (inexact->exact SizeIE )) > \override Stem #'length = #(* 7.0 Mag) > \override NoteHead #'font-size = #Size #}) > AltOff = { > \revert Stem #'length > \revert NoteHead #'font-size } > { c' \AltOn #0.5 c' c' \AltOff c' } > > %%%%%%%%%%%%%%%%%%%%%%%%%%% > > \version "2.4.6" > #(use-modules (ice-9 optargs)) > #(define* (AltOn MagArg) (ly:export #{ > #( define Mag $MagArg ) > #( define SizeIE (*(/ 6.0 (log 2.0)) (log Mag))) > #( define Size (inexact->exact SizeIE )) > \override Stem #'length = #(* 7.0 Mag) > \override NoteHead #'font-size = #Size #})) > #(define* (AltOff) (ly:export #{ > \revert Stem #'length > \revert NoteHead #'font-size #})) > { c' #(AltOn 0.65) c' c' #(AltOff) c' } > > %%%%%%%%%%%%%%%%%%%%%%%%%%% The first of your two solutions is the more LilyPond-idiomatic. However, the style is not very clean, here is how it could be rephrased: \version "2.4.6" AltOn = #(def-music-function (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 } { c' \AltOn #0.5 c' c' \AltOff c' } Or, with LilyPond 2.6 (note the extra 'parser' argument): \version "2.6.0" AltOn = #(def-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 } { c' \AltOn #0.5 c' c' \AltOff c' } However, I would rather write like this: \version "2.6.0" withAlt = #(def-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 #}) { c' \withAlt #0.5 { c' c' } c' } For LilyPond 2.4.6, remove the 'parser' argument after def-music-function. nicolas _______________________________________________ lilypond-user mailing list [email protected] http://lists.gnu.org/mailman/listinfo/lilypond-user
