Sorry about that, read the first part of what you provided, not all.

I just figured it out. I was essentially outputting sequentially instead of
simultaneously. I didn't figure it out until I added about two or three
copies of the music to run the lyrics out.

The stripped-down function is:

seqVerses =
#(define-void-function (parser location up down lyrics)
(ly:music? ly:music? string? string? string? scheme? scheme? scheme? list?)
(let*
((score
#{
        \score {
<<
\new Staff="top" { $up }
  #(make-simultaneous-music (map ly:music-deep-copy lyrics))
\new Staff="bottom" { $down }
          >>
}
      #}
)
)
      (add-score parser score)
)
)


This takes the lyrics (or practically any list of musical expressions) and
spits them out in-between the two staves. This lets me define simultaneous
lyrics as a single list element and they'll be preserved in the split-verse
version (in the case of choruses where there are multiple parts).

Thanks for the assistance. I think that gets everything I was looking for.

Cheers,
Carl



On Sat, May 11, 2013 at 1:31 AM, Jay Anderson <horndud...@gmail.com> wrote:

> On Fri, May 10, 2013 at 8:44 PM, Carl Peterson <carlopeter...@gmail.com>
> 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
>
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to