lilypond-devel
[Top][All Lists]
Advanced

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

Re: Scheme function to print out active Voice context during interpretat


From: Carl D. Sorensen
Subject: Re: Scheme function to print out active Voice context during interpretation?
Date: Sun, 14 Dec 2008 19:30:07 -0700



On 12/14/08 7:18 PM, "Trevor Bača" <address@hidden> wrote:

>> 
>> In examples 1 and 2+1 note, the first music occurs without a voice being
>> defined.  Therefore, LilyPond creates (instantiates) a voice.  Voice foo is
>> then created, and limited to the notes contained in the brackets.
>> 
>> In example 2, Voice foo is created before any voice is instantiated.  Then,
>> the music that comes after the voice foo definition is just applied to the
>> existing voice foo, since there is no explicit instantiation.
> 
> OK, this explanation is extremely helpful. But there's still something deeply
> wrong. Han-Wen from a bit earlier:
> 
> "Note that contexts do not 'nest' as you claim in a message below.
> Voice contexts cannot contain any other context."
> 
> But check this out:
> 
> %%% VOICE-RESOLUTION EX 3 %%%
> 
> \version "2.11.65"
> \include "english.ly <http://english.ly> "
> 
> \new Voice = "foo" {
>    \override Voice.NoteHead #'color = #red
>    \whichContext
>    c'8
>    cs'8
>    \new Voice = "bar" {
>       \override Voice.NoteHead #'color = #blue
>       \whichContext
>       d'8
>       ef'8
>       \new Voice = "blah" {
>          \override Voice.NoteHead #'color = #green
>          \whichContext
>          e'8
>          f'8
>          fs'8
>          g'8
>       }
>       \whichContext
>       af'8
>       a'8
>    }
>    \whichContext
>    bf'8
>    b'8
> }
> 
> %%% END %%%
> 
> It appears as though the voice contexts are indeed nesting ... perfectly, in
> fact!

I would not say the the contexts nest (i.e., Voice blah is not part of Voice
bar).  But music expressions can be nested, and notes are assigned to voices
by your various music expressions.

It seems to make sense to me, once I understand that there is some monkey
business that goes on when contexts (including, but not limited to Voices)
are implicitly instantiated.

My mental model (which is based on function, not on reviewing code) is that
\new Voice = "Foo" { ... }
says "Create a new context called foo, and put all the notes in this music
expression in Voice "Foo" unless something comes along to change it."

When something comes along to change it, the notes are put in a different
Voice context.  But the new Voice context is not part of the old Voice
context.  Voice is a lowest-level context.

Carl

> 
> And, in fact, John's new \whichContext function emits the following during
> interpretation:
> 
> GNU LilyPond 2.11.65
> Processing `0303.ly <http://0303.ly> '
> Parsing...
> Interpreting music...
> Current voice is foo
> 
> Current voice is bar
> 
> Current voice is blah
> 
> Current voice is bar
> 
> Current voice is foo
> 
> Preprocessing graphical objects...
> Finding the ideal number of pages...
> Fitting music on 1 page...
> Drawing systems...
> Layout output to `0303.ps <http://0303.ps> '...
> Converting to `./0303.pdf'...
> 
> 
> This is nesting, isn't it? (How else to explain the stickiness of the grob
> overrides?) Or have I completely lost my mind?
> 
> (Han-Wen's suggestion about looking over the iterator code makes sense and
> I'll take a look right after I get in a quick jog ... because I think I might
> go mildly insane otherwise ...)
> 
> 
>  





reply via email to

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