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