lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Argument transfer?


From: Fairchild
Subject: RE: Argument transfer?
Date: Mon, 4 Jul 2005 18:39:55 -0500

About a month ago I started this thread with the question: " [I]s there a
way to pass a parameter into a define from within \score?"  Several of you
responded with answers ranging from "impossible" to "certainly".  Actually I
was searching for a way to invoke the define with an argument, massage the
argument with Scheme code, then use the results in Lily code within the
define.  Appended below are two equivalent solutions.  I post them for
several reasons:

1)  As a way of thanking you who responded.

2)  The documented examples found aren't very comprehensible -- maybe these
can be made available -- with commentary.

3)  I don't understand some elements, and hope for enlightenment about:
       a)  def-music-function (location MagArg) (number?)
       b)  #(use-modules (ice-9 optargs))
       c)  #(define* (AltOn MagArg)
       d)  (ly:export #{ . . . #}

4)  I'm pleased with the results of many hours of stumbling and want to
brag.

5)  Can these be simplified?

                                 - Bruce

%%%%%%%%%%%%%%%%%%%%%%%%%%%

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

%%%%%%%%%%%%%%%%%%%%%%%%%%%







reply via email to

[Prev in Thread] Current Thread [Next in Thread]