[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Conditionally including lyrics
From: |
Jay Anderson |
Subject: |
Re: Conditionally including lyrics |
Date: |
Sat, 3 Dec 2011 12:25:24 -0700 |
On Fri, Dec 2, 2011 at 3:26 AM, Marc Hohl <address@hidden> wrote:
> Now the data files contain different numbers of stanzas, and ideally, the
> generator file
> should be intelligent enough to include all stanzas which are present. Has
> someone an idea
> how to create a loop which scans for textA, textB, textC etc. and puts a
> command that acts like
> \addlyrics for each hit?
I'll add my solution to this problem. I keep each verse in a separate
file with just "\lyricmode {...}". These are named verse_1.ily,
verse_2.ily, etc. Then where I want the lyrics I add '\createLyrics
"001" "soprano"' (see below for the definition). It isn't doing
\addLyrics, but \new Lyrics ... \lyricsto ... so it isn't exactly the
same. It isn't perfect but it works for what I need.
-----Jay
==========
#(use-modules (ice-9 regex))
#(define (verse-files dir)
(define (is-verse-file? file)
(string-match "^verse_[0-9]+\\.ily$" file))
(let ((dir-stream (opendir dir))
(count 0))
(do
((entry (readdir dir-stream) (readdir dir-stream)))
((eof-object? entry))
(if
(is-verse-file? entry)
(set! count (+ 1 count))))
(closedir dir-stream)
count))
#(define (range a b)
(define (range-inner a b out)
(if (> a b)
out
(range-inner a (- b 1) (cons b out))))
(range-inner a b '()))
createLyrics =
#(define-music-function (parser location dir voice) (string? string?)
(make-simultaneous-music
(map
(lambda (num)
(let* ((num-str (number->string num))
(file (string-append dir "/verse_" num-str ".ily"))
(verse (string-append num-str ".")))
#{ \new Lyrics \with {alignAboveContext = "bot"} \lyricsto
$voice { \set stanza = $verse { \include $file }} #}))
(range 1 (verse-files dir)))))
===============
- Would you donate for structured Lilypond variables? (was: Conditionally including lyrics), (continued)
Re: Conditionally including lyrics, Matthew Collett, 2011/12/02
Re: Conditionally including lyrics, Jan-Peter Voigt, 2011/12/02
Re: Conditionally including lyrics, Johan Vromans, 2011/12/02
Re: Conditionally including lyrics,
Jay Anderson <=