lilypond-user
[Top][All Lists]
Advanced

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

Re: Slurs in scheme?


From: Nicolas Sceaux
Subject: Re: Slurs in scheme?
Date: Thu, 08 Sep 2005 22:15:36 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin)

Joe Neeman <address@hidden> 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




reply via email to

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