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