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