On Fri, Jun 24, 2016 at 5:19 AM, David Kastrup <[email protected]> wrote:
> Tobias Hagedorn <[email protected]> writes:
>
>> Sorry I get this error message:
>>
>>  GUILE signalisierte einen Fehler für den hier beginnenden Ausdruck
>> #
>> (define-music-function (music) (ly:music?)
>>
>> Perhaps it depends on my version… I have to update
>> lilypond. music-function is complete new for me and very interesting!
>> I have to learn a bit more by myself and spending more time on this :)
>> Thanks a lot for this quick answering!
>> Tobias
>>
>> \version "2.19.15"
>>
>> addGlissandi =
>> #(define-music-function (music) (ly:music?)
>
> Yes.  I think it's something like 2.19.22 where you can write music
> functions like that.  Before it had to be
>
>     #(define-music-function (parser location music) (ly:music?)


I changed this in the attached, so I think this ought to work at least
back to current stable.

I've also tweaked the code a little so it's more understandable, in
case someone wants to fool with the mechanism for deciding when to
draw glissandi in the presence of note repetitions.  I suppose it
could get really fancy with glissandoMap.

DN
\version "2.19.30"

#(define get-pitches
   (lambda (mus)
     (let ((note-evs
            (cond
             ((music-is-of-type? mus 'event-chord)
              (filter (lambda (e) (music-is-of-type? e 'note-event))
                      (ly:music-property mus 'elements)))
             ((music-is-of-type? mus 'note-event) (list mus))
             (else '()))))
       (map (lambda (ne) (ly:music-property ne 'pitch)) note-evs))))


#(define pitch-reps?
   (lambda (a b)
     (let* ((pitchesA (get-pitches a))
            (pitchesB (get-pitches b))
            ; a list of pitches in pitchesA that are shared with B
            ; pitches only in pitchesA will be represented by #f
            (shared
             (map (lambda (pa)
                    (find (lambda (pb) (equal? pa pb)) pitchesB))
               pitchesA)))
       ; return #t if repetitions preclude glissando
       ; logic below is just a placeholder...
       (if (= (length pitchesA) (length pitchesB))
           (every ly:pitch? shared)
           (any ly:pitch? shared)))))


addGlissandi =
#(define-music-function (parser location music) (ly:music?)
   (music-map
    (lambda (mus)
      (if (music-is-of-type? mus 'sequential-music)
          (let ((elts (ly:music-property mus 'elements)))
            (pair-for-each
             (lambda (p)
               (if (> (length p) 1)
                   (let ((a (car p))
                         (b (cadr p)))
                     (if (not (pitch-reps? a b))
                         (begin
                          (if (music-is-of-type? a 'event-chord)
                              (append! (ly:music-property a 'elements)
                                (list (make-music 'GlissandoEvent))))
                          (if (music-is-of-type? a 'note-event)
                              (set! (ly:music-property a 'articulations)
                                    (cons (make-music 'GlissandoEvent)
                                      (ly:music-property a 'articulations)))))))))
             elts)))
      mus)
    music)
   music)


\addGlissandi {
  %\override Glissando.breakable = ##t
  %\override Glissando.after-line-breaking = ##t
  g4 c'~ c' <c' e'>
  <c' e'> c'  c' g'
  c'' g' c'2
  %\break
  g'1
}

\addGlissandi {
  <c' e'>1~
  <c' e'>4 <g' c''> <c'' e''> <g' c''>
  <g' c''>1
}
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to