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