]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/snippets/new/bar-chords-notation-for-guitar--with-text-spanner.ly
Rerun scripts/auxiliar/update-with-convert-ly.sh
[lilypond.git] / Documentation / snippets / new / bar-chords-notation-for-guitar--with-text-spanner.ly
1 \version "2.17.6"
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 #\"@var{fret number}\" @{ notes @} }.
11 "
12   doctitle = "Bar chords notation for Guitar (with Text Spanner)"
13 }
14
15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16 %% %%%%%%%  Cut here ----- Start 'bbarred.ly'
17
18 %% C with slash -------------------------------
19 cWithSlash = \markup {
20   \combine \roman C \translate #'(0.6 . -0.4) \draw-line #'(0 . 2.0)
21 }
22 %% Span -----------------------------------
23 %% Syntax: \bbarre #"text" { notes } - text = any number of box
24 bbarre =
25 #(define-music-function (barre location str music) (string? ly:music?)
26    (let ((elts (extract-named-music music '(NoteEvent EventChord))))
27      (if (pair? elts)
28          (let ((first-element (first elts))
29                (last-element (last elts)))
30            (set! (ly:music-property first-element 'articulations)
31                  (cons (make-music 'TextSpanEvent 'span-direction -1)
32                        (ly:music-property first-element 'articulations)))
33            (set! (ly:music-property last-element 'articulations)
34                  (cons (make-music 'TextSpanEvent 'span-direction 1)
35                        (ly:music-property last-element 'articulations))))))
36    #{
37        \once \override TextSpanner.font-size = #-2
38        \once \override TextSpanner.font-shape = #'upright
39        \once \override TextSpanner.staff-padding = #3
40        \once \override TextSpanner.style = #'line
41        \once \override TextSpanner.to-barline = ##f
42        \once \override TextSpanner.bound-details =
43             #`((left
44                 (text . ,#{ \markup { \draw-line #'( 0 . -.5) } #})
45                 (Y . 0)
46                 (padding . 0.25)
47                 (attach-dir . -2))
48                (right
49                 (text . ,#{ \markup { \cWithSlash #str } #})
50                 (Y . 0)
51                 (padding . 0.25)
52                 (attach-dir . 2)))
53 %% uncomment this line for make full barred
54        % \once  \override TextSpanner.bound-details.left.text =  \markup { "B" #str }
55        $music
56    #})
57
58 %% %%%%%%%  Cut here ----- End 'bbarred.ly'
59 %% Copy and change the last line for full barred. Rename in 'fbarred.ly'
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61
62 %% Syntaxe: \bbarre #"text" { notes } - text = any number of box
63 \relative c'{ \clef "G_8" \stemUp \bbarre #"III" { <f a'>16[  c' d c d8] } }