lilypond-user
[Top][All Lists]
Advanced

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

Re: Text centralized above a TextSpan


From: David Nalesnik
Subject: Re: Text centralized above a TextSpan
Date: Mon, 21 Sep 2015 08:04:08 -0500

Hi,

On Sat, Sep 19, 2015 at 7:09 PM, David Nalesnik <address@hidden> wrote:
David,

On Sat, Sep 19, 2015 at 3:48 PM, David Kastrup <address@hidden> wrote:
David Nalesnik <address@hidden> 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
}


reply via email to

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