Re: Text centralized above a TextSpan

2015-09-23 Thread Simon Albrecht

On 23.09.2015 01:20, David Kastrup wrote:

Simon Albrecht  writes:


I made an essay on a simpler input interface, which redefines
\startTextSpan as a music function. That would be much preferable at
least in my eyes. What do you think?
(I hope there wouldn’t be any merge conflicts here…)
However, I’m having a problem with this syntax: the attached file
gives lots of

"text-spanner-inner-text-lyric-mode.ly:615:5: error: wrong type for
argument 3.  Expecting music, found #>
   c1
 \startTextSpan \lyricmode { ral -- len -- tan -- do }"

upon compiling. And I don’t know what my mistake would be…

It's the last line before %%% EXAMPLES where you enter some strange
recursion.  You probably should first save the old value of
\startTextSpan in some differently named variable and use that.  But
really: reusing an existing command name is a bad idea to start with.



I think it’s eventually a good idea to replace the definition of 
\startTextSpan, firstly because it’s the most convenient sort of 
interface for this custom function. And secondly: _Any_ sensible use of 
text spanners now requires a quite complicated \override, even most 
common cases:

%%%
\relative {
  \override TextSpanner.bound-details.left.text = "rit."
  b'1\startTextSpan
  e,\stopTextSpan
}
%%%
Being able to input the same as
%%%
\relative {
  b'1\startTextSpan \lyricmode { rit. }
  e,\stopTextSpan
}
%%%
would be a huge improvement IMO.
I think it’s not often that one only needs a text to end the spanner, so
\startTextSpan \lyricmode { "" -- "back to normal" }
would be acceptable.

Drawback: it’s impossible to provide backward compatibility then, isn’t it?

But you were right and storing the default value in an extra variable 
solved the problem. I overlooked that I was introducing a recursion 
instead of redefining a variable. Thanks.


Yours, Simon

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-22 Thread Trevor Daniels

David Nalesnik wrote Monday, September 21, 2015 5:13 PM

> I'm attaching a rewrite of the code which allows an easy mix of 
> markups/strings and interprets hyphens as connectors.  
> Now there's no need for a TextSpanner.connectors property.

... and hardly any need for the text-spanner-line-count, as it's easy
to split up the text by system (since manual breaks are needed
anyway to control the placement) like this:

music = \relative {
%  \override TextSpanner.text-spanner-line-count = #'(8 5)
  \addTextSpannerText \lyricmode {
\markup \fontsize #1 \upright \smallCaps Abe:
"Say" "this" "over" "measures" "one" "and" "two"
  }
  <>\startTextSpan 
  a'4 a a a
  a4 a a a
  \stopTextSpan
  \break
  \addTextSpannerText \lyricmode {
"and" "this" "over" "measure" "three"
  }
  <>\startTextSpan
  a4 a a a
  \stopTextSpan
}

A function to split text at white space rather than having to surround
each word with quotes would make this quite useable, I think.
Certainly better than the way I did it in the NR.

One problem remains: the text overlaps if there is not enough room,
for example with ragged-right.  This would be a nuisance for the
examples in the manuals, but in real scores ragged-right is not usually
used.

Trevor
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-22 Thread David Nalesnik
On Tue, Sep 22, 2015 at 4:23 PM, Simon Albrecht 
wrote:

I made an essay on a simpler input interface, which redefines
> \startTextSpan as a music function. That would be much preferable at least
> in my eyes. What do you think?


If you can get this working, it would be a nice improvement!
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-22 Thread Simon Albrecht

On 21.09.2015 18:13, David Nalesnik wrote:



On Mon, Sep 21, 2015 at 8:41 AM, David Kastrup > wrote:


David Nalesnik > writes:

> Here's a preliminary experiment with using \lyricmode as an
input device
> for text spanner details.  It could easily be incorporated into
the larger
> function, but I've pared this down to ask a question.
>
> Is it possible to avoid needing to type \lyricmode when calling
\test?

No.  Music functions don't get to choose the syntactic mode of their
arguments.  It would be rather tricky to figure out when to switch
back
and forth without causing tokens to be lexed in the wrong mode due to
lookahead.


I was initially worried that the presence of the word "lyric" would be 
a potential source of confusion for a user--who is not entering 
lyrics, after all.  But if we're going to use lyricmode, the command 
is a useful reminder. And, really, the improvement over the arcane 
entry of my last posted version is huge, so who cares about those 
extra characters.


I'm attaching a rewrite of the code which allows an easy mix of 
markups/strings and interprets hyphens as connectors.  Now there's no 
need for a TextSpanner.connectors property.


Duration info is easily available, as are skips.  I'm unsure at the 
moment how to use this info, though: whether there is more to be 
gleaned than simply using durations as a guide to relative spacing, 
whether using this info to position texts relative to notes is 
possible--or desirable.


This version also gives equal space between texts, promised earlier 
but not delivered.  (This justification looks immensely better when 
long texts are mixed with short.)


Great!

I made an essay on a simpler input interface, which redefines 
\startTextSpan as a music function. That would be much preferable at 
least in my eyes. What do you think?

(I hope there wouldn’t be any merge conflicts here…)
However, I’m having a problem with this syntax: the attached file gives 
lots of


"text-spanner-inner-text-lyric-mode.ly:615:5: error: wrong type for 
argument 3.  Expecting music, found #>

  c1
\startTextSpan \lyricmode { ral -- len -- tan -- do }"

upon compiling. And I don’t know what my mistake would be…

Best regards, Simon
\version "2.19.27"
%% CUSTOM GROB PROPERTIES

% Taken from http://www.mail-archive.com/lilypond-user%40gnu.org/msg97663.html
% (Paul Morris)

