lilypond-user
[Top][All Lists]
Advanced

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

Re: always glissandi


From: David Nalesnik
Subject: Re: always glissandi
Date: Thu, 23 Jun 2016 20:55:50 -0500

On Thu, Jun 23, 2016 at 6:37 PM, David Nalesnik
<address@hidden> wrote:

>
> (If you want glissandi suppressed on repeated notes, that's a whole
> new level of sophistication.)
>


As with any command that operates on a span of music, complications
arise....  Glissandi obviously aren't appropriate between every group
of notes.  Tied notes are obviously not candidates for glissandi, as
noted earlier.  Repeated single notes, also an obvious "no."  But what
about shared notes between a pair of chords?

Anyway, I had an insight about adding a bit of look-ahead to the
function.  This allows some control over the handling of repeated
notes.  I don't know if what I've done here makes sense with the
practice you envisage, but the materials are here for tweaking.

I'm thinking I'm safe in betting that I've spent more time on this
than this will ever save you :)

Best,
DN

%%%%%%%%%%%%%%%%%%%%%
\version "2.19.30"

#(define pitchReps?
   (lambda (a b)
     (let* ((a (if (music-is-of-type? a 'event-chord)
                   (ly:music-property a 'elements)
                   (list a)))
            (b (if (music-is-of-type? b 'event-chord)
                   (ly:music-property b 'elements)
                   (list b)))
            (pitchesA (map (lambda (p) (ly:music-property p 'pitch)) a))
            (pitchesB (map (lambda (p) (ly:music-property p 'pitch)) b))
            (shared
             (map (lambda (x)
                    (find (lambda (y) (equal? x y)) pitchesB))
               pitchesA)))
       (if (= (length a) (length b))
           (every ly:pitch? shared)
           (any ly:pitch? shared)))))


addGlissandi =
#(define-music-function (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 (pitchReps? 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 {
  g4 c'~ c' <c' e'>
  <c' e'> c'  c' g'
  c'' g' c'2
  g'1
}

\addGlissandi {
  <c' e'>1~
  <c' e'>4 <g' c''> <c'' e''> <g' c''>
  <g' c''>1
}



reply via email to

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