lilypond-user
[Top][All Lists]
Advanced

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

Re: Still confused about context vs. new


From: Trevor Daniels
Subject: Re: Still confused about context vs. new
Date: Fri, 18 Jul 2008 08:50:51 +0100

Patrick

My original intention was not to cover the use of \context in the LM, but I see now that several of the examples and templates use it, so that was perhaps a mistake. Thanks for pointing this out. I'll look at it again.

In the meantime, the distinction is explained in NR 5.1.2 Creating contexts, although this section has not yet been reviewed in GDP so maybe it could be improved. Let me know to what extent it helps you. In any case I'll bear your comments in mind when I get to that section.

Trevor

----- Original Message ----- From: "Patrick Horgan" <address@hidden>
To: "Mailinglist lilypond-user" <address@hidden>
Sent: Thursday, July 17, 2008 9:35 PM
Subject: Still confused about context vs. new


I see many examples with \context, or \new used in the same place. I've read LM 3.1.1 for example which tells me that if I don't create explicitly a \new Staff or \new Voice, they will be created automatically, and goes on to refer to that as the implicit creation of contexts. I often see examples that refer to contexts, via something like \context ChoirStaff, or \context Staff, that have not been explicitly created. Can I assume that they are implicitly created? Something like this recent example off the list:
\version "2.11"

\score {
  \context ChoirStaff <<
      \context Staff<<
\context Voice = voice \relative c'' { \voiceOne\repeat unfold 200 { e2 } \new Voice \relative c'' { \voiceTwo \repeat unfold 200 { c }}>>
      \context Lyrics \lyricsto "voice" { \repeat unfold 200 { la }  }
         \new Staff \relative c   <<
\new Voice { \clef "bass" \voiceOne \repeat unfold 200 { } }
            \new Voice  { \voiceTwo  \repeat unfold 200 { a, } } >>  >>
\layout { }
}
Why does it use \context ChoirStaff instead of \new Choirstaff? Same for Staff? Same for Lyrics. If I change the \context to \new it works identically (I think). Does it? If not what's the difference? How do I know when to do which? If I replace all the \new with \context, the music changes. If I replace all the \context with \new it works fine. Why?

Is there a difference between:

\score {
   \new ChoirStaff <<
      \new Staff{
         \new Voice<<>>
      }
     \new Staff{
         \new Voice<<>>
   >>
}

and
\score {
   \new ChoirStaff <<
      \new Staff{
         \new Voice<<>>
      }
      \new Staff{
         \context Voice<<>>
      }
 >>
}

Are these referring to implicit always pre-existing contexts, so that changing the \context to \new just takes up more memory for nothing and the implicit ones are still there?

In LM 3.4.4 it implies without stating that changing a property of a Staff happens within the context of the current staff. i.e. setting instrumentName for a staff only affects that staff and goes on to say that if you don't specify Staff, then it will affect the default context, voice. I had to try it to see if \set Staff.instrumentName = #"Alto" would work--that was a nice clue, wish the text would have spelled that out. It seems as if the writers know this well, it's part of their /context/ <grin;> and they don't spell out things that now, to them are obvious.

Farther in LM 3.4.4. they begin using commands to change note heads without mentioning contexts at all. Am I to assume, that they affect a default context? Which is that? The last thing I read was to be careful because the default was Voice. So am I changing a Voice property here when I don't specify context?

I'm sure it's all clear if you already know it, but for me, it's quite fuzzy.

Patrick


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






reply via email to

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