lilypond-user
[Top][All Lists]
Advanced

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

Test direction within event-function


From: Urs Liska
Subject: Test direction within event-function
Date: Wed, 17 Oct 2018 10:26:07 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

Hi,

I'm trying to write an event-function that creates both a slur and a markup on opposite sides. I can do that by manually specifying the directions:

\version "2.19.82"

testDirection =
#(define-event-function ()()
   #{
     _(
     ^"Text"
   #})

{
  c' \testDirection d' )
}

but I have to make it possible to do it both ways (top/bottom and bottom/top).
I know how to set the directions with an extra (optional) function argument, but I would prefer if I could extract the direction directly from within the event-function.

Using \displayMusic I see that an explicit direction is "known" to the event function:
\void \displayMusic ^\testDirection
=>
(make-music
  'PostEvents
  'direction
  1
  'elements
  (list (make-music
          'SlurEvent
          'direction
          -1
          'span-direction
          -1)
        (make-music
          'TextScriptEvent
          'direction
          1
          'text
          "Text")))

(the 'direction PostEvent takes either 1 or -1, or is missing if no explicit direction is given). But I have no idea if/how I can access that information from within the function to decide how to create the slur and the text event.

Thanks Urs


reply via email to

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