1 %%%% This file is part of LilyPond, the GNU music typesetter.
3 %%%% Copyright (C) 2010 Carl D. Sorensen <c_sorensen@byu.edu>
5 %%%% LilyPond is free software: you can redistribute it and/or modify
6 %%%% it under the terms of the GNU General Public License as published by
7 %%%% the Free Software Foundation, either version 3 of the License, or
8 %%%% (at your option) any later version.
10 %%%% LilyPond is distributed in the hope that it will be useful,
11 %%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
12 %%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 %%%% GNU General Public License for more details.
15 %%%% You should have received a copy of the GNU General Public License
16 %%%% along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 %% Make slide indication for chords
22 #(define-music-function (parser location mus1 mus2) (ly:music? ly:music?)
23 "Make a glissando between the notes of triads @code{mus1} and @code{mus2}."
25 (define (add-glissando musChord)
26 (let ((els (ly:music-property musChord 'elements)))
27 (ly:music-set-property! musChord 'elements (append els (list (make-music 'GlissandoEvent))))
30 (define (get-notes musicChord)
31 (filter (lambda(x) (eq? (ly:music-property x 'name) 'NoteEvent))
32 (ly:music-property musicChord 'elements)))
34 (define (select-note musChord index)
35 (let* ((notes (get-notes musChord))
36 (non-notes (filter (lambda (x)
37 (not (eq? (ly:music-property x 'name)
39 (ly:music-property musChord 'elements)))
40 (selected-note (list-ref notes index))
41 (new-els (cons selected-note non-notes))
42 (new-mus (ly:music-deep-copy musChord)))
43 (ly:music-set-property! new-mus 'elements new-els)
46 (define (add-glissando-line mus1 mus2 index)
49 (make-sequential-music
52 (make-grob-property-set 'StringNumber 'transparent #t)
53 (make-grob-property-set 'NoteColumn 'ignore-collision #t)
54 ;; obviously, this isn't equivalent to \once,
55 ;; so could be changed if required
56 (make-grob-property-set 'Glissando 'thickness 2)
57 (make-grob-property-set 'DynamicText 'transparent #t)
58 (make-grob-property-set 'DynamicLineSpanner 'transparent #t)
59 (make-grob-property-set 'DynamicTextSpanner 'transparent #t)
60 (add-glissando (select-note mus1 index))
61 (select-note mus2 index)))
62 'Bottom (symbol->string (gensym)))
65 (let* ((notes1 (get-notes mus1))
66 (notes2 (get-notes mus2))
67 (note-count (min (length notes1) (length notes2))))
70 \once \override Glissando #'minimum-length = #4
71 \once \override Glissando #'springs-and-rods = #ly:spanner::set-spacing-rods
77 $(make-simultaneous-music
79 (add-glissando-line mus1 mus2 x))
82 \revert NoteColumn #'ignore-collision