% function from "scm/define-grob-properties.scm" (modified)
#(define (cn-define-grob-property symbol type?)
   (set-object-property! symbol 'backend-type? type?)
   (set-object-property! symbol 'backend-doc "custom grob property")
   symbol)

% For internal use.
#(cn-define-grob-property 'text-spanner-stencils list?)

% user interface
#(cn-define-grob-property 'text-spanner-line-count number-list?)

% How much space between line and object to left and right?
% Default is '(0.0 . 0.0).
#(cn-define-grob-property 'line-X-offset number-pair?)

% Vertical shift of connector line, independenf of texts.
#(cn-define-grob-property 'line-Y-offset number?)

#(define (get-text-distribution text-list line-extents)
   ;; Given a list of texts and a list of line extents, attempt to
   ;; find a decent line distribution.  The goal is to put more texts
   ;; on longer lines, while ensuring that first and last lines are texted.
   ;; TODO: ideally, we should consider extents of text, rather than
   ;; simply their number.
   (let* ((line-count (length line-extents))
  (text-count (length text-list))
  (line-lengths
   (map (lambda (line) (interval-length line))
 line-extents))
  (total-line-len (apply + line-lengths))
  (exact-per-line
   (map (lambda (line-len)
  (* text-count (/ line-len total-line-len)))
 line-lengths))
  ;; First and last lines can't be untexted.
  (adjusted
   (let loop ((epl exact-per-line) (idx 0) (result '()))
 (if (null? epl)
 result
 (if (and (or (= idx 0)
  (= idx (1- line-count)))
  (< (car epl) 1))
 (loop (cdr epl) (1+ idx)
   (append result (list 1.0)))
 (loop (cdr epl) (1+ idx)
   (append result (list (car epl)

 ;; The idea is to raise the "most roundable" line's count, then the
 ;; "next most roundable," and so forth, until we account for all texts.
 ;; Everything else is rounded down (except those lines which need to be
 ;; bumped up to get the minimum of one text), so we shouldn't exceed our
 ;; total number of texts.
 ;; TODO: Need a promote-demote-until-flush to be safe, unless this is
 ;; mathematically sound!
 (define (promote-until-flush result)
   (let* ((floored (map floor result))
  

Re: Text centralized above a TextSpan

2015-09-22 Thread Simon Albrecht

On 22.09.2015 22:03, Trevor Daniels wrote:

David Nalesnik wrote Monday, September 21, 2015 5:13 PM


I'm attaching a rewrite of the code which allows an easy mix of
markups/strings and interprets hyphens as connectors.
Now there's no need for a TextSpanner.connectors property.

... and hardly any need for the text-spanner-line-count, as it's easy
to split up the text by system (since manual breaks are needed
anyway to control the placement) like this:

music = \relative {
%  \override TextSpanner.text-spanner-line-count = #'(8 5)
   \addTextSpannerText \lyricmode {
 \markup \fontsize #1 \upright \smallCaps Abe:
 "Say" "this" "over" "measures" "one" "and" "two"
   }
   <>\startTextSpan
   a'4 a a a
   a4 a a a
   \stopTextSpan
   \break
   \addTextSpannerText \lyricmode {
 "and" "this" "over" "measure" "three"
   }
   <>\startTextSpan
   a4 a a a
   \stopTextSpan
}


I don’t quite understand your reasoning here; in my eyes it’s better to 
have only one TextSpanner and override its text-spanner-line-count than 
to split up the spanners. David N.s examples show the use of this in 
conjunction with manual breaks, which works fine.


A function to split text at white space rather than having to surround
each word with quotes would make this quite useable, I think.


The quotes are unnecessary anyway (except if we want to use \markup): we 
are in lyricmode. They only stayed there as an oversight.



Certainly better than the way I did it in the NR.

One problem remains: the text overlaps if there is not enough room,


A known limitation: note spacing stays as-is.

Yours, Simon

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-22 Thread David Kastrup
Simon Albrecht  writes:

> I made an essay on a simpler input interface, which redefines
> \startTextSpan as a music function. That would be much preferable at
> least in my eyes. What do you think?
> (I hope there wouldn’t be any merge conflicts here…)
> However, I’m having a problem with this syntax: the attached file
> gives lots of
>
> "text-spanner-inner-text-lyric-mode.ly:615:5: error: wrong type for
> argument 3.  Expecting music, found # (arg)>>
>   c1
> \startTextSpan \lyricmode { ral -- len -- tan -- do }"
>
> upon compiling. And I don’t know what my mistake would be…

It's the last line before %%% EXAMPLES where you enter some strange
recursion.  You probably should first save the old value of
\startTextSpan in some differently named variable and use that.  But
really: reusing an existing command name is a bad idea to start with.

-- 
David Kastrup

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-22 Thread David Nalesnik
Hi Trevor,

On Tue, Sep 22, 2015 at 3:03 PM, Trevor Daniels 
wrote:


>
> ... and hardly any need for the text-spanner-line-count, as it's easy
> to split up the text by system (since manual breaks are needed
> anyway to control the placement) like this:
>
> music = \relative {
> %  \override TextSpanner.text-spanner-line-count = #'(8 5)
>   \addTextSpannerText \lyricmode {
> \markup \fontsize #1 \upright \smallCaps Abe:
> "Say" "this" "over" "measures" "one" "and" "two"
>   }
>   <>\startTextSpan
>   a'4 a a a
>   a4 a a a
>   \stopTextSpan
>   \break
>   \addTextSpannerText \lyricmode {
> "and" "this" "over" "measure" "three"
>   }
>   <>\startTextSpan
>   a4 a a a
>   \stopTextSpan
> }
>
>
>
[...]


> One problem remains: the text overlaps if there is not enough room,
> for example with ragged-right.  This would be a nuisance for the
> examples in the manuals, but in real scores ragged-right is not usually
> used.
>

Yes, this is really irksome, but it's a problem with ordinary text spanners
too.  They don't avoid text overlaps automatically.  The only corrective
for the problem is setting minimum-length.

{
  \override TextSpanner.bound-details.left.text = #"really long long text"
  \override TextSpanner.bound-details.right.text = #"overlapped"
  % gives 2 instances of strange error in 2.19.27; other versions?
  % programming error: mis-predicted force, 108.120472 ~= 139.065846
  %\override TextSpanner.minimum-length = 25
  %\override TextSpanner.springs-and-rods = #ly:spanner::set-spacing-rods
  c1\startTextSpan
  c1\stopTextSpan
}

In order to get independent line lengths for the musical theatre example,
you'd have to use two spanners as you do above.  I don't think \alterBroken
would work since minimum-length is set before line-breaking.

David
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-21 Thread David Kastrup
Simon Albrecht  writes:

> On 19.09.2015 22:48, David Kastrup wrote:
>> However, (re-)using engravers for the "picking apart" bit in a context
>> without its own vertical axis group might be an interesting option.
>> Want several text spanners?  Use several contexts.
>
> This reminds me: the ‘standard’ use case for this kind of text spanner
> is ri -- tar -- dan -- do or the like, i.e. actually a Tempo Spanner
> . It would make
> sense to have this in a separate context (TempoLine?) at the top of
> the system. However, as I already said in the issue, tempo spanners
> should correspond to MetronomeMarks in syntax, so this would require
> complete abandoning of the current \tempo syntax, wouldn’t it?
> Alternatively, we might retain the current method as is and add a new
> one with support for tempo spanners, entered in a manner alike to
> lyrics entering:
>
> %
> timeTrack = {
>   \time 3/4
>   Prestissimo2.
>   \bar "||"
>   \time 2/2
>   Larghetto1*4
>   ral2 -- len --
>   tan -- do
>   s1
>   \bar "|."
> }

More like

timeTrack = \lyricmode {
  \time 3/4
  Prestissimo2.
  \bar "||"
  \time 2/2
  Larghetto1*4
  ral2 -- len --
  tan -- do
  \skip 1
  \bar "|."
}

namely with some small changes bringing it back into the embrace of
currently supported syntax.

-- 
David Kastrup

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-21 Thread David Nalesnik
On Mon, Sep 21, 2015 at 8:17 AM, Simon Albrecht 
wrote:

> On 21.09.2015 15:04, David Nalesnik wrote:
>
>> Hi,
>>
>> On Sat, Sep 19, 2015 at 7:09 PM, David Nalesnik > > wrote:
>>
>>
>> OK, I see.  Using \lyricmode would be a user-friendly way to
>> specify markups/strings, connectors/no connectors, and relative
>> spacing of texts through attached durations (making the use of
>> spacers--somewhat awkward to handle--unnecessary).
>>
>>
>> Here's a preliminary experiment with using \lyricmode as an input device
>> for text spanner details.  It could easily be incorporated into the larger
>> function, but I've pared this down to ask a question.
>>
>> Is it possible to avoid needing to type \lyricmode when calling \test?
>>
>
> David K. will be able to answer this, but I may say: it’s possible to omit
> the {} around \lyricmode {} which already makes it nicer, and then typing
> \lyricmode has its advantages: it’s easier to understand, and easier to
> highlight syntax correctly.
>
>
Definitely softens the blow!  (While we're here--though it doesn't affect
the user--I should have omitted the "parser location" from the extractTexts
function.  New tricks, old dog.)

DN
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-21 Thread David Nalesnik
Hi,

On Sat, Sep 19, 2015 at 7:09 PM, David Nalesnik 
wrote:

> David,
>
> On Sat, Sep 19, 2015 at 3:48 PM, David Kastrup  wrote:
>
>> David Nalesnik  writes:
>>
>> > (As an aside: I must say that David's suggestion of using lyrics
>> > produces miraculous results without the hundreds and hundreds of lines
>> > of new code!  Don't want a connector line?  Don't write a hyphen.
>> > Etc.)
>>
>> Actually, we might have had some miscommunication.  I was not really
>> suggesting using a lyrics context, just \lyricsmode as a user interface.
>> The idea was more or less to pick the music expression apart and then
>> let your code do the work.
>>
>>
> OK, I see.  Using \lyricmode would be a user-friendly way to specify
> markups/strings, connectors/no connectors, and relative spacing of texts
> through attached durations (making the use of spacers--somewhat awkward to
> handle--unnecessary).
>
>

Here's a preliminary experiment with using \lyricmode as an input device
for text spanner details.  It could easily be incorporated into the larger
function, but I've pared this down to ask a question.

Is it possible to avoid needing to type \lyricmode when calling \test?

Thank you,
David


  \version "2.19.27"

#(define (get-text elt)
   (ly:music-property elt 'text))

#(define (extract-texts lst result)
   (cond
((null? lst) result)
((not (null? (get-text (car lst
 (extract-texts
  (cdr lst)
  (append result (list (get-text (car lst))
((ly:music-property (car lst) 'elements)
 (append
  (extract-texts (ly:music-property (car lst) 'elements) result)
  (extract-texts (cdr lst) '(
(else (extract-texts (cdr lst) result

extractTexts =
#(define-scheme-function
  (parser location lst)
  (ly:music?)
  (extract-texts
   (extract-named-music lst '(LyricEvent))
   '()))

test =
#(define-music-function (arg) (ly:music?)
   (let ((texts (extractTexts arg)))
 ;(display texts) (newline)
 #{
   \override TextSpanner.bound-details.left.text = #(car texts)
   \override TextSpanner.bound-details.right.text = #(last texts)
 #}))


{
  \test { \lyricmode { \markup { \with-color #red ri }4 -- tar -- dan -- do
} }
  c'1\startTextSpan
  d'1\stopTextSpan
}
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-21 Thread Simon Albrecht

On 21.09.2015 15:04, David Nalesnik wrote:

Hi,

On Sat, Sep 19, 2015 at 7:09 PM, David Nalesnik 
> wrote:



OK, I see.  Using \lyricmode would be a user-friendly way to
specify markups/strings, connectors/no connectors, and relative
spacing of texts through attached durations (making the use of
spacers--somewhat awkward to handle--unnecessary).


Here's a preliminary experiment with using \lyricmode as an input 
device for text spanner details.  It could easily be incorporated into 
the larger function, but I've pared this down to ask a question.


Is it possible to avoid needing to type \lyricmode when calling \test?


David K. will be able to answer this, but I may say: it’s possible to 
omit the {} around \lyricmode {} which already makes it nicer, and then 
typing \lyricmode has its advantages: it’s easier to understand, and 
easier to highlight syntax correctly.


Yours, Simon

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-21 Thread David Kastrup
David Nalesnik  writes:

> Definitely softens the blow!  (While we're here--though it doesn't
> affect the user--I should have omitted the "parser location" from the
> extractTexts function.  New tricks, old dog.)

In Germany, there is a sort of New Year's Eve tradition of broadcasting
(and viewing) a two-person sketch "Dinner for One" where a butler serves
"Miss Sophie" and her traditional guests all of which have passed away
since the tradition started and are substituted for by the butler who,
having to do the toasts for every missing party, becomes inebriated
rather speedily.

As a running gag, whenever the butler serves a new dish or drink, he
stumbles on the head of a tiger pelt, cursing it.  Near the end of the
sketch, he just walks past the head, to the surprise of everybody
including himself as stumbling over it has become part of the routine.

parser location.

-- 
David Kastrup

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-21 Thread David Nalesnik
On Mon, Sep 21, 2015 at 8:41 AM, David Kastrup  wrote:

> David Nalesnik  writes:
>
> > Here's a preliminary experiment with using \lyricmode as an input device
> > for text spanner details.  It could easily be incorporated into the
> larger
> > function, but I've pared this down to ask a question.
> >
> > Is it possible to avoid needing to type \lyricmode when calling \test?
>
> No.  Music functions don't get to choose the syntactic mode of their
> arguments.  It would be rather tricky to figure out when to switch back
> and forth without causing tokens to be lexed in the wrong mode due to
> lookahead.
>
>
I was initially worried that the presence of the word "lyric" would be a
potential source of confusion for a user--who is not entering lyrics, after
all.  But if we're going to use lyricmode, the command is a useful
reminder.  And, really, the improvement over the arcane entry of my last
posted version is huge, so who cares about those extra characters.

I'm attaching a rewrite of the code which allows an easy mix of
markups/strings and interprets hyphens as connectors.  Now there's no need
for a TextSpanner.connectors property.

Duration info is easily available, as are skips.  I'm unsure at the moment
how to use this info, though: whether there is more to be gleaned than
simply using durations as a guide to relative spacing, whether using this
info to position texts relative to notes is possible--or desirable.

This version also gives equal space between texts, promised earlier but not
delivered.  (This justification looks immensely better when long texts are
mixed with short.)

DN

%%%
\version "2.19.27"

 FUNCTIONS TO INCLUDE 

%% CUSTOM GROB PROPERTIES

% Taken from http://www.mail-archive.com/lilypond-user%40gnu.org/msg97663.html
% (Paul Morris)

% function from "scm/define-grob-properties.scm" (modified)
#(define (cn-define-grob-property symbol type?)
   (set-object-property! symbol 'backend-type? type?)
   (set-object-property! symbol 'backend-doc "custom grob property")
   symbol)

% For internal use.
#(cn-define-grob-property 'text-spanner-stencils list?)

% user interface
#(cn-define-grob-property 'text-spanner-line-count number-list?)

% How much space between line and object to left and right?
% Default is '(0.0 . 0.0).
#(cn-define-grob-property 'line-X-offset number-pair?)

% Vertical shift of connector line, independenf of texts.
#(cn-define-grob-property 'line-Y-offset number?)

#(define (get-text-distribution text-list line-extents)
   ;; Given a list of texts and a list of line extents, attempt to
   ;; find a decent line distribution.  The goal is to put more texts
   ;; on longer lines, while ensuring that first and last lines are texted.
   ;; TODO: ideally, we should consider extents of text, rather than
   ;; simply their number.
   (let* ((line-count (length line-extents))
  (text-count (length text-list))
  (line-lengths
   (map (lambda (line) (interval-length line))
 line-extents))
  (total-line-len (apply + line-lengths))
  (exact-per-line
   (map (lambda (line-len)
  (* text-count (/ line-len total-line-len)))
 line-lengths))
  ;; First and last lines can't be untexted.
  (adjusted
   (let loop ((epl exact-per-line) (idx 0) (result '()))
 (if (null? epl)
 result
 (if (and (or (= idx 0)
  (= idx (1- line-count)))
  (< (car epl) 1))
 (loop (cdr epl) (1+ idx)
   (append result (list 1.0)))
 (loop (cdr epl) (1+ idx)
   (append result (list (car epl)

 ;; The idea is to raise the "most roundable" line's count, then the
 ;; "next most roundable," and so forth, until we account for all texts.
 ;; Everything else is rounded down (except those lines which need to be
 ;; bumped up to get the minimum of one text), so we shouldn't exceed our
 ;; total number of texts.
 ;; TODO: Need a promote-demote-until-flush to be safe, unless this is
 ;; mathematically sound!
 (define (promote-until-flush result)
   (let* ((floored (map floor result))
  (total (apply + floored)))

 (if (>= total text-count)
 (begin
  ;(format #t "guess: ~a~%~%~%" result)
  floored)
 (let* ((decimal-amount
 (map (lambda (x) (- x (floor x))) result))
(maximum (apply max decimal-amount))
(max-location
 (list-index
  (lambda (x) (= x maximum))
  decimal-amount))
(item-to-bump (list-ref result max-location)))
   ;(format #t "guess: ~a~%" result)
   

Re: Text centralized above a TextSpan

2015-09-21 Thread David Nalesnik
On Mon, Sep 21, 2015 at 11:13 AM, David Nalesnik 
wrote:

>
>
> I'm attaching a rewrite of the code which allows an easy mix of
> markups/strings and interprets hyphens as connectors.  Now there's no need
> for a TextSpanner.connectors property.
>
>
I should mention that spacers need their own hyphen so the line is
continued:

 \addTextSpannerText \lyricmode { ral -- "" -- len -- tan -- do }


DN
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-21 Thread David Nalesnik
On Mon, Sep 21, 2015 at 9:09 AM, David Kastrup  wrote:

> David Nalesnik  writes:
>
> > Definitely softens the blow!  (While we're here--though it doesn't
> > affect the user--I should have omitted the "parser location" from the
> > extractTexts function.  New tricks, old dog.)
>
> In Germany, there is a sort of New Year's Eve tradition of broadcasting
> (and viewing) a two-person sketch "Dinner for One" where a butler serves
> "Miss Sophie" and her traditional guests all of which have passed away
> since the tradition started and are substituted for by the butler who,
> having to do the toasts for every missing party, becomes inebriated
> rather speedily.
>
> As a running gag, whenever the butler serves a new dish or drink, he
> stumbles on the head of a tiger pelt, cursing it.  Near the end of the
> sketch, he just walks past the head, to the surprise of everybody
> including himself as stumbling over it has become part of the routine.
>
> parser location.
>
>
Hastening the end of the sketch? ;)
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-21 Thread David Kastrup
David Nalesnik  writes:

> Here's a preliminary experiment with using \lyricmode as an input device
> for text spanner details.  It could easily be incorporated into the larger
> function, but I've pared this down to ask a question.
>
> Is it possible to avoid needing to type \lyricmode when calling \test?

No.  Music functions don't get to choose the syntactic mode of their
arguments.  It would be rather tricky to figure out when to switch back
and forth without causing tokens to be lexed in the wrong mode due to
lookahead.

-- 
David Kastrup

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-21 Thread David Kastrup
Michael Gerdau  writes:

>> Hastening the end of the sketch? ;)
>
> For those not knowing this classic, here is a YT link of not too good
> quality but which does transport the important parts:
> https://www.youtube.com/watch?v=NDqD0Dz_J-M

Ah, the Swiss recording.  It's rather condensed.  I'd rather go for one
of the versions recorded for German TV.  Of course, viewers in Germany
itself will be blocked from seeing those versions but they probably know
them by heart anyway.

-- 
David Kastrup

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-21 Thread Michael Gerdau
> Hastening the end of the sketch? ;)

For those not knowing this classic, here is a YT link of not too good
quality but which does transport the important parts:
https://www.youtube.com/watch?v=NDqD0Dz_J-M

Kind regards,
Michael
-- 
 Michael Gerdau   email: m...@qata.de
 GPG-keys available on request or at public keyserver

signature.asc
Description: This is a digitally signed message part.
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-20 Thread Simon Albrecht

On 19.09.2015 22:48, David Kastrup wrote:

However, (re-)using engravers for the "picking apart" bit in a context
without its own vertical axis group might be an interesting option.
Want several text spanners?  Use several contexts.


This reminds me: the ‘standard’ use case for this kind of text spanner 
is ri -- tar -- dan -- do or the like, i.e. actually a Tempo Spanner 
. It would make 
sense to have this in a separate context (TempoLine?) at the top of the 
system. However, as I already said in the issue, tempo spanners should 
correspond to MetronomeMarks in syntax, so this would require complete 
abandoning of the current \tempo syntax, wouldn’t it? Alternatively, we 
might retain the current method as is and add a new one with support for 
tempo spanners, entered in a manner alike to lyrics entering:


%
timeTrack = {
  \time 3/4
  Prestissimo2.
  \bar "||"
  \time 2/2
  Larghetto1*4
  ral2 -- len --
  tan -- do
  s1
  \bar "|."
}
music = \relative {
  c'4 e8 g c4
  e,2 fis4 gis
  a2 e
  c e4 c

  a2 a'4 g
  f2 g
  a h
  c1\fermata
}

\score {
  <<
\new TempoLine \timeTrack
\new Staff \music
  >>
}
%

Which looks promising, if you ask me…

Yours, Simon

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-19 Thread David Nalesnik
David,

On Sat, Sep 19, 2015 at 3:48 PM, David Kastrup  wrote:

> David Nalesnik  writes:
>
> > (As an aside: I must say that David's suggestion of using lyrics
> > produces miraculous results without the hundreds and hundreds of lines
> > of new code!  Don't want a connector line?  Don't write a hyphen.
> > Etc.)
>
> Actually, we might have had some miscommunication.  I was not really
> suggesting using a lyrics context, just \lyricsmode as a user interface.
> The idea was more or less to pick the music expression apart and then
> let your code do the work.
>
>
OK, I see.  Using \lyricmode would be a user-friendly way to specify
markups/strings, connectors/no connectors, and relative spacing of texts
through attached durations (making the use of spacers--somewhat awkward to
handle--unnecessary).


> However, (re-)using engravers for the "picking apart" bit in a context
> without its own vertical axis group might be an interesting option.
> Want several text spanners?  Use several contexts.


I'll need to experiment a bit before I can say I understand!

Thanks,
David
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-19 Thread Trevor Daniels

David Nalesnik wrote Saturday, September 19, 2015 7:14 PM

On Sat, Sep 19, 2015 at 12:10 PM, David Kastrup  wrote:

> "Trevor Daniels"  writes:
>
>> http://www.lilypond.org/doc/v2.19/Documentation/notation/opera-and-stage-musicals#dialogue-over-music
>>
>> I'd like to see this developed and added to LP core.
>>
> Right now LyricHyphen will draw something resembling the spanner line, 
> but comprised of a succession of round-filled boxes.  

Actually for the purpose I had in mind (words over music but spoken and out of 
rhythm)
we wouldn't need a spanner line, just the spaced-out text.
 
> Here's a sketch: [snipped]

Using lyrics with explicit durations is the way it's done in the NR now, but 
it's
difficult to set up and prone to not working under some circumstances.  The
automatic spacing over several lines was the attractive feature of your
TextSpan code. 

Trevor
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-19 Thread Kieren MacMillan
Hi Trevor (et al.),

> Actually for the purpose I had in mind (words over music but spoken and out 
> of rhythm)
> we wouldn't need a spanner line, just the spaced-out text.

After David N. made his wonderful MeasureAttachedSpanner for me, we spoke 
(briefly) of how it might be taken “to the goal line” — which would include (I 
believe) the kind of thing you’re talking about / hoping for.

Let’s brainstorm a bunch of use cases, and see what we can do about getting 
them all handled [well] by a single grob/mechanism.

Cheers,
Kieren.


Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-19 Thread David Nalesnik
Hi Trevor,

On Sat, Sep 19, 2015 at 1:49 PM, Trevor Daniels 
wrote:

>
> David Nalesnik wrote Saturday, September 19, 2015 7:14 PM
>
> On Sat, Sep 19, 2015 at 12:10 PM, David Kastrup  wrote:
>
> [...]


> > Right now LyricHyphen will draw something resembling the spanner line,
> > but comprised of a succession of round-filled boxes.
>
> Actually for the purpose I had in mind (words over music but spoken and
> out of rhythm)
> we wouldn't need a spanner line, just the spaced-out text.
>
>
 I could easily allow a switch to turn off all connectors.


> Using lyrics with explicit durations is the way it's done in the NR now,
> but it's
> difficult to set up and prone to not working under some circumstances.  The
> automatic spacing over several lines was the attractive feature of your
> TextSpan code.
>
>
To do that, you'd need to split the text up into individual words.  That
could get irritating, but it wouldn't be hard to break long strings up by
whitespace, or some other alternative.

This should give acceptable results, with two conditions:

(1) items will be equally spaced;
(2) Items are currently parceled out between lines solely based on their
number, as if they were equal in length.  The distribution algorithm ought
to take word-length into account, and I wonder if my math is up to that :(

(As an aside: I must say that David's suggestion of using lyrics produces
miraculous results without the hundreds and hundreds of lines of new code!
Don't want a connector line?  Don't write a hyphen.  Etc.)

David
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-19 Thread David Nalesnik
On Sat, Sep 19, 2015 at 12:10 PM, David Kastrup <d...@gnu.org> wrote:

> "Trevor Daniels" <t.dani...@treda.co.uk> writes:
>
> >
> http://www.lilypond.org/doc/v2.19/Documentation/notation/opera-and-stage-musicals#dialogue-over-music
> >
> > I'd like to see this developed and added to LP core.
> >
> > Trevor
> >
> >   - Original Message -
> >   From: David Nalesnik
> >   To: Simon Albrecht
> >   Cc: lilypond-user
> >   Sent: Friday, September 18, 2015 11:58 PM
> >   Subject: Re: Text centralized above a TextSpan
> >
> >
> >   Hi,
> >
> >
> >   Alright!  This should do it...
> >
> >
> >   You can:
> >
> >
> >   --Adapt this for versions < 2.19.27 with a loss of overriding power
> > (style, dash-fraction, etc.)--see comments beginning in line 435
> >
> >
> >   --Use/mix markups and strings.
> >
> >
> >   --Specify any number of texts >= 2 for your spanner.
> >
> >
> >   --Break it across an arbitrary number of lines, with an acceptable
> > distribution.
> >
> >
> >   --Use spacers ("") to force texts closer/farther apart.  You can
> > also move them like this:
> >   \markup \translate [...]
> >   \markup \right-align [...]
> >   etc.
> >
> >
> >   --Override the number of texts per line if you don't like the
> > automatic distribution.  There's a warning if the numbers don't tally.
> >
> >
> >   --Specify which texts will be joined by a line and which won't using
> > TextSpanner.connectors. I noticed this request in another related
> > thread:
> >   http://www.mail-archive.com/lilypond-user%40gnu.org/msg103939.html
>
> Well, it looks to me like being able to use something in \lyricsmode
> would be useful for specifying extenders, hyphens, rhythmic
> distribution, text without creating lots of new commands and properties
> for the user.
>
>
Right now LyricHyphen will draw something resembling the spanner line, but
comprised of a succession of round-filled boxes.  An enhancement of the
stencil callback would be needed to allow for all the possibilities of
TextSpanner, 'style, for example.

Here's a sketch:


\version "2.19.27"  %%% REQUIRED

#(define (connector grob)
   (let* ((lb (ly:spanner-bound grob LEFT))
  (rb (ly:spanner-bound grob RIGHT))
  (common-x (ly:grob-common-refpoint lb rb X))
  (l-ext (ly:grob-extent lb common-x X))
  (r-ext (ly:grob-extent rb common-x X))
  (x-coord (ly:grob-relative-coordinate lb common-x X)))
 (ly:stencil-translate-axis
  (ly:line-interface::line grob (cdr l-ext) 0.0 (car r-ext) 0.0)
  (- x-coord)
  X)))
<<
  \new Lyrics \lyricmode {
%\once \override LyricText.self-alignment-X = #RIGHT
"rit"1*2 --
"tar"2*5 --
"dan"2*3 --
"do"1
  }
  \new Staff {
c2 c
c2 c
c2 c
c2 c
\break
c2 c
c2 c
c2 c
c2 c
  }
>>

\layout {
  \context {
\Lyrics
\override LyricHyphen.style = #'dashed-line
\override LyricHyphen.dash-fraction = 0.2
\override LyricHyphen.dash-period = 3.0
\override LyricText.font-shape = #'italic
\override LyricHyphen.stencil = #connector
  }
}

%%%

DN
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-19 Thread David Nalesnik
On Sat, Sep 19, 2015 at 1:14 PM, David Nalesnik 
wrote:

Right now LyricHyphen will draw something resembling the spanner line, but
> comprised of a succession of round-filled boxes.  An enhancement of the
> stencil callback would be needed to allow for all the possibilities of
> TextSpanner, 'style, for example.
>
> Here's a sketch:
>
>
Image attached.
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-19 Thread Kieren MacMillan
Hi David,

> Alright!  This should do it…

Amazing! (As always…)

> Change the distance from text to line with TextSpanner.line-offset, which 
> defaults to #'(0.0 . 0.0).

Love this. Is there a tweak for the vertical position of the line (independent 
of the text)?

> P.S.  One area of further improvement would be the input syntax.  Any 
> suggestions for making this more user-friendly?

As I play with it, I’ll see what I can come up with.

Many thanks for this!
Kieren.


Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-19 Thread David Nalesnik
Hi Kieren,

On Sat, Sep 19, 2015 at 5:56 AM, Kieren MacMillan <
kieren_macmil...@sympatico.ca> wrote:

>
> > Change the distance from text to line with TextSpanner.line-offset,
> which defaults to #'(0.0 . 0.0).
>
> Love this. Is there a tweak for the vertical position of the line
> (independent of the text)?
>

Sure, no problem.  I added a 'line-Y-offset property which just
raises/lowers the line without any reference to the texts.

For consistency, I renamed 'line-offset to 'line-X-offset.


> > P.S.  One area of further improvement would be the input syntax.  Any
> suggestions for making this more user-friendly?
>
> As I play with it, I’ll see what I can come up with.
>

Please do!  I thought about a music function which reframes the input and
calls what I have for \addTextSpannerText, but I'm not sure how to go about
that.


>
> Many thanks for this!
>
>
You're very welcome.

David
\version "2.19.27"

%% CUSTOM GROB PROPERTIES

% Taken from http://www.mail-archive.com/lilypond-user%40gnu.org/msg97663.html
% (Paul Morris)

% function from "scm/define-grob-properties.scm" (modified)
#(define (cn-define-grob-property symbol type?)
   (set-object-property! symbol 'backend-type? type?)
   (set-object-property! symbol 'backend-doc "custom grob property")
   symbol)

% For internal use.
#(cn-define-grob-property 'text-spanner-stencils list?)

% user interface
#(cn-define-grob-property 'text-spanner-line-count number-list?)

% List of booleans describing connections between text items regardless
% of line breaks.
#(cn-define-grob-property 'connectors list?)

% How much space between line and object to left and right?
% Default is '(0.0 . 0.0).
#(cn-define-grob-property 'line-X-offset number-pair?)

% Vertical shift of connector line, independenf of texts.
#(cn-define-grob-property 'line-Y-offset number?)

#(define (get-text-distribution text-list line-extents)
   ;; Given a list of texts and a list of line extents, attempt to
   ;; find a decent line distribution.  The goal is to put more texts
   ;; on longer lines, while ensuring that first and last lines are texted.
   ;; TODO: ideally, we should consider extents of text, rather than
   ;; simply their number.
   (let* ((line-count (length line-extents))
  (text-count (length text-list))
  (line-lengths
   (map (lambda (line) (interval-length line))
 line-extents))
  (total-line-len (apply + line-lengths))
  (exact-per-line
   (map (lambda (line-len)
  (* text-count (/ line-len total-line-len)))
 line-lengths))
  ;; First and last lines can't be untexted.
  (adjusted
   (let loop ((epl exact-per-line) (idx 0) (result '()))
 (if (null? epl)
 result
 (if (and (or (= idx 0)
  (= idx (1- line-count)))
  (< (car epl) 1))
 (loop (cdr epl) (1+ idx)
   (append result (list 1.0)))
 (loop (cdr epl) (1+ idx)
   (append result (list (car epl)

 ;; The idea is to raise the "most roundable" line's count, then the
 ;; "next most roundable," and so forth, until we account for all texts.
 ;; Everything else is rounded down (except those lines which need to be
 ;; bumped up to get the minimum of one text), so we shouldn't exceed our
 ;; total number of texts.
 ;; TODO: Need a promote-demote-until-flush to be safe, unless this is
 ;; mathematically sound!
 (define (promote-until-flush result)
   (let* ((floored (map floor result))
  (total (apply + floored)))

 (if (>= total text-count)
 (begin
  ;(format #t "guess: ~a~%~%~%" result)
  floored)
 (let* ((decimal-amount
 (map (lambda (x) (- x (floor x))) result))
(maximum (apply max decimal-amount))
(max-location
 (list-index
  (lambda (x) (= x maximum))
  decimal-amount))
(item-to-bump (list-ref result max-location)))
   ;(format #t "guess: ~a~%" result)
   (list-set! result max-location (1+ (floor item-to-bump)))
   (promote-until-flush result)

 (let ((result (map inexact->exact
 (promote-until-flush adjusted
   (if (not (= (apply + result) text-count))
   ;; If this doesn't work, discard, triggering crude
   ;; distribution elsewhere.
   '()
   result

#(define (get-connectors grob text-distribution)
   "Modify @var{text-distribution} to reflect line breaks.  Return a list
of lists of booleans representing whether to draw a connecting line
between successive texts."
   ;; The property TextSpanner.connectors holds a list of booleans representing
   ;; whether a line will be drawn between 

Re: Text centralized above a TextSpan

2015-09-19 Thread Kieren MacMillan
Hi David,

> Sure, no problem.  I added a 'line-Y-offset property which just raises/lowers 
> the line without any reference to the texts.

Perfect! Thanks.
(To my eye, a setting of about 0.0875 is right.)

> For consistency, I renamed 'line-offset to 'line-X-offset. 

Makes sense.

Thanks again,
Kieren.


Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-19 Thread David Nalesnik
Hi Kieren,

On Sat, Sep 19, 2015 at 9:10 AM, Kieren MacMillan <
kieren_macmil...@sympatico.ca> wrote:

> Hi David,
>
> > Sure, no problem.  I added a 'line-Y-offset property which just
> raises/lowers the line without any reference to the texts.
>
> Perfect! Thanks.
> (To my eye, a setting of about 0.0875 is right.)
>
>
Ah, OK.  I see what the issue is.  The lines are drawn centered to the
baseline.  (Up TextSpanner.thickness and you'll get a vivid demonstration.)

This correction can be automated.  Try running this example:

\relative c' {
  \override TextSpanner.thickness = 5
  \override TextSpanner.line-X-offset = #'(0.5 . 0.5)
  \override TextSpanner.line-Y-offset =
  #(lambda (grob)
 (let* ((line-th (ly:staff-symbol-line-thickness grob))
   (th (* (ly:grob-property grob 'thickness 1.0) line-th)))
   (/ th 2.0)))
  \addTextSpannerText #'("ral" "len" "tan" "do")
  c1\startTextSpan
  d'1\stopTextSpan
}

--David
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-19 Thread David Kastrup
David Nalesnik  writes:

> (As an aside: I must say that David's suggestion of using lyrics
> produces miraculous results without the hundreds and hundreds of lines
> of new code!  Don't want a connector line?  Don't write a hyphen.
> Etc.)

Actually, we might have had some miscommunication.  I was not really
suggesting using a lyrics context, just \lyricsmode as a user interface.
The idea was more or less to pick the music expression apart and then
let your code do the work.

However, (re-)using engravers for the "picking apart" bit in a context
without its own vertical axis group might be an interesting option.
Want several text spanners?  Use several contexts.

-- 
David Kastrup

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-19 Thread Kieren MacMillan
Hi Trevor (et al.),

> This looks potentially very useful for adding spoken words which need to be 
> said during a passage of music, often required in musical theatre.

If we do this, let’s do it right…
I’m willing to pay some sponsorship for it.

Cheers,
Kieren.


Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-19 Thread Trevor Daniels

This looks potentially very useful for adding spoken words which need to be 
said during a passage of music, often required in musical theatre.  This is 
very difficult and hackish to do with current LP - see

http://www.lilypond.org/doc/v2.19/Documentation/notation/opera-and-stage-musicals#dialogue-over-music

I'd like to see this developed and added to LP core.

Trevor

  - Original Message - 
  From: David Nalesnik 
  To: Simon Albrecht 
  Cc: lilypond-user 
  Sent: Friday, September 18, 2015 11:58 PM
  Subject: Re: Text centralized above a TextSpan


  Hi,


  Alright!  This should do it...


  You can:


  --Adapt this for versions < 2.19.27 with a loss of overriding power (style, 
dash-fraction, etc.)--see comments beginning in line 435


  --Use/mix markups and strings.


  --Specify any number of texts >= 2 for your spanner.


  --Break it across an arbitrary number of lines, with an acceptable 
distribution.


  --Use spacers ("") to force texts closer/farther apart.  You can also move 
them like this:
  \markup \translate [...]
  \markup \right-align [...]
  etc.


  --Override the number of texts per line if you don't like the automatic 
distribution.  There's a warning if the numbers don't tally.


  --Specify which texts will be joined by a line and which won't using 
TextSpanner.connectors. I noticed this request in another related thread:
  http://www.mail-archive.com/lilypond-user%40gnu.org/msg103939.html



  The default is to join everything, and we revert to that with a warning if 
you specify too few connections. (Full disclosure: you can't hide one half of a 
line crossing a break and show the other half, but unless there's some pressing 
need, I'm going to forget I noticed this)  


  --Change the distance from text to line with TextSpanner.line-offset, which 
defaults to #'(0.0 . 0.0).


  Additionally, there are warnings for overlaps.  There's no attempt at fixing 
these.  I wouldn't know how to influence spacing.


  By the way, is there a way to get spacing to accommodate really long 
left/right texts with ordinary TextSpanners without resorting to 
\newSpacingArea, manual breaks, and the like?  I don't find a mechanism: 
\textLengthOn doesn't seem to work...


  Enjoy--
  David


  P.S.  One area of further improvement would be the input syntax.  Any 
suggestions for making this more user-friendly?  I can't figure out how to get 
markups to process properly without that off-putting


  #(list #{ \markup "foo" #} )


  construction.


  %%%




--


  ___
  lilypond-user mailing list
  lilypond-user@gnu.org
  https://lists.gnu.org/mailman/listinfo/lilypond-user
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-19 Thread David Kastrup
"Trevor Daniels" <t.dani...@treda.co.uk> writes:

> http://www.lilypond.org/doc/v2.19/Documentation/notation/opera-and-stage-musicals#dialogue-over-music
>
> I'd like to see this developed and added to LP core.
>
> Trevor
>
>   - Original Message - 
>   From: David Nalesnik 
>   To: Simon Albrecht 
>   Cc: lilypond-user 
>   Sent: Friday, September 18, 2015 11:58 PM
>   Subject: Re: Text centralized above a TextSpan
>
>
>   Hi,
>
>
>   Alright!  This should do it...
>
>
>   You can:
>
>
>   --Adapt this for versions < 2.19.27 with a loss of overriding power
> (style, dash-fraction, etc.)--see comments beginning in line 435
>
>
>   --Use/mix markups and strings.
>
>
>   --Specify any number of texts >= 2 for your spanner.
>
>
>   --Break it across an arbitrary number of lines, with an acceptable
> distribution.
>
>
>   --Use spacers ("") to force texts closer/farther apart.  You can
> also move them like this:
>   \markup \translate [...]
>   \markup \right-align [...]
>   etc.
>
>
>   --Override the number of texts per line if you don't like the
> automatic distribution.  There's a warning if the numbers don't tally.
>
>
>   --Specify which texts will be joined by a line and which won't using
> TextSpanner.connectors. I noticed this request in another related
> thread:
>   http://www.mail-archive.com/lilypond-user%40gnu.org/msg103939.html

Well, it looks to me like being able to use something in \lyricsmode
would be useful for specifying extenders, hyphens, rhythmic
distribution, text without creating lots of new commands and properties
for the user.

-- 
David Kastrup

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-18 Thread David Nalesnik
Hi,

Alright!  This should do it...

You can:

--Adapt this for versions < 2.19.27 with a loss of overriding power (style,
dash-fraction, etc.)--see comments beginning in line 435

--Use/mix markups and strings.

--Specify any number of texts >= 2 for your spanner.

--Break it across an arbitrary number of lines, with an acceptable
distribution.

--Use spacers ("") to force texts closer/farther apart.  You can also move
them like this:
\markup \translate [...]
\markup \right-align [...]
etc.

--Override the number of texts per line if you don't like the automatic
distribution.  There's a warning if the numbers don't tally.

--Specify which texts will be joined by a line and which won't using
TextSpanner.connectors. I noticed this request in another related thread:
http://www.mail-archive.com/lilypond-user%40gnu.org/msg103939.html

The default is to join everything, and we revert to that with a warning if
you specify too few connections. (Full disclosure: you can't hide one half
of a line crossing a break and show the other half, but unless there's some
pressing need, I'm going to forget I noticed this)

--Change the distance from text to line with TextSpanner.line-offset, which
defaults to #'(0.0 . 0.0).

Additionally, there are warnings for overlaps.  There's no attempt at
fixing these.  I wouldn't know how to influence spacing.

By the way, is there a way to get spacing to accommodate really long
left/right texts with ordinary TextSpanners without resorting to
\newSpacingArea, manual breaks, and the like?  I don't find a mechanism:
\textLengthOn doesn't seem to work...

Enjoy--
David

P.S.  One area of further improvement would be the input syntax.  Any
suggestions for making this more user-friendly?  I can't figure out how to
get markups to process properly without that off-putting

#(list #{ \markup "foo" #} )

construction.

%%%
\version "2.19.27"

%% CUSTOM GROB PROPERTIES

% Taken from http://www.mail-archive.com/lilypond-user%40gnu.org/msg97663.html
% (Paul Morris)

% function from "scm/define-grob-properties.scm" (modified)
#(define (cn-define-grob-property symbol type?)
   (set-object-property! symbol 'backend-type? type?)
   (set-object-property! symbol 'backend-doc "custom grob property")
   symbol)

% For internal use.
#(cn-define-grob-property 'text-spanner-stencils list?)

% user interface
#(cn-define-grob-property 'text-spanner-line-count number-list?)

% List of booleans describing connections between text items regardless
% of line breaks.
#(cn-define-grob-property 'connectors list?)

% How much space between line and object to left and right?
% Default is '(0.0 . 0.0).
#(cn-define-grob-property 'line-offset number-pair?)

#(define (get-text-distribution text-list line-extents)
   ;; Given a list of texts and a list of line extents, attempt to
   ;; find a decent line distribution.  The goal is to put more texts
   ;; on longer lines, while ensuring that all lines are texted.
   ;; TODO: ideally, we should consider extents of text, rather than
   ;; simply their number.
   (let* ((line-count (length line-extents))
  (text-count (length text-list))
  (line-lengths
   (map (lambda (line) (interval-length line))
 line-extents))
  (total-line-len (apply + line-lengths))
  (exact-per-line
   (map (lambda (line-len)
  (* text-count (/ line-len total-line-len)))
 line-lengths))
  ;; First and last lines can't be untexted.
  (adjusted
   (let loop ((epl exact-per-line) (idx 0) (result '()))
 (if (null? epl)
 result
 (if (and (or (= idx 0)
  (= idx (1- line-count)))
  (< (car epl) 1))
 (loop (cdr epl) (1+ idx)
   (append result (list 1.0)))
 (loop (cdr epl) (1+ idx)
   (append result (list (car epl)

 ;; The idea is to raise the "most roundable" line's count, then the
 ;; "next most roundable," and so forth, until we account for all texts.
 ;; Everything else is rounded down (except those lines which need to be
 ;; bumped up to get the minimum of one text), so we shouldn't exceed our
 ;; total number of texts.
 ;; TODO: Need a promote-demote-until-flush to be safe, unless this is
 ;; mathematically sound!
 (define (promote-until-flush result)
   (let* ((floored (map floor result))
  (total (apply + floored)))

 (if (>= total text-count)
 (begin
  ;(format #t "guess: ~a~%~%~%" result)
  floored)
 (let* ((decimal-amount
 (map (lambda (x) (- x (floor x))) result))
(maximum (apply max decimal-amount))
(max-location
 (list-index
  (lambda (x) (= x maximum))
  decimal-amount))

Re: Text centralized above a TextSpan

2015-09-16 Thread David Nalesnik
Hi Simon,

On Mon, Sep 14, 2015 at 7:41 AM, Simon Albrecht 
wrote:

> David,
>
> This is tremendous! Thank you very much.
>

You're very welcome!

I was inspired to fix some of the issues with this last version.

Texts are better distributed among the pieces of broken spanners.  (The
algorithm in place gives an OK estimation, but it has problems.  Help
welcome--don't know if my math is up to the task!)

You can specify the number of texts for each line:
\override TextSpanner.text-spanner-line-count = #'(1 0 1 1)

Overlaps will result in a warning.  Fixing them at this point means
changing line distribution, making space, breaking lines--work on the
user's part.  We're just replacing default stencils here, not changing
spacing.


Once again, you need 2.19.27.  There''s a note in lines 351-353 (*eek*) for
earlier versions, but you can't get the line styles, etc., before the most
recent development release.


Anyway, hope this helps!

David
\version "2.19.27"

%% CUSTOM GROB PROPERTIES

% Taken from http://www.mail-archive.com/lilypond-user%40gnu.org/msg97663.html
% (Paul Morris)

% function from "scm/define-grob-properties.scm" (modified)
#(define (cn-define-grob-property symbol type?)
   (set-object-property! symbol 'backend-type? type?)
   (set-object-property! symbol 'backend-doc "custom grob property")
   symbol)

% for internal use
#(cn-define-grob-property 'text-spanner-stencils list?)

% user interface
#(cn-define-grob-property 'text-spanner-line-count number-list?)

#(define (get-text-distribution text-list line-extents)
   ;; Given a list of texts and a list of line extents, attempt to
   ;; find a decent line distribution.  The goal is to put more texts
   ;; on longer lines, while ensuring that all lines are texted.  (The
   ;; case of fewer texts than lines available is dealt with
   ;; separately.  TODO: ugly code which does not consider the
   ;; length of texts, only their number.
   (let* ((line-count (length line-extents))
  (text-count (length text-list))
  (line-lengths 
   (map (lambda (line) (interval-length line))
 line-extents))
  (total-line-len (apply + line-lengths))
  (exact-per-line
   (map (lambda (line-len)
  (* text-count (/ line-len total-line-len)))
 line-lengths))
  ;; No line can have under one text.
  (adjusted
   (map (lambda (ex)
  (if (< ex 1) (ceiling ex) ex))
 exact-per-line)))
 ;; The idea is to raise the "most roundable" line's count, then the
 ;; "next most roundable," and so forth, until we account for all texts.
 ;; Everything else is rounded down (except those lines which need to be
 ;; bumped up to get the minimum of one text), so we shouldn't exceed our
 ;; total number of texts.  Well, the mandatory one text per line can
 ;; put us too high... Need a promote-demote-until-flush.
 (define (promote-until-flush result)
   (let* ((floored (map floor result))
  (total (apply + floored)))
 
 (if (>= total text-count)
 (begin 
  ;(format #t "guess: ~a~%~%~%" result)
  floored)
 (let* ((decimal-amount
 (map (lambda (x) (- x (floor x))) result))
(maximum (apply max decimal-amount))
(max-location
 (list-index
  (lambda (x) (= x maximum))
  decimal-amount))
(item-to-bump (list-ref result max-location)))
   ;(format #t "guess: ~a~%" result)
   (list-set! result max-location (1+ (floor item-to-bump)))
   (promote-until-flush result)
 
 (let ((result (map inexact->exact
 (promote-until-flush adjusted
   (if (not (= (apply + result) text-count))
   ;; If this doesn't work, discard, triggering crude
   ;; distribution elsewhere.
   '()
   result

#(define (get-line-arrangement siblings extents texts)
   "Given a list of spanner extents and texts, return a vector of lists
of the texts to be used for each line.  Using @code{'()} for @var{siblings}
returns a vector for an unbroken spanner."
   (let ((sib-len (length siblings)))
 (if (= sib-len 0)
 ;; only one line...
 (make-vector 1 texts)
 (let* ((texts-len (length texts))
(text-counts
 (ly:grob-property
  (car siblings) 'text-spanner-line-count))
(text-counts
 (cond
  ((pair? text-counts) text-counts) ; manual override
  ((or (null? siblings)
   (< texts-len sib-len))
   '())
  (else (get-text-distribution texts extents
(text-counts
 (if 

Re: Text centralized above a TextSpan

2015-09-14 Thread David Nalesnik
On Sun, Sep 6, 2015 at 12:17 PM, David Nalesnik 
wrote:

>
>
> Hopefully another step forward!
>
>
Attached is an improvement.

2.19.27 has been released, and you need this version to get the full
functionality here.  (There is provision for earlier versions--see note far
down in the first function--but you'll only get solid lines, unless you're
up for some heavy enhancement.)

The alignment of texts at the beginning and end is fixed, so you can
left-align, right-align, translate, whatever, with predictable results.

You can spread texts over more than two lines.  Here, the algorithm is
pretty simple, and is more of a placeholder.  Unfortunately, text can clump
when a spanner starts close to the line end or ends close to the start.
You can tweak the line distribution by adding spacers (""), as explained in
one of the examples.  What's needed is an algorithm that looks for overlaps
and shifts texts from first line forward, last line back as needed.  I've
been pondering this.  Probably it will require creating a new property
which specifies text count per line, so there isn't massive redundant
calculation. On the TODO list.  At the moment, if I have to write another
loop, I will scream :)

Anyway, enjoy!

David
\version "2.19.27"

%% Adapted from 'justify-line-helper' in scm/define-markup-commands.scm.
#(define (distribute-text-spanner-stencils grob args extent padding)
   "Return a stencil which spreads @var{args} along an extent
@var{extent}, with spaces filled by a line."
   (let* ((orig-stencils
   (map (lambda (a) (grob-interpret-markup grob a)) args))
  (stencils
   (map (lambda (stc)
  (if (ly:stencil-empty? stc X)
  (ly:make-stencil (ly:stencil-expr stc)
'(0 . 0) (ly:stencil-extent stc Y))
  stc))
 orig-stencils))
  (line-contents
   (if (= (length stencils) 1)
   (list point-stencil (car stencils) point-stencil)
   stencils))
  (text-extents
   (map (lambda (stc) (ly:stencil-extent stc X))
 line-contents))
  (te1 text-extents)
  ;; How much shift is necessary to align left edge of first
  ;; stencil with extent?  Apply this shift to all stencils.
  (text-extents
   (map (lambda (stc)
  (coord-translate
   stc
   (- (car extent) (caar text-extents
 text-extents))
  ;; how much does the last stencil need to be translated for
  ;; its right edge to touch the end of the spanner?
  (last-shift (- (cdr extent) (cdr (last text-extents
  (word-count (length line-contents))
  ;; Make a list of stencils and their extents, scaling the
  ;; extents across extent. The right edge of the last stencil
  ;; is now aligned with the right edge of the spanner.  The
  ;; first stencil will be moved 0.0, the last stencil the
  ;; amount given by last-shift.
  (stencils-shifted-extents-list
   (let loop ((contents line-contents) (exts text-extents)
   (idx 0) (result '()))
 (if (null? contents)
 result
 (loop
  (cdr contents) (cdr exts) (1+ idx)
  (append result
(list
 (cons (car contents)
   (coord-translate
(car exts)
(* idx
  (/ last-shift (1- word-count)))
  ; Remove non-marker spacers from list of extents.  This is done
  ; so that a single line is drawn to cover the total gap rather
  ; than several. (A single line is needed since successive dashed
  ; lines will not connect properly.) TODO: seems broken!
  (stencils-extents-list-no-spacers
   (let loop ((orig stencils-shifted-extents-list) (idx 0) (result '()))
 (cond
  ((= idx (length stencils-shifted-extents-list)) result)
  ; Ignore first and last stencils, which--if point stencil--
  ; will be markers.
  ((or (= idx 0)
   (= idx (1- (length stencils-shifted-extents-list
   (loop (cdr orig) (1+ idx)
 (append result (list (car orig)
  ; Remove spacers.  Better way to identify them than comparing
  ; left and right extents?
  ((= (cadar orig) (cddar orig))
   (loop (cdr orig) (1+ idx) result))
  ; Keep any visible stencil.
  (else (loop (cdr orig) (1+ idx)
  (append result (list (car orig
  
  (padding (ly:grob-property grob 'padding 0.0))
  (padded-stencils-extents-list
   (let loop ((orig stencils-extents-list-no-spacers) (idx 0) (result '()))
  

Re: Text centralized above a TextSpan

2015-09-14 Thread BB

Tried to compile with version 2.19.25

.../tmp/frescobaldi-6V3LoT/tmpI8U_qS/text-spanner-centered-text.ly:152:20 <0>: 
In expression (ly:line-interface::line grob (caar exts) ...):


/tmp/frescobaldi-6V3LoT/tmpI8U_qS/text-spanner-centered-text.ly:152:20 
<1>: Unbound variable: ly:line-interface::line




On 14.09.2015 14:22, David Nalesnik wrote:

\version "2.19.27"

%% Adapted from 'justify-line-helper' in scm/define-markup-commands.scm.
#(define (distribute-text-spanner-stencils grob args extent padding)
"Return a stencil which spreads @var{args} along an extent
@var{extent}, with spaces filled by a line."
(let* ((orig-stencils
(map (lambda (a) (grob-interpret-markup grob a)) args))
   (stencils
(map (lambda (stc)
   (if (ly:stencil-empty? stc X)
   (ly:make-stencil (ly:stencil-expr stc)
 '(0 . 0) (ly:stencil-extent stc Y))
   stc))
  orig-stencils))
   (line-contents
(if (= (length stencils) 1)
(list point-stencil (car stencils) point-stencil)
stencils))
   (text-extents
(map (lambda (stc) (ly:stencil-extent stc X))
  line-contents))
   (te1 text-extents)
   ;; How much shift is necessary to align left edge of first
   ;; stencil with extent?  Apply this shift to all stencils.
   (text-extents
(map (lambda (stc)
   (coord-translate
stc
(- (car extent) (caar text-extents
  text-extents))
   ;; how much does the last stencil need to be translated for
   ;; its right edge to touch the end of the spanner?
   (last-shift (- (cdr extent) (cdr (last text-extents
   (word-count (length line-contents))
   ;; Make a list of stencils and their extents, scaling the
   ;; extents across extent. The right edge of the last stencil
   ;; is now aligned with the right edge of the spanner.  The
   ;; first stencil will be moved 0.0, the last stencil the
   ;; amount given by last-shift.
   (stencils-shifted-extents-list
(let loop ((contents line-contents) (exts text-extents)
(idx 0) (result '()))
  (if (null? contents)
  result
  (loop
   (cdr contents) (cdr exts) (1+ idx)
   (append result
 (list
  (cons (car contents)
(coord-translate
 (car exts)
 (* idx
   (/ last-shift (1- word-count)))
   ; Remove non-marker spacers from list of extents.  This is done
   ; so that a single line is drawn to cover the total gap rather
   ; than several. (A single line is needed since successive dashed
   ; lines will not connect properly.) TODO: seems broken!
   (stencils-extents-list-no-spacers
(let loop ((orig stencils-shifted-extents-list) (idx 0) (result 
'()))
  (cond
   ((= idx (length stencils-shifted-extents-list)) result)
   ; Ignore first and last stencils, which--if point stencil--
   ; will be markers.
   ((or (= idx 0)
(= idx (1- (length stencils-shifted-extents-list
(loop (cdr orig) (1+ idx)
  (append result (list (car orig)
   ; Remove spacers.  Better way to identify them than comparing
   ; left and right extents?
   ((= (cadar orig) (cddar orig))
(loop (cdr orig) (1+ idx) result))
   ; Keep any visible stencil.
   (else (loop (cdr orig) (1+ idx)
   (append result (list (car orig
   
   (padding (ly:grob-property grob 'padding 0.0))

   (padded-stencils-extents-list
(let loop ((orig stencils-extents-list-no-spacers) (idx 0) (result 
'()))
  (cond
   ((= idx (length stencils-extents-list-no-spacers)) result)
   ;; don't widen line markers
   ((= (cadar orig) (cddar orig))
(loop (cdr orig) (1+ idx)
  (append result (list (car orig)
   ;; right padding only if object starts line
   ((= idx 0)
(loop (cdr orig) (1+ idx)
  (append
   result
   (list (cons (caar orig)
   (coord-translate (cdar orig) (cons 0 padding)))
   ;; left padding only if object ends a line
   ((= idx (1- (length stencils-extents-list-no-spacers)))
(loop (cdr orig) (1+ idx)
  (append
   result
   (list 

Re: Text centralized above a TextSpan

2015-09-14 Thread Simon Albrecht

David,

This is tremendous! Thank you very much. This should definitely make 
it’s way into the official installation once it’s reasonably finished.


Yours, Simon

Am 14.09.2015 um 14:22 schrieb David Nalesnik:



On Sun, Sep 6, 2015 at 12:17 PM, David Nalesnik 
> wrote:




Hopefully another step forward!


Attached is an improvement.

2.19.27 has been released, and you need this version to get the full 
functionality here.  (There is provision for earlier versions--see 
note far down in the first function--but you'll only get solid lines, 
unless you're up for some heavy enhancement.)


The alignment of texts at the beginning and end is fixed, so you can 
left-align, right-align, translate, whatever, with predictable results.


You can spread texts over more than two lines.  Here, the algorithm is 
pretty simple, and is more of a placeholder.  Unfortunately, text can 
clump when a spanner starts close to the line end or ends close to the 
start. You can tweak the line distribution by adding spacers (""), as 
explained in one of the examples.  What's needed is an algorithm that 
looks for overlaps and shifts texts from first line forward, last line 
back as needed.  I've been pondering this.  Probably it will require 
creating a new property which specifies text count per line, so there 
isn't massive redundant calculation. On the TODO list.  At the moment, 
if I have to write another loop, I will scream :)


Anyway, enjoy!

David



___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-14 Thread Simon Albrecht

Am 14.09.2015 um 14:34 schrieb BB:


Tried to compile with version 2.19.25

.../tmp/frescobaldi-6V3LoT/tmpI8U_qS/text-spanner-centered-text.ly:152:20 
<0>: In expression (ly:line-interface::line grob (caar exts) ...):


/tmp/frescobaldi-6V3LoT/tmpI8U_qS/text-spanner-centered-text.ly:152:20 
<1>: Unbound variable: ly:line-interface::line




Please reread David’s post: that’s functionality available only in 
v2.19.27, but there is a workaround. Though: why not get Lily 2.19.27?


Yours, Simon




On 14.09.2015 14:22, David Nalesnik wrote:

\version "2.19.27"

%% Adapted from 'justify-line-helper' in scm/define-markup-commands.scm.
#(define (distribute-text-spanner-stencils grob args extent padding)
"Return a stencil which spreads @var{args} along an extent
@var{extent}, with spaces filled by a line."
(let* ((orig-stencils
(map (lambda (a) (grob-interpret-markup grob a)) args))
   (stencils
(map (lambda (stc)
   (if (ly:stencil-empty? stc X)
   (ly:make-stencil (ly:stencil-expr stc)
 '(0 . 0) (ly:stencil-extent stc Y))
   stc))
  orig-stencils))
   (line-contents
(if (= (length stencils) 1)
(list point-stencil (car stencils) point-stencil)
stencils))
   (text-extents
(map (lambda (stc) (ly:stencil-extent stc X))
  line-contents))
   (te1 text-extents)
   ;; How much shift is necessary to align left edge of first
   ;; stencil with extent?  Apply this shift to all stencils.
   (text-extents
(map (lambda (stc)
   (coord-translate
stc
(- (car extent) (caar text-extents
  text-extents))
   ;; how much does the last stencil need to be translated for
   ;; its right edge to touch the end of the spanner?
   (last-shift (- (cdr extent) (cdr (last text-extents
   (word-count (length line-contents))
   ;; Make a list of stencils and their extents, scaling the
   ;; extents across extent. The right edge of the last stencil
   ;; is now aligned with the right edge of the spanner.  The
   ;; first stencil will be moved 0.0, the last stencil the
   ;; amount given by last-shift.
   (stencils-shifted-extents-list
(let loop ((contents line-contents) (exts text-extents)
(idx 0) (result '()))
  (if (null? contents)
  result
  (loop
   (cdr contents) (cdr exts) (1+ idx)
   (append result
 (list
  (cons (car contents)
(coord-translate
 (car exts)
 (* idx
   (/ last-shift (1- word-count)))
   ; Remove non-marker spacers from list of extents.  This is done
   ; so that a single line is drawn to cover the total gap rather
   ; than several. (A single line is needed since successive dashed
   ; lines will not connect properly.) TODO: seems broken!
   (stencils-extents-list-no-spacers
(let loop ((orig stencils-shifted-extents-list) (idx 0) (result 
'()))
  (cond
   ((= idx (length stencils-shifted-extents-list)) result)
   ; Ignore first and last stencils, which--if point stencil--
   ; will be markers.
   ((or (= idx 0)
(= idx (1- (length stencils-shifted-extents-list
(loop (cdr orig) (1+ idx)
  (append result (list (car orig)
   ; Remove spacers.  Better way to identify them than comparing
   ; left and right extents?
   ((= (cadar orig) (cddar orig))
(loop (cdr orig) (1+ idx) result))
   ; Keep any visible stencil.
   (else (loop (cdr orig) (1+ idx)
   (append result (list (car orig
   
   (padding (ly:grob-property grob 'padding 0.0))

   (padded-stencils-extents-list
(let loop ((orig stencils-extents-list-no-spacers) (idx 0) (result 
'()))
  (cond
   ((= idx (length stencils-extents-list-no-spacers)) result)
   ;; don't widen line markers
   ((= (cadar orig) (cddar orig))
(loop (cdr orig) (1+ idx)
  (append result (list (car orig)
   ;; right padding only if object starts line
   ((= idx 0)
(loop (cdr orig) (1+ idx)
  (append
   result
   (list (cons (caar orig)
   (coord-translate (cdar orig) (cons 0 padding)))
   ;; left padding only if object ends a 

Re: Text centralized above a TextSpan

2015-09-06 Thread David Nalesnik
Hi,


> On Thu, Sep 3, 2015 at 2:42 PM, Caio Giovaneti de Barros <
> caio.bar...@gmail.com> wrote:
>
>> Hello David!
>>
>> On 02-09-2015 10:19, David Nalesnik wrote:
>>
>>>
>>> Try this out:
>>>
>>> http://lists.gnu.org/archive/html/lilypond-user/2013-05/msg00405.html
>>>
>>>
>> This looks ok, but I'm not sure it'll work form me. I need to tweak the
>> Spanner a bit to centralize the line height vertically in relation to the
>> left and right bounds
>
>
[...]


>
>
>> and also use custom symbols for each bound.
>
>
>
I worked with Harm's function (link above) and produced the attached.  It
uses the same technique of \fill-line (or rather, \justify-line) to space
the text items, but draws the connecting lines differently.  Instead of
using \whiteout to break the line, it draws each line individually.

The function will accept a list of markups or strings.  "" acts as a
spacer, forcing text elements farther apart and others correspondingly
closer  (exactly as multiple dashes do in Harm's function).

The syntax for inputting a list of markups is unwieldy.   Is there a nicer
way to handle this sort of input?

+Important*:  This needs the to-be-released 2.19.27 (or current master) to
be fully functional.  You'd just need to uncomment the lines indicated in
justify-line-helper to get fully overridable lines: dashed, dotted, zigzag,
customization of dashes, etc.  At the moment you'll see solid lines.
 (Though there's a pretty unsatisfactory workaround for dashed lines
included.)

Hopefully another step forward!

David

Image attached in further post.

\version "2.19.25"

%% Only needed for versions before 2.19.27.
#(define (make-dashed-line-stencil width startx starty endx endy on off phase)
   (let ((xext (cons (min startx endx) (max startx endx)))
 (yext (cons (min starty endy) (max starty endy
 (ly:make-stencil
  (list 'dashed-line
; thick on off dx dy phase
width on off (- endx startx) (- endy starty) phase)
  ; Since the line has rounded edges, we have to / can safely add half the
  ; width to all coordinates!
  (interval-widen xext (/ width 2))
  (interval-widen yext (/ width 2)

%% The following is taken from scm/define-markup-commands.scm.  It is
%% needed to emulate \justify-line, so that texts may be spread
%% evenly along TextSpanner.
#(define (get-fill-space
  word-count line-width word-space text-widths constant-space?)
   "Calculate the necessary paddings between adjacent texts in a
single justified line.  The lengths of all texts are stored in
@var{text-widths}.  When @var{constant-space?} is @code{#t}, the
formula for the padding between texts is:
padding = (line-width - total-text-width)/(word-count - 1)
When @var{constant-space?} is @code{#f}, the formula for the
padding between interior texts a and b is:
padding = line-width/(word-count - 1) - (length(a) + length(b))/2
In this case, the first and last padding have to be calculated
specially using the whole length of the first or last text.
All paddings are checked to be at least word-space, to ensure that
no texts collide.
Return a list of paddings."
   (cond
((null? text-widths) '())
(constant-space?
 (make-list
  (1- word-count)
  ;; Ensure that space between words cannot be
  ;; less than word-space.
  (max
   word-space
   (/ (- line-width (apply + text-widths))
 (1- word-count)

;; special case first padding
((= (length text-widths) word-count)
 (cons
  (- (- (/ line-width (1- word-count)) (car text-widths))
(/ (cadr text-widths) 2))
  (get-fill-space
   word-count line-width word-space (cdr text-widths)
   constant-space?)))
;; special case last padding
((= (length text-widths) 2)
 (list (- (/ line-width (1- word-count))
 (+ (/ (car text-widths) 2) (cadr text-widths)))
   0))
(else
 (let ((default-padding
(- (/ line-width (1- word-count))
  (/ (+ (car text-widths) (cadr text-widths)) 2
   (cons
(if (> word-space default-padding)
word-space
default-padding)
(get-fill-space
 word-count line-width word-space (cdr text-widths)
 constant-space?))

%% Adapted from scm/define-markup-commands.scm.
#(define (justify-line-helper
  grob args word-space line-width constant-space? padding)
   "Return a stencil which spreads @var{args} along a line of width
@var{line-width}, with spaces filled by a line. If @var{constant-space?}
is set to @code{#t}, the space between words is constant.  If @code{#f}, the
distance between words varies according to their relative lengths."
   (let* ((orig-stencils
   (map (lambda (a) (grob-interpret-markup grob a)) args))
  (stencils
   (map (lambda (stc)
  (if (ly:stencil-empty? stc X)
  point-stencil
  stc))
 orig-stencils))
  

Re: Text centralized above a TextSpan

2015-09-06 Thread David Nalesnik
On Sun, Sep 6, 2015 at 12:17 PM, David Nalesnik 
wrote:

>
> Image attached in further post.
> 
>
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-03 Thread Caio Giovaneti de Barros



On 02-09-2015 10:08, Andrew Bernard wrote:


I am not sure how long you may have been following things, but this topic came 
up for me recently, and there is various discussion in the archives.


Yes, I made a search through the list the best I could, but I didn't 
find this (maybe the titles are not so obvious?). Also, the list is just 
too active to follow each topic. I'm just saying this not to give the 
impression I asked without consulting the documentation first



I came up with two half baked solutions, one involving modifying a text 
spanner, another modifying a markup, but neither of these is satisfactory.


Ok, I'll look into the archive to find a solution.


I continue to be amazed how useful such a capability would be, and how many 
people request it. Certainly this sort of thing is all through the contemporary 
music scores I deal with.


Exactly! I, too, am dealing with contemporary music (my compositions), 
maybe that's it.


Thank you for the reply.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-02 Thread Andrew Bernard
Hi Caio,

Welcome to the list.

I am not sure how long you may have been following things, but this topic came 
up for me recently, and there is various discussion in the archives. In a 
nutshell, the answer is not really. It’s possible of course, but can it be done 
simply and easily, that’s the point. Presently I am working on a solution to 
enable lilypond to do this nicely. I came up with two half baked solutions, one 
involving modifying a text spanner, another modifying a markup, but neither of 
these is satisfactory. I am commencing some work to make an engraver to do the 
job.

I continue to be amazed how useful such a capability would be, and how many 
people request it. Certainly this sort of thing is all through the contemporary 
music scores I deal with. It’s something I hope to see incorporated into 
lilypond one day. As to timeframes for my solution - don’t hold your breath!

Andrew





On 2/09/2015 22:41, "Caio Giovaneti de Barros" 
 wrote:

>
>Is it possible to have text centralized above a TextSpan? 


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Text centralized above a TextSpan

2015-09-02 Thread David Nalesnik
Hi Caio,

On Wed, Sep 2, 2015 at 8:08 AM, Andrew Bernard 
wrote:

 there is various discussion in the archives.


Try this out:

http://lists.gnu.org/archive/html/lilypond-user/2013-05/msg00405.html

Best,
David
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user