lilypond-user
[Top][All Lists]
Advanced

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

Re: Apply event function *within* music-function


From: Thomas Morley
Subject: Re: Apply event function *within* music-function
Date: Tue, 2 May 2017 10:06:24 +0200

2017-05-02 8:29 GMT+02:00 Urs Liska <address@hidden>:
> Hi all,
>
> I'm trying to apply event functions to music passed into a music function
> like that:
>
> \version "2.19.57"
>
> test =
> #(define-music-function (mus)(ly:music?)
>    #{
>      #mus \startGroup
>    #})
>
> {
>   \test c' d' e' f' \stopGroup
> }
>
>
> (of course this is not what I ultimately want to achieve, but the nucleus
> from which I'll be able to continue on my own).
>
> This fails with "error: syntax error, unexpected EVENT_IDENTIFIER". I think
> it is because the #mus expression is somehow already complete (differently
> from when used in regular input) and I have to somehow *apply* the
> \startGroup event function to the #mus argument.
>
> From \displayMusic I can see that it is added as a NoteGroupingEvent to the
> note's articulations, but I'd like to ask if there's a more straightforward
> way to attach the event to the music than rebuilding the music expression in
> Scheme.
> OTOH I will want to do that for the first *and last* element in a music
> expression (in order to apply the start and stop command to a sequence of
> notes), so I may *have* to extract the Scheme representation anyway?
>
> TIA
> Urs



\layout {
  \context {
    \Voice
    \consists "Horizontal_bracket_engraver"
  }
}

test =
#(define-music-function (mus)(ly:music?)
   #{
      <>\startGroup
      $mus
      <>\stopGroup
   #})

{
  \test { c' d' e' f' }
}

Should do the trick.

Cheers,
   Harm



reply via email to

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