Joe Neeman <[EMAIL PROTECTED]> writes:

> As a simple example, here I'm trying to write a function that expands
> "a" into something like "a( a)":
>
> slur =
> #(def-music-function
>   (parser location m)
>   (ly:music?)
>
>   (make-sequential-music
>     (list
>       m
>       (make-span-event 'SlurEvent START)
>       m
>       (make-span-event 'SlurEvent STOP))))
>
> {
>     b \slur a
> }
>
> But I don't get the slur in the output. I've also tried similar things
> with ties and I've tried changing the order of the elements in the
> list.

The first thing to do is to see what the music that you want to build
looks like. You use \displayMusic :

  \displayMusic { a' ( a' ) }
==>
(make-music
  'SequentialMusic
  'elements
  (list (make-music
          'EventChord
          'elements
          (list (make-music
                  'NoteEvent
                  'duration
                  (ly:make-duration 2 0 1 1)
                  'pitch
                  (ly:make-pitch 0 5 0))
                (make-music
                  'SlurEvent
                  'span-direction
                  -1)))
        (make-music
          'EventChord
          'elements
          (list (make-music
                  'NoteEvent
                  'duration
                  (ly:make-duration 2 0 1 1)
                  'pitch
                  (ly:make-pitch 0 5 0))
                (make-music
                  'SlurEvent
                  'span-direction
                  1)))))

So the bad news here is that the SlurEvent expressions have to be added
"inside" the note that you want to give has an argument (more precisely,
the EventChord expression).

The argument to the function will look like that:

  \displayMusic a'
==>
(make-music
  'EventChord
  'elements
  (list (make-music
          'NoteEvent
          'duration
          (ly:make-duration 2 0 1 1)
          'pitch
          (ly:make-pitch 0 5 0))))

So, in the function, you'll want to clone this expression (so that you
have two notes to build the sequence), add SlurEvents to the 'elements
property of each ones, and finally make a SequentialMusic with the two
EventChords.


slur = #(def-music-function (parser location note) (ly:music?)
         "Return: { note ( note ) }.
`note' is supposed to be an EventChord."
         (let ((note2 (ly:music-deep-copy note)))
           (set! (ly:music-property note 'elements)
                 (cons (make-music 'SlurEvent 'span-direction -1)
                       (ly:music-property note 'elements)))
           (set! (ly:music-property note2 'elements)
                 (cons (make-music 'SlurEvent 'span-direction 1)
                       (ly:music-property note2 'elements)))
           (make-music 'SequentialMusic 'elements (list note note2))))

\displayMusic \slur a'

==>
(make-music
  'SequentialMusic
  'elements
  (list (make-music
          'EventChord
          'elements
          (list (make-music
                  'SlurEvent
                  'span-direction
                  -1)
                (make-music
                  'NoteEvent
                  'duration
                  (ly:make-duration 2 0 1 1)
                  'pitch
                  (ly:make-pitch 0 5 0))))
        (make-music
          'EventChord
          'elements
          (list (make-music
                  'SlurEvent
                  'span-direction
                  1)
                (make-music
                  'NoteEvent
                  'duration
                  (ly:make-duration 2 0 1 1)
                  'pitch
                  (ly:make-pitch 0 5 0))))))

nicolas


_______________________________________________
lilypond-user mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to