]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/snippets/new/bar-chords-notation-for-guitar--with-text-spanner.ly
Copy snippets changed in ffb5c20633459831cea21859f3423ea50060d705 to snippets/new
[lilypond.git] / Documentation / snippets / new / bar-chords-notation-for-guitar--with-text-spanner.ly
1 \version "2.15.20"
2
3 \header {
4   lsrtags = "chords, fretted-strings"
5
6   texidoc = "
7 Here is how to print bar chords, or half-bar chords (just uncomment the
8 appropriate line for to select either one).
9
10 The syntax is @code{\\bbarre #'fret_number' @{ notes @} }
11
12
13
14
15 "
16   doctitle = "Bar chords notation for Guitar ( with Text Spanner)"
17 }
18
19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20 %% %%%%%%%  Cut here ----- Start 'bbarred.ly'
21
22 %% PostScript -------------------------------
23 pScript= \markup {
24         \with-dimensions #'(0 . 0.8) #'(0 . 2.0)
25         \postscript     #"
26         0.15 setlinewidth
27         /Times-Roman findfont
28         2.0 scalefont
29         setfont
30         (C)show %%change with B if you prefer
31        %(B)show %%change with C if you prefer
32         stroke
33         0.7 -0.5 moveto
34         0.7  1.7 lineto
35         stroke"
36 }
37 %% Span -----------------------------------
38 %% Syntax: \bbarre #"text" { notes } - text = any number of box
39 bbarre= #(define-music-function (barre location str music) (string? ly:music?)
40            (let ((spanned-music
41                    (let ((first-element #f)
42                          (last-element #f)
43                          (first-found? #f))
44                      (music-map (lambda (m)
45                                   (if (eqv? (ly:music-property m 'name) 'EventChord)
46                                       (begin
47                                         (if (not first-found?)
48                                             (begin
49                                               (set! first-found? #t)
50                                               (set! first-element m)))
51                                         (set! last-element m)))
52                                   m)
53                                 music)
54                      (if first-found?
55                          (begin
56                            (set! (ly:music-property first-element 'elements)
57                                  (cons (make-music 'TextSpanEvent 'span-direction -1)
58                                        (ly:music-property first-element 'elements)))
59                            (set! (ly:music-property last-element 'elements)
60                                  (cons (make-music 'TextSpanEvent 'span-direction 1)
61                                        (ly:music-property last-element 'elements)))))
62                      music)))
63              (make-music 'SequentialMusic
64                'origin location
65                'elements (list #{
66                         \once \override TextSpanner #'font-size = #-2
67                         \once \override TextSpanner #'font-shape = #'upright
68                         \once \override TextSpanner #'staff-padding = #3
69                         \once \override TextSpanner #'style = #'line
70                         \once \override TextSpanner #'to-barline = ##f
71                         \once \override TextSpanner #'bound-details =  #'((left (Y . 0) (padding . 0.25) (attach-dir . -2)) (right (Y . 0) (padding . 0.25) (attach-dir . 2)))
72                         \once  \override TextSpanner #'bound-details #'right #'text = \markup { \draw-line #'( 0 . -.5) }
73                         \once  \override TextSpanner #'bound-details #'left #'text =  \markup { \pScript #str }
74 %% uncomment this line for make full barred
75                        % \once  \override TextSpanner #'bound-details #'left #'text =  \markup { "B" #str }
76                           #}
77     spanned-music))))
78
79 %% %%%%%%%  Cut here ----- End 'bbarred.ly'
80 %% Copy and change the last line for full barred. Rename in 'fbarred.ly'
81 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82
83 %% Syntaxe: \bbarre #"text" { notes } - text = any number of box
84 \relative c'{ \clef "G_8" \stemUp \bbarre #"III" { <f a'>16[  c' d c d8] } }