]> git.donarmstrong.com Git - lilypond.git/blob - input/regression/tie-chord.ly
Split WWW target in two stages WWW-1 and WWW-2
[lilypond.git] / input / regression / tie-chord.ly
1 \header {
2
3
4   texidoc = "In chords, ties keep closer to the note head vertically,
5 but never collide with heads or stems. Seconds are formatted up/down;
6 the rest of the ties are positioned according to their vertical
7 position.
8
9 The code does not handle all cases. Sometimes ties will printed on top
10 of or very close to each other. This happens in the last chords of
11 each system.  "
12   
13
14 }
15
16 \version "2.10.0"
17
18 \paper {
19   indent = #0.0
20   ragged-right = ##t
21 }
22
23
24
25 generateTiePattern
26 = #(define-music-function (parser location is-long chords) (boolean? ly:music?)
27
28     "
29
30 translate x y z to x~x y~y z~z
31
32
33     
34   (define (chord->tied-chord chord)
35     (let*
36         ((ch1 (ly:music-deep-copy chord))
37          (ch2 (ly:music-deep-copy chord))
38          (dur1 (ly:make-duration
39                 (if is-long
40                     1 2)))
41          (dur2 (ly:make-duration
42                 (if is-long
43                     3 2))))
44
45       (for-each (lambda (e)
46                   (ly:music-set-property! e 'duration dur1))
47                 (ly:music-property ch1 'elements))
48
49       (for-each (lambda (e)
50                   (ly:music-set-property! e 'duration dur2))
51                 (ly:music-property ch2 'elements))
52       
53       (set! (ly:music-property ch1 'elements)
54             (cons
55              (make-music 'TieEvent)
56              (ly:music-property ch1 'elements)))
57
58       (list ch1 ch2)))
59
60   (make-music 'SequentialMusic 'elements (apply append
61                                                 (map chord->tied-chord (ly:music-property  chords 'elements)))))
62
63 baseChords =
64 \applyMusic #(lambda (mus)
65               (ly:music-property mus 'element))
66 \relative c'' {
67   <c e>  
68   <b c e>
69   <a c e>
70   <a b e>
71   <a b e f>
72   <a c d f>
73   <a c e f>
74   <f a e' f>
75   <c e f a> 
76   <c e g a>
77   <f b e a>
78 }
79
80 testShort =
81 {
82   \key c \major
83   \generateTiePattern ##f \baseChords
84 }  
85
86 testLong =
87 {
88   \key c \major
89   \generateTiePattern ##t \baseChords
90 }  
91
92 \new Voice
93 {
94   \time 2/4
95
96   \testShort \break
97   \transpose c d \testShort \break
98   \time 5/8
99   \testLong \break
100   \transpose c d \testLong \break
101 }
102
103