[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Barres and enclose-bounds
From: |
Nick Payne |
Subject: |
Re: Barres and enclose-bounds |
Date: |
Mon, 12 Jul 2010 07:05:53 +1000 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100528 Thunderbird/3.0.5 |
Here's another barre function:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% more attractive barring indication than the inbuilt one
% Parameters
%
% "<fretnum>" % fret number (eg "5")
% #osp % outside-staff-priority - normally set to #0
unless barre is colliding with other elements
% #dirn % set to #UP for above the staff, #DOWN for below
% #'(lpad . rpad) % left and right padding to apply to TextSpanner
(shorten or lengthen)
% #adjBreak % when barre wraps to following stave, set value
to prevent TextSpanner on following stave starting above the clef symbol
% #adjend % when barre wraps to following stave, set value to
prevent TextSpanner going to the very end of the stave
%
% Example:
% \barre "5" #0 #UP #'(-0.5 . -1) #8 #1
% <g,-2>\startTextSpan <c-3> <bf'-4>-> <ef,-1> <af-1>-> <c,-3>\stopTextSpan
%
barre = #(define-music-function (parser location fretnum osp dirn
shorten adjBreak adjEnd)
(string? number? number? pair? number? number?)
#{
\once \override TextSpanner #'outside-staff-priority = #$osp
\once \override TextSpanner #'bound-details #'left #'text =
\markup { \small { \concat { "C" "." $fretnum " " } } }
\once \override TextSpanner #'style = #'line
\once \override TextSpanner #'font-shape = #'upright
\once \override TextSpanner #'direction = #$dirn
%draw a bracket edge on RHS
\once \override TextSpanner #'bound-details #'right #'text =
\markup { \draw-line #(cons 0 (/ $dirn -1)) }
% set alignment of line with reference to left text
\once \override TextSpanner #'bound-details #'left
#'stencil-align-dir-y = #CENTER
% change X pos of LH and RH end as desired
\once \override TextSpanner #'bound-details #'left #'padding =
#(car $shorten)
\once \override TextSpanner #'bound-details #'right #'padding =
#(cdr $shorten)
% allow adjustment of line end when it wraps to following stave
\once \override TextSpanner #'bound-details #'right-broken
#'padding = #$adjEnd
% adjust LH end of line when it wraps to following stave so that it
doesn't
% extend to the left of the notes on the stave
\once \override TextSpanner #'bound-details #'left-broken #'X =
#$adjBreak
% optional override to remove text and bracket edge at line breaks
\once \override TextSpanner #'bound-details #'left-broken #'text = ##f
\once \override TextSpanner #'bound-details #'right-broken #'text = ##f
#})
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
and here's one for half barres that slashes the C and subscripts the
number of strings covered:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% postscript slash for half barres
#(define slash "0.18 setlinewidth 0.76 1.53 moveto 0 -1.62 rlineto stroke")
%
% Half barre
% Parameters
%
% "<fretnum>" % fret number (eg "5")
% "<partial>" % number of strings to cover - subscripted to the
fret number
% #osp % outside-staff-priority - normally set to #0
unless barre is colliding with other elements
% #dirn % set to #UP for above the staff, #DOWN for below
% #'(lpad . rpad) % left and right padding to apply to TextSpanner
(shorten or lengthen)
% #adjBreak % when barre wraps to following stave, set value
to prevent TextSpanner on following stave starting above the clef symbol
% #adjend % when barre wraps to following stave, set value to
prevent TextSpanner going to the very end of the stave
%
% Example:
% \hbarre "5" "3" #0 #UP #'(-0.5 . -1) #8 #1
% <g,-2>\startTextSpan <c-3> <bf'-4>-> <ef,-1> <af-1>-> <c,-3>\stopTextSpan
%
hbarre = #(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 { \concat { \postscript #slash "C" "." $fretnum
\raise #0.8 \sub $partial " " } } }
\once \override TextSpanner #'style = #'line
\once \override TextSpanner #'font-shape = #'upright
\once \override TextSpanner #'direction = #$dirn
%draw a bracket edge on RHS
\once \override TextSpanner #'bound-details #'right #'text =
\markup { \draw-line #(cons 0 (/ $dirn -1)) }
% set alignment of line with reference to left text
\once \override TextSpanner #'bound-details #'left
#'stencil-align-dir-y = #CENTER
% change X pos of LH and RH end as desired
\once \override TextSpanner #'bound-details #'left #'padding =
#(car $shorten)
\once \override TextSpanner #'bound-details #'right #'padding =
#(cdr $shorten)
% allow adjustment of line end when it wraps to following stave
\once \override TextSpanner #'bound-details #'right-broken
#'padding = #$adjEnd
% adjust LH end of line when it wraps to following stave so that it
doesn't
% extend to the left of the notes on the stave
\once \override TextSpanner #'bound-details #'left-broken #'X =
#$adjBreak
% optional override to remove text and bracket edge at line breaks
\once \override TextSpanner #'bound-details #'left-broken #'text = ##f
\once \override TextSpanner #'bound-details #'right-broken #'text = ##f
#})
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Nick
On 11/07/10 22:20, Phil Burfitt wrote:
Hi Paul,
Here's my barre function (takes care of breaks as well). Hope it can
be of some help or at least give you some ideas...
barre = #(define-music-function (parser location padding text)
(number? string?)
#{
\once \override TextSpanner #'font-size = #-0.5
\once \override TextSpanner #'padding = #$padding
\once \override TextSpanner #'(bound-details left text) = #$text
\once \override TextSpanner #'(bound-details left padding) = #-0.5
\once \override TextSpanner #'(bound-details left-broken text) =
\markup { \null }
\once \override TextSpanner #'(bound-details left-broken padding) = #0
\once \override TextSpanner #'font-shape = #'upright
\once \override TextSpanner #'style = #'line
%\once \override TextSpanner #'style = #'dashed-line
%\once \override TextSpanner #'dash-period = #0.8
%\once \override TextSpanner #'dash-fraction = #0.2
\once \override TextSpanner #'(bound-details left stencil-align-dir-y)
= #CENTER
\once \override TextSpanner #'(bound-details right text) = \markup {
\draw-line #'(0 . -0.4) }
\once \override TextSpanner #'(bound-details right padding) = #-1.0
\once \override TextSpanner #'(bound-details right-broken text) =
\markup { \null }
\once \override TextSpanner #'(bound-details right-broken padding) = #0
#})
startBarre = \startTextSpan
stopBarre = \stopTextSpan
To use: \barre #4 "CV" (first argument = vertical padding, second
argument = barre text)
Example:
\relative c' = {
\stemDown
\barre #4 "CV "
a'\startBarre c e a\stopBarre
}
If you prefer dotted/dashed lines then you can uncomment the style,
dash-period and dash-fraction lines.
Hope it helps.
Phil.