lilypond-user
[Top][All Lists]
Advanced

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

Re: Expansion of score for different format


From: Jay Anderson
Subject: Re: Expansion of score for different format
Date: Fri, 10 May 2013 22:31:13 -0700

On Fri, May 10, 2013 at 8:44 PM, Carl Peterson <address@hidden> wrote:
> Premature sending...
>
> As I was saying, the problem with the below code is that it prints the first
> verse, but it only prints the first verse. I also simplified the code so
> that instead of just passing lyrics in the list structure, each list element
> is one or more Lyrics blocks.
>

Sorry, I'm not totally following where you're going. I added an
'allVerses' function to the example I made earlier (how I would
approach the problem). It isn't especially clean, but hopefully it
helps to get you further. The trick here is to create another function
to just return the lyrics together and insert that into the score.

(Again this is quick and dirty code which can certainly be cleaned up
-- de-duplicate stuff between the two implementations)

=================================================
\version "2.17.16"

#(define (make-my-scores parser location up down lyrics verse)
  (if (not (null? lyrics))
    (let* ((verseStr (string-append (number->string verse) "."))
           (score
      #{
        \score
        {
          <<
            \new Staff="top" { \new Voice="soprano" { \clef treble $up } }
            \new Staff="bottom" { \new Voice="tenor" { \clef bass $down } }
            \new Lyrics \with { alignAboveContext = "bottom" }
\lyricsto "soprano" { \set stanza = $verseStr $(car lyrics) }
          >>
        }
      #}))
      (add-score parser score)
      (make-my-scores parser location up down (cdr lyrics) (+ verse 1)))))

seqVerses =
#(define-void-function (parser location up down lyrics) (ly:music?
ly:music? list?)
  (make-my-scores parser location up down lyrics 1))


%%%%%%%%%%%%%

#(define (zip p q) (map list p q))

createLyrics =
#(define-music-function (parser location lyrics) (list?)
  (make-simultaneous-music
    (map
      (lambda (verse-lyrics)
        (let* ((num-str (number->string (car verse-lyrics)))
               (actual-lyrics (cadr verse-lyrics))
               (verse (string-append num-str ".")))
          #{ \new Lyrics \with {alignAboveContext = "bottom"}
\lyricsto "soprano" { \set stanza = $verse $actual-lyrics } #}))
      (zip (iota (length lyrics) 1) lyrics))))

allVerses =
#(define-void-function (parser location up down lyrics) (ly:music?
ly:music? list?)
  (let* ((score
    #{
      \score
      {
        <<
          \new Staff="top" { \new Voice="soprano" { \clef treble $up } }
          \new Staff="bottom" { \new Voice="tenor" { \clef bass $down } }
          \createLyrics $lyrics
        >>
      }
    #}))
    (add-score parser score)))

soprano = \relative c' { c4 c c c | }
tenor = \relative c { c4 c c c | }
verseOne = \lyricmode { a b c d }
verseTwo = \lyricmode { e f g h }

\seqVerses \soprano \tenor #(list verseOne verseTwo)
\allVerses \soprano \tenor #(list verseOne verseTwo)
=================================================

Then of course you can make what you originally wanted:
=================================================
choiceVerses =
#(define-void-function (parser location all up down lyrics) (boolean?
ly:music? ly:music? list?)
  (if all
    #{ \allVerses $up $down $lyrics #}
    #{ \seqVerses $up $down $lyrics #}))

\choiceVerses ##f \soprano \tenor #(list verseOne verseTwo)
=================================================

-----Jay



reply via email to

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