lilypond-user
[Top][All Lists]
Advanced

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

Re: [issue 1482] \caps \fromproperty and markup->string


From: Jan-Peter Voigt
Subject: Re: [issue 1482] \caps \fromproperty and markup->string
Date: Fri, 07 Oct 2011 10:44:24 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.23) Gecko/20110921 Lightning/1.0b2 Thunderbird/3.1.15

Hello David,

why do you think it is too hackish? If it gets lily-standard, all
visible to the user is something like this:
If he wants a non-pre-defined lyric-markup:
lyrcaps = #(define-lyric-markup (markup #:recaps #:fromproperty 'lyric:text))

and then \addlyrics/\lyricmode { sing \lyrcaps { sing sing sing }  }
First he needs a special markup function recaps that recursively calls
\caps and does nothing else.  This is rather hard to define for a user.
What if he wants italics instead?  Then he needs to jiggle this together
with some magic #:fromproperty markup, then it mixes with something
else.  I mean, get real: how would he ever manage to italize lyrics that
way?
if the define-lyric-markup is defined in the depths of lilyponds scm dirs, one can define a markup wrapper wich makes use of one \fromproperty call. If there are predefined commands in the depths of lilyponds ly dirs, one can use \lyrcaps, \lyrita, \lyrhilite or whatever is predefined. This seems not too difficult. The recursive recaps-command is a redefinition of the caps-markup-command for the current stable version, because "\caps \italic TEXT" won't work in any markup, regardless of its location, due to the definition of caps/smallCaps. So it's an answer to Vaughan's question regarding caps. My approach is still too hackish, if one wants just to italize lyrics ... in such a case I would recommend:
--snip--
lyrita = #(define-music-function (parser location mus)(ly:music?)
  #{
    \override LyricText #'font-shape = #'italic
    $mus
    \revert LyricText #'font-shape
#})

\relative c' {
  e4 g b c a1
} \addlyrics {
A -- ve \lyrita { Ma -- ri -- a }
}
--snip--
... or just use the overrides directly in the addlyrics/lyricmode-part.
Now let's take a look at my approach.
I did and it didn't compile ...
The user interface is still clunky due to deficiencies in the parser (I
have not yet looked at lyricsmode), so the \notemode is a nuisance, and
a few other ughs.
Yes in my approach are also some ughs ... it's a work in progress ;) ...
But it requires far less specialized macros and stuff.  Personally, I'd
prefer it if lyricsmode just accepted \markuplines and spliced all its
elements individually into a music list.  But I can't do everything at
once.
... but I disagree here. If you get your lyricize method working, it is still a macro just like define-lyric-markup. My idea is to mark a lyric-part as e.g. refrain, added by editor or to-be-re-written. Then you have one place, where you define, how those parts should look like.

Here's an example of the *hacks* ;) I use ... without the caps-fix but some comments:
--snip--

\version "2.14.2"
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% to be buried somewhere under the scm-hood of lilypond

%%% a markup style command
% definition in a closure
#(define-public (setstyle symbol markup) #f)
#(define-public (getstyle symbol) #f)
#(let ((style:markups (list)))
     (set! setstyle (lambda (symbol markup)
               (if (symbol? symbol)
(set! style:markups (assoc-set! style:markups symbol markup)) (ly:input-message location (format "'~A' is not a symbol!\n" symbol)))))
     (set! getstyle (lambda (symbol)
               (let ((m #f))
                    (set! m (assoc-get symbol style:markups))
(if m (begin m) (begin (markup #:italic #:fromproperty 'style:text))))))
)
% style markup command
#(define-markup-command (style layout props symbol markup)(symbol? markup?)
(interpret-markup layout (cons (list (cons 'style:text markup)) props) (getstyle symbol)))
% setStyle music function to avoid scheme in style definition
#(define-public setStyle (define-music-function (parser location sym mup)(symbol? markup?)
    (setstyle sym mup)(make-music 'SequentialMusic 'void #t)))

%%% define-lyric-markup function
#(define-public (define-lyric-markup mup)
  (define-music-function (parser location lyrics) (ly:music?)
    (music-map
      (lambda (m)
              (begin
                (if (equal? (ly:music-property m 'name) 'LyricEvent)
                    (let ((syl (ly:music-property m 'text)))
(ly:music-set-property! m 'text (markup #:override (cons 'lyric:text syl) mup))))
                m))
      lyrics)))

%%% make use of the predefined style command in lyrics
#(define-public lyricstyle (define-music-function (parser location style lyrics) (symbol? ly:music?) (let ((lsf (ly:music-function-extract (define-lyric-markup (markup #:style style #:fromproperty 'lyric:text)))))
         (lsf parser location lyrics))
))

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% to be defined by intermediate users or predefined somewhere in lily's ly dir

%%% a "to be done" style using *one* fromproperty
\setStyle #'TBD \markup {
  \italic \with-color #red \fromproperty #'style:text
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% use example with secular lyrics

\relative c' {
  e4 g b c | a1
} \addlyrics {
  walk this way \lyricstyle #'TBD { get loud }
}

--snip--

There is still one problem with this approach: Nested styles and nested lyric-mups won't work. I am looking at it ...

And still the idea of having markuplines converted to LyricEvents sounds interesting, if you want to place arbitrary markups anywhere.
Do you have a working example for stable lily? I will try in devel later.

Cheers,
Jan-Peter




reply via email to

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