]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/snippets/bar-chords-notation-for-guitar--with-text-spanner.ly
Doc-d: generate corrected png files from svg
[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 Documentation/snippets/new
3 % Make any changes in Documentation/snippets/new/
4 % and then run scripts/auxiliar/makelsr.py
5 %
6 % This file is in the public domain.
7 %% Note: this file works from version 2.15.24
8 \version "2.15.24"
9
10 \header {
11   lsrtags = "chords, fretted-strings"
12
13   texidoc = "
14 Here is how to print bar chords, or half-bar chords (just uncomment the
15 appropriate line for to select either one).
16
17 The syntax is @code{\\bbarre #'fret_number' @{ notes @} }
18
19
20
21
22 "
23   doctitle = "Bar chords notation for Guitar ( with Text Spanner)"
24 } % begin verbatim
25
26
27 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
28 %% %%%%%%%  Cut here ----- Start 'bbarred.ly'
29
30 %% C with slash -------------------------------
31 cWithSlash = \markup {
32   \combine \roman C \translate #'(0.6 . -0.4) \draw-line #'(0 . 2.0)
33 }
34 %% Span -----------------------------------
35 %% Syntax: \bbarre #"text" { notes } - text = any number of box
36 bbarre= #(define-music-function (barre location str music) (string? ly:music?)
37            (let ((spanned-music
38                    (let ((first-element #f)
39                          (last-element #f)
40                          (first-found? #f))
41                      (music-map (lambda (m)
42                                   (if (eqv? (ly:music-property m 'name) 'EventChord)
43                                       (begin
44                                         (if (not first-found?)
45                                             (begin
46                                               (set! first-found? #t)
47                                               (set! first-element m)))
48                                         (set! last-element m)))
49                                   m)
50                                 music)
51                      (if first-found?
52                          (begin
53                            (set! (ly:music-property first-element 'elements)
54                                  (cons (make-music 'TextSpanEvent 'span-direction -1)
55                                        (ly:music-property first-element 'elements)))
56                            (set! (ly:music-property last-element 'elements)
57                                  (cons (make-music 'TextSpanEvent 'span-direction 1)
58                                        (ly:music-property last-element 'elements)))))
59                      music)))
60              (make-music 'SequentialMusic
61                'origin location
62                'elements (list #{
63                         \once \override TextSpanner #'font-size = #-2
64                         \once \override TextSpanner #'font-shape = #'upright
65                         \once \override TextSpanner #'staff-padding = #3
66                         \once \override TextSpanner #'style = #'line
67                         \once \override TextSpanner #'to-barline = ##f
68                         \once \override TextSpanner #'bound-details =  #'((left (Y . 0) (padding . 0.25) (attach-dir . -2)) (right (Y . 0) (padding . 0.25) (attach-dir . 2)))
69                         \once  \override TextSpanner #'bound-details #'right #'text = \markup { \draw-line #'( 0 . -.5) }
70                         \once  \override TextSpanner #'bound-details #'left #'text =  \markup { \cWithSlash #str }
71 %% uncomment this line for make full barred
72                        % \once  \override TextSpanner #'bound-details #'left #'text =  \markup { "B" #str }
73                           #}
74     spanned-music))))
75
76 %% %%%%%%%  Cut here ----- End 'bbarred.ly'
77 %% Copy and change the last line for full barred. Rename in 'fbarred.ly'
78 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
79
80 %% Syntaxe: \bbarre #"text" { notes } - text = any number of box
81 \relative c'{ \clef "G_8" \stemUp \bbarre #"III" { <f a'>16[  c' d c d8] } }