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: Thu, 06 Oct 2011 15:12:18 +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

Hi Vaughan,

I introduced the define-lyric-markup method a few mails ago, so it is no lilypond standard. Here I added methods to your file and used the recaps command, I introduced in a revious mail, to capsify markups recursively whatching out for \fromproperty.
This way it compiles fine on my machine:
--snip--
\version "2.14.2"

% to define a lyric-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)))

% apply caps to all strings found in m
#(define-public (rcaps m . mprops)
  (let ((layout (if (> (length mprops) 0) (car mprops) #f))
        (props (if (> (length mprops) 1) (cadr mprops) '()))
        (mup? (lambda (m)(or (string? m)(list? m)(markup? m))))
        (ret (markup)))
       (set! ret
         (cond
           ((string? m) (markup #:caps m))
           ((null? m) "")
           ((and (pair? m)(equal? (car m) fromproperty-markup))
            (rcaps (chain-assoc-get (cadr m) props "???")))
           ((and (pair? m)(markup-function? (car m))) (cons (car m)
(map (lambda (mup)(if (mup? mup) (rcaps mup layout props) mup)) (cdr m))))
           ((list? m)
            (map (lambda (mup)(rcaps mup layout props)) m))
           (else "ERROR, unable to caps markup"))
       )
       ret)
)
% recursive caps markup command
#(define-markup-command (recaps layout props mup)(markup?)
  (interpret-markup layout props (rcaps mup layout props)))


lyrcaps = #(define-lyric-markup (markup #:recaps #:fromproperty 'lyric:text))

staffOne = "Soprano"

staffOneMusic = \relative c' {
    \clef "treble" \key f \minor \time 2/2

    c'1 \melisma ees \melismaEnd ees2 c c ees ees ees f f |
    ees1 c2 c2 c \melisma bes \melismaEnd aes aes des1 c|
    \bar "||"
    c1~ \melisma c2 bes~ bes aes bes1 aes \melismaEnd |
    r2 des \melisma ees1 f~ f2 ees f \melismaEnd des \melisma c1~ c
\melismaEnd |
    \bar "||"
}

staffOneLyrics = \lyricmode {
    De __ la -- men -- ta -- ti -- o -- ne Je -- re -- mi -- æ pro --
phe -- tæ,
    pro -- phe -- tæ.

    \lyrcaps { Mem, __ Mem, __ Mem. __ }

}

\score {

          \new Staff
<<
          \new Voice = \staffOne {
            \set Staff.instrumentName=\staffOne
            \staffOneMusic
          }
          \new Lyrics \lyricsto \staffOne { \staffOneLyrics }
>>
}
--snip--

Cheers, Jan-Peter

Hi Jan-Peter,

Thank you very much for your help with small-caps. I have been trying
to use the functions you listed but I am getting an unbound variable
error. Could you work out what is wrong with the code please? I’ve
made it as short as possible!

--snip--
home:lilypond vaughan$ lilypond test6.ly
GNU LilyPond 2.14.2
Processing `test6.ly'
Parsing...
test6.ly:21:11: error: GUILE signaled an error for the expression beginning here
lyrcaps = #
            (define-lyric-markup (markup #:frompropertysmallcaps 'lyric:text))
Unbound variable: define-lyric-markup

--snip-- test6.ly

\version "2.14.2"

#(define-markup-command (fromproperty layout props symbol)
    (symbol?)
    (let ((m (chain-assoc-get symbol props))
          (caps? (chain-assoc-get 'caps props)))
      (if (markup? m)
          (interpret-markup layout props
                            (if caps?
                                (make-smallCaps-markup m)
                                m))
          empty-stencil)))



#(define-markup-command (caps layout props arg) (markup?)
    (interpret-markup layout (prepend-alist-chain 'caps #t props)
                      (make-smallCaps-markup arg)))


lyrcaps = #(define-lyric-markup (markup #:frompropertysmallcaps 'lyric:text))

staffOne = "Soprano"

staffOneMusic = \relative c' {
     \clef "treble" \key f \minor \time 2/2

     c'1 \melisma ees \melismaEnd ees2 c c ees ees ees f f |
     ees1 c2 c2 c \melisma bes \melismaEnd aes aes des1 c|
     \bar "||"
     c1~ \melisma c2 bes~ bes aes bes1 aes \melismaEnd |
     r2 des \melisma ees1 f~ f2 ees f \melismaEnd des \melisma c1~ c
\melismaEnd |
     \bar "||"
}

staffOneLyrics = \lyricmode {
     De __ la -- men -- ta -- ti -- o -- ne Je -- re -- mi -- æ pro --
phe -- tæ,
     pro -- phe -- tæ.

     \lyrcaps { Mem, __ Mem, __ Mem. __ }

}

\score {

           \new Staff
           <<
           \new Voice = \staffOne {
             \set Staff.instrumentName=\staffOne
             \staffOneMusic
           }
           \new Lyrics \lyricsto \staffOne { \staffOneLyrics }
           >>
}


   -- snip --

Cheers,
Vaughan






reply via email to

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