\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' c' g' c'' g' c'2 %\break g'1 } \addGlissandi { 1~ 4 1 }