lilypond-user
[Top][All Lists]
Advanced

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

Re: new and context


From: Trevor Daniels
Subject: Re: new and context
Date: Wed, 5 Dec 2012 08:39:36 -0000

Noeck, you wrote Tuesday, December 04, 2012 8:43 PM

> what is the difference between \new and \context?

Very little.  In most situations they can be used interchangeably.

One difference is that \context Staff = "A" will search for a previously
defined Staff with the same name and use that existing context,
whereas \new Staff = "A" will always create a new context, even if
a context with the same name already exists.

I always use \new the first time a context is created and \context to
refer back to an existing context, but this is just a convention and
other users have different conventions.

> I have read 5.1.2 Creating contexts, but I don't understand it yet.
> 
> It talks about 3 commands for a context:
>  \new type music expression
>  \context type = id music
>  \context type music
> 
> Why is \new type = id music not listed with an extra bullet? Or, why is
> \context type = id and \new type = id is not?

This section of the documentation was last amended in 2006, when the
style was much more casual than the way the earlier sections of the Notation
Reference are now written.  It is likely the author was not very clear how 
contexts worked.  It's time this section was revisited.  Thanks for drawing
our atttention to it.

> Where would I need \context?
> There is an example:
> <<
>  \new Staff \context Voice = "A" \music
>  \context Voice = "A" \arts
> >>
> But I could write \new Staff << \music \\ \arts >>, couldn't I?

Yes.
 
> Ok, I see some differences in the stem directions, but it's not clear to
> me why. I would be very happy, if anyone could explain that to me.

The former uses a single Voice context, the latter uses two.
 
> Would a syntax be possible without new and LilyPond creates the context
> if it is not there and references an exising one, if it has the same
> name? 

That's essentially what \context does.

Trevor

reply via email to

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