lilypond-user
[Top][All Lists]
Advanced

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

Re: \tag can't follow \lyricsto


From: Nicolas Sceaux
Subject: Re: \tag can't follow \lyricsto
Date: Wed, 16 Jul 2008 13:59:43 +0200

Le 16 juil. 08 à 13:31, Roman Stawski a écrit :

The command order I'm using is from a really old template that I've
been using for years without problems. I came across your formulation
when checking an answer to another post on the bugs list.

Looks as if I'll have to update my templates. (Who's got the sed user
guide?)

You don't have to. The way you're using it is valid.
You just have to adapt it when using \tag to workaround the parser
defect.

However, there is an easier way to include or exclude
the harmony, without using tags, like this:


harmony = { \new Staff {a'1} }
<<
\new Staff { \new Voice = "dirge" { c''1 } }
\lyricsto "dirge" \new Lyrics { Whoops }
%\harmony %uncomment to include harmony
>>

That doesn't convince me.

It was poor advice, your use of \tag is correct in this situation.

Ideally, I want to produce different output from the same score
_without_ touching the contents. My idea (dream?) of using tags was
to eventually write a dollop of scheme that would be able to look at
the command line arguments and set \keepWithTag or \removeWithTag as
appropriate. However, the way that tags are implemented today isn't
powerful enough for what I want to do... they can only be used to filter music expressions -- I'd like to be able to filter out markup, scores and
anything else in the input file. (Well, I did say 'dream'!).

At the moment I'm using a cobbled together solution partly based on tags,
and partly based on a perl preprocessor that does the filtering before
passing the input onto to Lilypond -- but pretty it ain't.

You can conditionnaly insert music using a music function.
For instance:

#(define (true-function . args) #t)
insertWhen =
#(define-music-function (parser location condition music) (true- function ly:music?)
   (if condition
       music
       (make-music 'Music)))

<<
  \new Staff { \new Voice = "dirge" { c''1 } }
  \lyricsto "dirge" \new Lyrics \lyricmode { Whoops }
  \insertWhen #(eqv? (ly:get-option 'part) 'harmony) \new Staff { a'1 }
>>

Then, when compiling your input file with -dpart=harmony option,
the staff is added.

You can also specialize \insertWhen, the following way:

insertWhenHarmony =
#(define-music-function (parser location music) (ly:music?)
   (if (eqv? (ly:get-option 'part) 'harmony)
       music
       (make-music 'Music)))

<<
  \new Staff { \new Voice = "dirge" { c''1 } }
  \lyricsto "dirge" \new Lyrics \lyricmode { Whoops }
  \insertWhenHarmony \new Staff { a'1 }
>>

nicolas





reply via email to

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