lilypond-user
[Top][All Lists]
Advanced

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

Re: Using addlyrics with a variable


From: Mats Bengtsson
Subject: Re: Using addlyrics with a variable
Date: Mon, 10 Oct 2005 12:20:07 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050511

I already knew that \addlyrics had very limited applicability, but
it seems that it's even more limited to only handle simple examples
than you might expect.

Still, the following version of your first attempt does work:


\version "2.6.3"
sopLyric = \lyricmode {  One Two  Three }

<<
\context Voice { a b c }
\addlyrics {  \sopLyric }
>>

First of all, you have to tell the front end of LilyPond to handle the
lyrics as lyrics, this is done with the \lyricmode (which is automatically
done after \addlyrics and \lyricsto, but has to be done explicitly when you
have your lyrics in a variable definition).
Secondly, you at least have to tell LilyPond that the score contains two
things in parallel, namely the music and the lyrics. That's done with the
<<...>>.
Finally, for some silly reason, you need to have curly braces around the
"argument" of \addlyrics. I'll send a bug report on that one.

I would actually recommend you to always explicitly specify the
\score{...} block. It just tells you where the actual score declaration
appears, in contrast to variable definitions and other declarations.
Then, the example would look like:

\version "2.6.3"
sopLyric = \lyricmode {  One Two  Three }

\score{
<<
\context Voice { a b c }
\addlyrics {  \sopLyric }
>>
}

  /Mats

Neil Killeen wrote:

Hello

I am exploring lilypond for the first time. In evaluating its suitability for my
purposes, I am making a little test piece to explore layouts.

I am having trouble with lyric setting. I would like to use a pre-defined variable with the \addlyrics command (I can't find the answer in the manual
or archives).

Thus something along the lines of


sopLyric = {  One Two  Three }
{ a b c }
\addlyrics \sopLyric



However, this approach fails.  The actual error I get from my actual
test piece is


test2.ly:44:13: error: syntax error, unexpected STRING
sopLyric = {
            One Two  Three }



OK, so I guess I have something wrong with the variable assignment syntax
(sopLyric = ...) and it is not allowed to put a string like this. I have tried other things; with quotes, and trying to put the addlyrics in the variable but I can't get this
approach to work.

As far as I can see, the manual does not have an example of this. Whenever it uses \addlyrics, the examples give the lyrics directly where the \addlyrics command is used. I can't find anything about using strings in the explanation of assigning
variables either.


The manual does show how to use a pre-defined variable with the more complex lyric modes. So I tried this too. Below is the actual code (rather than some pseudo code like above) that I used. You can see I am trying to use lyricmode
and lyricsto on the Soprano voice (the only one for now).  The music is
enclosed between << and >> because of course I really want to have
several voices (sop,mez,alto) but in finding the simplest version of what
I am doing that fails, I have pulled the other voices out.

The error I get is

warning: cannot find Voice `sop'

(although I have defined it), and the resultant type-set file has two staffs; one empty, the second with
the actual soprano voice notes and no lyric.

As far as I can see I have followed the examples in the manual.

I note that if I remove the << and >> this error message does not occur,
but the same wrong output arises.

Perhaps I should be using some of the other commands like \score etc but
I don't really know what they are for at this point (they just start appearing
in the manual without explanation).


advice appreciated !

regards
Neil



\include "english.ly"
\version "2.6.3"
\midi{ \tempo 4=72 }
\header {
 title = \markup { "Test Piece" }
 composer = \markup { "Mr. Wiggle" }
 poet = \markup { "Mr. Biggles" }
}
common = {
 \key g \major
 \time 3/4
}
%
sopNotes = {
  \relative c' {
     \set Staff.instrument = \markup {Soprano}
     \tempo 4=80
     \common
     \clef treble
     e'2 d4   c2 <b d>4   a8( b) c2
  }
}
%
%
sopLyric = \lyricmode {
 One Two   One Two  One __ Two
}
%
<<
 \context Voice = sop {
    \new Staff  {
       \sopNotes
    }
  }
  \lyricsto "sop" \new Lyrics \sopLyric






_______________________________________________
lilypond-user mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/lilypond-user


--
=============================================
        Mats Bengtsson
        Signal Processing
        Signals, Sensors and Systems
        Royal Institute of Technology
        SE-100 44  STOCKHOLM
        Sweden
        Phone: (+46) 8 790 8463                         
       Fax:   (+46) 8 790 7260
        Email: address@hidden
        WWW: http://www.s3.kth.se/~mabe
=============================================





reply via email to

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