lilypond-user
[Top][All Lists]
Advanced

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

Re: text spanning


From: Hugh Myers
Subject: Re: text spanning
Date: Fri, 27 Nov 2009 19:02:18 -0700

Worked fine on supplied example. Does not work at all well on the
piece I'm working on. This:

\version "2.13.7"

tspan = #(define-music-function (parser location text osp dirn shorten
adjBreak adjEnd) (string? number? number? pair? number? number?) #{
  % set osp to 999 if spanner is colliding with another element
  % this will position the spanner outside all other elements
  % can be normally be set to zero
  \once \override TextSpanner #'outside-staff-priority = #$osp
  \once \override TextSpanner #'bound-details #'left #'text =
\markup\italic\small { \concat { { $text } " " } }
  \once \override TextSpanner #'font-shape = #'upright
  % direction (either #UP or #DOWN)
  \once \override TextSpanner #'direction = #$dirn
  % setup dashed line and draw a bracket edge on RHS
  \once \override TextSpanner #'dash-period = #1.5
  \once \override TextSpanner #'dash-fraction = #0.3
  \once \override TextSpanner #'thickness = #0.8
  \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
  \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
#})

chord = < e b gis e b e, >
upper = {
  \tempo 4=90
  \chord \chord \chord
  \repeat volta 2 {
    \tempo 4=200
    b c d
    d c b
    c a b
    \acciaccatura d8 \voiceOne c4 b a
    b a g
    a g f
  }
  \alternative {
    { r4 \times 2/3 { gis8 \startTextSpan b e } e,4 \times 2/3 { gis8
b e } e,2 }
    {
      \repeat volta 2 {
        \bar ":|.|:"
        { e8 [e'] gis, [e'] b [e] }
        e,8 [e'] gis, [e'] b [e]
        a,8 [e'] c [e] b [e]
        a,8 [e'] g, [e'] f, [e']
      }
    }
  }
  e,8 [e'] gis, [e'] b [e]
  d8 [e] c [e] b [e]
  c8 [e] a, [e'] b [e]
  c8 [e] b [e] a, [e']
  b8 [e] a, [e'] g, [e']
  a,8 [e'] g, [e'] f, [e']
  e,4 gis b
  \stopTextSpan
  < e b gis e b e, >2.
}

lower = {
  s2.
  <gis, d e, >2.
  e,2.
  a2.
  a2.
  g2.
  f2.
  { e2.~e2. }
  s2.
  s2.
  s2.
  s2.
  s2.
  s2.
  s2.
  s2.
  s2.
  s2.
}

{
  \time 3/4
  \set Score.barNumberVisibility = #all-bar-numbers-visible
  \bar ""
  \set Score.voltaSpannerDuration = #(ly:make-moment 3 4)
  \tspan "let ring" #0 #DOWN #'(0 . -0.5) #5 #1
  <<
  \new Staff \relative c'' {
    <<
      \new Voice = "1" { \voiceOne \upper }
      \new Voice = "2" { \voiceTwo \lower }
    >>
  }
  \new TabStaff \relative c' {
    <<
      \new TabVoice = "t1" { \voiceOne \upper }
      \new TabVoice = "t2" { \voiceTwo \lower }
    >>
  }
  >>
}

Doesn't work. Missing text element and from the looks of things is
seriously confused by the presence of the tablature staff. Also the
location of the dashes on wrapped lines indicates that they will be in
the wrong place--- although this could be related to the missing text
element? Hints?

--hsm

On Fri, Nov 27, 2009 at 6:18 PM, Hugh Myers <address@hidden> wrote:
> Commenting out the last two lines works just fine.
>
> --hsm
>
> On Fri, Nov 27, 2009 at 6:16 PM, Hugh Myers <address@hidden> wrote:
>> I'll try both as needed... and let you know.
>>
>> --hsm
>>
>> On Fri, Nov 27, 2009 at 5:34 PM, Nick Payne <address@hidden> wrote:
>>> To get the text repeated on each line, you either comment out last two lines
>>> in the function or change the override value to ##t, I can't remember which.
>>>
>>> Nick
>>>
>>> Hugh Myers wrote:
>>>>
>>>> Is there a way to repeat the text automagically with each wrap?
>>>>
>>>> --hsm
>>>>
>>>>
>>>> On Fri, Nov 27, 2009 at 12:24 PM, Hugh Myers <address@hidden> wrote:
>>>>
>>>>>
>>>>> Lovely! Much thanks Nick--- also nice to have code to examine prior to
>>>>> the point I need to roll my own :)
>>>>>
>>>>> --hsm
>>>>>
>>>>> On Fri, Nov 27, 2009 at 12:20 PM, Nick Payne
>>>>> <address@hidden> wrote:
>>>>>
>>>>>>
>>>>>> Hugh Myers wrote:
>>>>>>
>>>>>>>
>>>>>>> Perhaps I misunderstand your reply, but bar 14(where the problem is)
>>>>>>> has nothing to do with a rest. The text starts where (as you say) I
>>>>>>> wanted it to. That is not the problem. What is the problem is the
>>>>>>> continuation of the spanning text at bar 14--- here it starts outside
>>>>>>> in the margin instead of being aligned beneath a note. Is this
>>>>>>> behavior controllable?
>>>>>>>
>>>>>>
>>>>>> See music function below that I wrote for creating text spanners with
>>>>>> arbitrary text. It allows you to specify as parameters:
>>>>>>
>>>>>> The starting text
>>>>>> The outside staff priority
>>>>>> Whether the spanner is above or below the stave
>>>>>> The amount by which you want to adjust the left and right ends of the
>>>>>> spanner
>>>>>> The amount by which you want to adjust the left and right point at which
>>>>>> the
>>>>>> spanner breaks when it crosses a line break
>>>>>>
>>>>>> % usage e.g.:
>>>>>> %   \tspan "sul ponticello" #0 #DOWN #'(0 . -0.5) #5 #1
>>>>>> %   g\startTextSpan c bes' ees, aes c, g c bes' ees, aes c,\stopTextSpan
>>>>>> tspan = #(define-music-function (parser location text osp dirn shorten
>>>>>> adjBreak adjEnd) (string? number? number? pair? number? number?) #{
>>>>>>  % set osp to 999 if spanner is colliding with another element
>>>>>>  % this will position the spanner outside all other elements
>>>>>>  % can be normally be set to zero
>>>>>>  \once \override TextSpanner #'outside-staff-priority = #$osp
>>>>>>  \once \override TextSpanner #'bound-details #'left #'text =
>>>>>> \markup\italic\small\bold { \concat { { $text } " " } }
>>>>>>  \once \override TextSpanner #'font-shape = #'upright
>>>>>>  % direction (either #UP or #DOWN)
>>>>>>  \once \override TextSpanner #'direction = #$dirn
>>>>>>  % setup dashed line and draw a bracket edge on RHS
>>>>>>  \once \override TextSpanner #'dash-period = #1.5
>>>>>>  \once \override TextSpanner #'dash-fraction = #0.3
>>>>>>  \once \override TextSpanner #'thickness = #0.8
>>>>>>  \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
>>>>>>  \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
>>>>>> #})
>>>
>>>
>>
>




reply via email to

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