lilypond-user
[Top][All Lists]
Advanced

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

Re: Scheme Problem


From: Orm Finnendahl
Subject: Re: Scheme Problem
Date: Sun, 31 Dec 2006 14:17:53 +0100
User-agent: Mutt/1.5.11

Am 31. Dezember 2006, 15:23 Uhr (+1100) schrieb Brett Duncan:
> 
> But when I put
> 
>    \compFor #16
> 
> into my .ly file, the following error occurs:
> 
> syntax error, unexpected NUMBER_IDENTIFIER, expecting DIGIT or UNSIGNED
>            \repeat "unfold"
>                                         \lilyvartmpb { r4 }
> 
> 
> Can someone point out to me where I'm going wrong?

I don't know the exact reason but somehow the expansion into a scheme
construct doesn't work for variables in the \repeat "unfold" construct
(the parser expects a number but obviously doesn't resolve the $beats
before seeing it).

You can get it done this way: Look at the expansion of your function
with \displayMusic after replacing the variable with a real number (to
avoid the error) and then use the output of lilypond for defining your
music-function:

compFor = #(define-music-function (parser location beats) (number?)
       #{                                                          
           \override Rest #'stencil =
#ly:percent-repeat-item-interface::beat-slash
           \override Rest #'thickness = #'0.48
           \override Rest #'slope = #'1.7

           \repeat "unfold" 16 { r4 }

           \revert Rest #'stencil
       #})                       

\displayMusic
\compFor #16

----------------------------------- 

In the output of lilypond, you replace the "16" with the variable name
"beats" and copy that into the definition of your music function. It's
not really convenient and there's probably another way to get it done,
but at least it works.

-----------------------------------
The result is like this (and that works as expected):

\version "2.11.2"

compFor = #(define-music-function (parser location beats) (number?)
            (make-music
             'SequentialMusic
             'elements
             (list (make-music
                    'ContextSpeccedMusic
                    'context-type
                    'Bottom
                    'element
                    (make-music
                     'OverrideProperty
                     'pop-first
                     #t
                     'grob-property-path
                     (list (quote stencil))
                     'grob-value
                     ly:percent-repeat-item-interface::beat-slash
                     'symbol
                     'Rest))
              (make-music
               'ContextSpeccedMusic
               'context-type
               'Bottom
               'element
               (make-music
                'OverrideProperty
                'pop-first
                #t
                'grob-property-path
                (list (quote thickness))
                'grob-value
                0.48
                'symbol
                'Rest))
              (make-music
               'ContextSpeccedMusic
               'context-type
               'Bottom
               'element
               (make-music
                'OverrideProperty
                'pop-first
                #t
                'grob-property-path
                (list (quote slope))
                'grob-value
                1.7
                'symbol
                'Rest))
              (make-music
               'UnfoldedRepeatedMusic
               'elements
               '()
               'repeat-count
               beats
               'element
               (make-music
                'SequentialMusic
                'elements
                (list (make-music
                       'EventChord
                       'elements
                       (list (make-music
                              'RestEvent
                              'duration
                              (ly:make-duration 2 0 1 1)))))))
              (make-music
               'ContextSpeccedMusic
               'context-type
               'Bottom
               'element
               (make-music
                'RevertProperty
                'grob-property-path
                (list (quote stencil))
                'symbol
                'Rest)))))


   \compFor #16




reply via email to

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