lilypond-user
[Top][All Lists]
Advanced

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

Re: Problem creating Macro on \repeat


From: Nicolas Sceaux
Subject: Re: Problem creating Macro on \repeat
Date: Fri, 11 Aug 2006 20:40:53 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin)

Mats Bengtsson <address@hidden> writes:

> Pietro Casella wrote:
>
>> Hi all,
>>
>> I'm trying to create something like this:
>>
>> blankbar = #(define-music-function (parser location x) (number?)
>> #{
>>     \repeat unfold $x {s1}
>> #})
>>
>> \blankbar #56

> I'm afraid you have hit a limitation in the use of #{...#}. My
> recommendation
> is to change to plan B, which is described in the section on "Building
> complicated
> functions" in the manual for version 2.9.x.

Some more explanations:
  #{ \repeat unfold $x {s1}  #}
is equivalent to:
  x=#3
  \repeat unfold \x {s1}
which, if you try it, causes the syntax error you reported.

So, as Mats said, you have to do otherwise, but that's not too difficult
in that case.

  \displayMusic \repeat unfold 3 {s1}
==>
(make-music
  'UnfoldedRepeatedMusic
  'elements
  '()
  'repeat-count
  3
  'element
  (make-music
    'SequentialMusic
    'elements
    (list (make-music
            'EventChord
            'elements
            (list (make-music
                    'SkipEvent
                    'duration
                    (ly:make-duration 0 0 1 1)))))))

Search the "3" in the above expression: that's where you'll put the x
argument of your music function. You can even change the:
  (make-music
    'SequentialMusic
    'elements
    (list (make-music
            'EventChord
            'elements
            (list (make-music
                    'SkipEvent
                    'duration
                    (ly:make-duration 0 0 1 1))))))
part with #{ s1 #} (which is what it means) to make the expression
shorter.

  blankbar =
  #(define-music-function (parser location x) (number?)
     (make-music 'UnfoldedRepeatedMusic
       'elements '()
       'repeat-count x
       'element #{ s1 #}))
  
  \blankbar #56

simple!

nicolas




reply via email to

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