lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: barré variables and TextSpanner


From: Nick Payne
Subject: Re: barré variables and TextSpanner
Date: Mon, 19 Nov 2012 05:36:48 +1100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121028 Thunderbird/16.0.2

On 18/11/12 23:11, Federico Bruni wrote:
> I'm currently using these simple variables to reduce the clutter in my
> files:
>
> barreI = \override TextSpanner #'(bound-details left text) = #"B I "
> barreII = \override TextSpanner #'(bound-details left text) = #"B II "
> barreIII = \override TextSpanner #'(bound-details left text) = #"B III "
> ...
>
> I'm ok with adding \startTextSpan and \stopTextSpan every time. I just
> wanted to save some space in the music input.
>
> Now I'd like to avoid this long list of frets and define a function
> which can take the fret as argument. So I can use:
>
> \barre #"I"
> \barre #"V"
>
> I think that it would be easier to maintain, but I don't know where to
> start.
> I've found this snippet in the LSR:
> http://lsr.dsi.unimi.it/LSR/Item?id=632
>
> But it's aimed at chords. Also, it works only in 2.14.2, not in 2.16

This is what I use. You can strip out what you don't want. The override
settings have been updated by convert-ly to the new format, and would
need to be changed back to the old format for 2.16 (eg TextSpanner
#'style instead of TextSpanner.style):

\version "2.17.6"

% Parameters:
% fretnum: the fret number for the barre - eg "VII"
% partial: the number of frets to cover - eg "4"
% osp: outside staff priority, in case this needs altering from the
default of 350
% dirn: #UP or #DOWN to place spanner above or below staff
% shorten: pair indicating left & right padding of TextSpanner
% adjBreak: adjust LH end of TextSpanner line when it has wrapped to
following stave
% adjEnd: adjustment of line end when it wraps to following stave
barc = #(define-music-function (parser location fretnum partial osp dirn
shorten adjBreak adjEnd)
    (string? string? number? number? pair? number? number?)
#{
    \once \override TextSpanner.outside-staff-priority = #osp
    \once \override TextSpanner.bound-details.left.text =
        \markup\small\bold { \concat { $fretnum \raise #0.8 \sub
$partial } }
    \once \override TextSpanner.style = #'line
    \once \override TextSpanner.font-shape = #'upright
    \once \override TextSpanner.direction = #dirn
    \once \override TextSpanner.bound-details.right.text = \markup {
\draw-line #(cons 0 (/ dirn -1)) }
    \once \override TextSpanner.bound-details.left.stencil-align-dir-y =
#0.35
    \once \override TextSpanner.bound-details.left.padding = #(car shorten)
    \once \override TextSpanner.bound-details.right.padding = #(cdr shorten)
    \once \override TextSpanner.bound-details.right-broken.padding = #adjEnd
    \once \override TextSpanner.bound-details.left-broken.X = #adjBreak
    \once \override TextSpanner.bound-details.left-broken.text = ##f
    \once \override TextSpanner.bound-details.right-broken.text = ##f
#})

\relative c'' {
  \barc "II" "5" #350 #UP #'(0 . -1) #7 #0.5 a4\startTextSpan a a
a\stopTextSpan
}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]