X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Documentation%2Fsnippets%2Fbar-chords-notation-for-guitar--with-text-spanner.ly;h=8a99e867cdb5be0d1df4eee7e33f6d94195554af;hb=1999a1bdb8c925ca279d79b330ba6497200445eb;hp=cc396fa6ba4200311342ecec72b430f949e0342e;hpb=248b82c3b9dcecf96351ad5f22540325fa54ad88;p=lilypond.git diff --git a/Documentation/snippets/bar-chords-notation-for-guitar--with-text-spanner.ly b/Documentation/snippets/bar-chords-notation-for-guitar--with-text-spanner.ly index cc396fa6ba..8a99e867cd 100644 --- a/Documentation/snippets/bar-chords-notation-for-guitar--with-text-spanner.ly +++ b/Documentation/snippets/bar-chords-notation-for-guitar--with-text-spanner.ly @@ -1,7 +1,11 @@ -%% Do not edit this file; it is automatically -%% generated from LSR http://lsr.dsi.unimi.it -%% This file is in the public domain. -\version "2.13.10" +% DO NOT EDIT this file manually; it is automatically +% generated from Documentation/snippets/new +% Make any changes in Documentation/snippets/new/ +% and then run scripts/auxiliar/makelsr.py +% +% This file is in the public domain. +%% Note: this file works from version 2.15.30 +\version "2.15.30" \header { lsrtags = "chords, fretted-strings" @@ -10,74 +14,54 @@ Here is how to print bar chords, or half-bar chords (just uncomment the appropriate line for to select either one). -The syntax is @code{\\bbarre #'fret_number' @{ notes @} } - - - - +The syntax is @code{\\bbarre #\"@var{fret number}\" @{ notes @} }. " - doctitle = "Bar chords notation for Guitar ( with Text Spanner)" + doctitle = "Bar chords notation for Guitar (with Text Spanner)" } % begin verbatim + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %%%%%%% Cut here ----- Start 'bbarred.ly' -%% PostScript ------------------------------- -pScript= \markup { - \with-dimensions #'(0 . 0.8) #'(0 . 2.0) - \postscript #" - 0.15 setlinewidth - /Times-Roman findfont - 2.0 scalefont - setfont - (C)show %%change with B if you prefer - %(B)show %%change with C if you prefer - stroke - 0.7 -0.5 moveto - 0.7 1.7 lineto - stroke" +%% C with slash ------------------------------- +cWithSlash = \markup { + \combine \roman C \translate #'(0.6 . -0.4) \draw-line #'(0 . 2.0) } %% Span ----------------------------------- %% Syntax: \bbarre #"text" { notes } - text = any number of box -bbarre= #(define-music-function (barre location str music) (string? ly:music?) - (let ((spanned-music - (let ((first-element #f) - (last-element #f) - (first-found? #f)) - (music-map (lambda (m) - (if (eqv? (ly:music-property m 'name) 'EventChord) - (begin - (if (not first-found?) - (begin - (set! first-found? #t) - (set! first-element m))) - (set! last-element m))) - m) - music) - (if first-found? - (begin - (set! (ly:music-property first-element 'elements) - (cons (make-music 'TextSpanEvent 'span-direction -1) - (ly:music-property first-element 'elements))) - (set! (ly:music-property last-element 'elements) - (cons (make-music 'TextSpanEvent 'span-direction 1) - (ly:music-property last-element 'elements))))) - music))) - (make-music 'SequentialMusic - 'origin location - 'elements (list #{ - \once \override TextSpanner #'font-size = #-2 - \once \override TextSpanner #'font-shape = #'upright - \once \override TextSpanner #'staff-padding = #3 - \once \override TextSpanner #'style = #'line - \once \override TextSpanner #'to-barline = ##f - \once \override TextSpanner #'bound-details = #'((left (Y . 0) (padding . 0.25) (attach-dir . -2)) (right (Y . 0) (padding . 0.25) (attach-dir . 2))) - \once \override TextSpanner #'bound-details #'right #'text = \markup { \draw-line #'( 0 . -.5) } - \once \override TextSpanner #'bound-details #'left #'text = \markup { \pScript $str } +bbarre = +#(define-music-function (barre location str music) (string? ly:music?) + (let ((elts (extract-named-music music '(NoteEvent EventChord)))) + (if (pair? elts) + (let ((first-element (first elts)) + (last-element (last elts))) + (set! (ly:music-property first-element 'articulations) + (cons (make-music 'TextSpanEvent 'span-direction -1) + (ly:music-property first-element 'articulations))) + (set! (ly:music-property last-element 'articulations) + (cons (make-music 'TextSpanEvent 'span-direction 1) + (ly:music-property last-element 'articulations)))))) + #{ + \once \override TextSpanner #'font-size = #-2 + \once \override TextSpanner #'font-shape = #'upright + \once \override TextSpanner #'staff-padding = #3 + \once \override TextSpanner #'style = #'line + \once \override TextSpanner #'to-barline = ##f + \once \override TextSpanner #'bound-details = + #`((left + (text . ,#{ \markup { \draw-line #'( 0 . -.5) } #}) + (Y . 0) + (padding . 0.25) + (attach-dir . -2)) + (right + (text . ,#{ \markup { \cWithSlash #str } #}) + (Y . 0) + (padding . 0.25) + (attach-dir . 2))) %% uncomment this line for make full barred - % \once \override TextSpanner #'bound-details #'left #'text = \markup { "B" $str } - #} - spanned-music)))) + % \once \override TextSpanner #'bound-details #'left #'text = \markup { "B" #str } + $music + #}) %% %%%%%%% Cut here ----- End 'bbarred.ly' %% Copy and change the last line for full barred. Rename in 'fbarred.ly'