]> git.donarmstrong.com Git - lilypond.git/blob - ly/chord-glissando-init.ly
Midi2ly: add --skip option, print rests by default. Fixes #1549.
[lilypond.git] / ly / chord-glissando-init.ly
1 %%%% This file is part of LilyPond, the GNU music typesetter.
2 %%%%
3 %%%% Copyright (C) 2010 Carl D. Sorensen <c_sorensen@byu.edu>
4 %%%%
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.
9 %%%%
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.
14 %%%%
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/>.
17
18 \version "2.13.49"
19
20 %%  Make slide indication for chords
21 chordGlissando =
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}."
24
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))))
28        musChord))
29
30    (define (get-notes musicChord)
31      (filter (lambda(x) (eq? (ly:music-property x 'name) 'NoteEvent))
32              (ly:music-property musicChord 'elements)))
33
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)
38                                            'NoteEvent)))
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)
44        new-mus))
45
46    (define (add-glissando-line mus1 mus2 index)
47      (context-spec-music
48       (context-spec-music
49        (make-sequential-music
50         (list
51          hideNotes
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)))
63       'Staff))
64
65    (let* ((notes1 (get-notes mus1))
66           (notes2 (get-notes mus2))
67           (note-count (min (length notes1) (length notes2))))
68
69     #{
70        \once \override Glissando #'minimum-length = #4
71        \once \override Glissando #'springs-and-rods = #ly:spanner::set-spacing-rods
72      <<
73        {
74          $(add-glissando mus1)
75          $mus2
76        }
77        $(make-simultaneous-music
78            (map (lambda (x)
79                         (add-glissando-line mus1 mus2 x))
80                 (iota note-count)))
81     >>
82     \revert NoteColumn #'ignore-collision
83   #}))