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