lilypond-user
[Top][All Lists]
Advanced

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

Re: Termination of variable definitions


From: David Wright
Subject: Re: Termination of variable definitions
Date: Tue, 19 Apr 2016 15:13:28 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

On Tue 19 Apr 2016 at 19:38:14 (+0100), David Sumbler wrote:
> So at the risk of embarrassing myself, I should be grateful if somebody
> would explain the following: how does Lilypond recognize the end of a
> variable definition?

Oversimplifying, there are about four things you can define with a
variable. Simplest is a single note, then a sequence { }, then a
simultaneous set of expressions, then an expression "within" a context.

%%%%%%%%
violin = a

{
  \violin
}

%% substitute "a" with:

{ f }

{ f g }

<< e g >>

\new Voice b

\new Voice { d g }

\new Voice << d f >>
%%%%%%%%

So you can put any of the those in place of "a".

But it's recursive. If you write
violin = \new Voice b
you can substitute again, this time for "b".
(Within limits: contexts have a parent/child ordering, so Staff
can contain Voice but not vice versa.)

Once you write { or <<, then LP will look for the matching } or >>
to close the expression. Once you write \foo, LP will "eat" enough
to satisfy \foo.

> violin = \new Staff {
>   \relative {
>     a'4 b c b
>   }
> }
> 
> cello = \new Staff {
>   \relative {
>     \clef "bass"
>     e2 d
>   }
> }

violin = \new Staff {
  \relative {
    a'4 b c b
  }
}

violin = \new Staff {
  \relative { ... }
}

violin = \new Staff {
  a
}

violin = \new Staff { ... }

violin = \new Staff a

violin = a

The last works because \new needs a context and an expression.
Similarly, \transpose needs two pitches and an expression.
etc.

Cheers,
David.



reply via email to

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