lilypond-user
[Top][All Lists]
Advanced

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

Re: Accessing Context Properties


From: tisimst
Subject: Re: Accessing Context Properties
Date: Thu, 25 Feb 2016 11:55:03 -0700 (MST)



On Thu, Feb 25, 2016 at 11:03 AM, David Kastrup [via Lilypond] <[hidden email]> wrote:
tisimst <[hidden email]> writes:

> David,
>
>> All of that cannot be done from within a music function.  I repeat:

>> All they can do is create music expressions (typically overrides or
>> applyContext calls, possibly as context modifications) that contain
>> callbacks of some form that, when ultimately called during iteration
>> of the music _expression_, will be able to access actual properties.
>>
>> That has nothing to do with music functions at all but rather with
>> the kind of music expressions you'd want the music function to
>> create.
>
> I got that from your first message. I promise. I just am not sure what
> this means. Can you point me to a snippet (in the LSR?) that shows
> this?
Shows _what_? 

Shows an example of a "kind of music _expression_ you'd want the music function to create." If that's too broad a request, don't worry about it. I just learn lots better when I have a concrete example to dissect. That's all I meant.
 
> That would help a lot.

>
>> > These are just examples and I'm not even asking for specifics on
>> > how to do these (as they've partially been discussed in other
>> > threads). What approach would I want to follow in order to access
>> > the properties so I could make a change elsewhere?
>>
>> Have you read what I wrote?  Music functions are not able to access
>> properties.  Various music expressions (possibly created by music
>> functions) may contain callbacks that might be used for such
>> purposes.
>>
>
> Thanks you for your reply. Yes, I definitely read what you wrote. I
> realize that music functions aren't the way to go and you've made that
> perfectly clear. I didn't even mean to imply in my previous response
> that I wanted to do those things with music functions. I don't care
> what the mechanism is. I just want to know what it is!
So do you or don't you care to know?

What I meant is that it doesn't matter to me what it contains, what it's called, etc. I'd just like to see what one looks like so I know what I have to do when I the need arises.
 
At any rate, there are a number of different mechanisms where accessing
context properties make sense.

Basically all of the _user_-accessible mechanisms occur in the context
of engravers, as event listeners, acknowledgers, end acknowledgers.
Iterators are not user-definable, so there is little opportunity to
access context properties from within them, but they may call callbacks
like the elements-callback of sequential expressions.  There is also
\applyContext.

> That is exactly why I asked "what approach would I follow in order to
> access the properties so I could make a change elsewhere?".

It depends on what you want to do.  There is no general answer.

That is helpful to know. Thank you.
 
> I have no idea where your statements are supposed to be leading me.
> I'd really like to know, though.

Shrug.  Without a specific question, there will be no specific answer.

> Would you be kind enough to show how YOU would access a context
> property and use its value in an grob override?

Actually, one usually wouldn't (sorry for having mentioned them in that
context).  Grob callbacks are usually called on-demand, at a time where
iteration has already completed and contexts are no longer available.

> Perhaps it's too dependent on what I'd actually like to do.

It very much depends on what you want to do.

So, are there general categories of when you'd need to do it one way over another?
 
> I'm asking this because I know that if I can get my hands on a grob,

But you can't.  Not in a music _expression_.  Only in various other
contexts.

> I know how to access its properties (with ly:grob-property) and use
> that property's value to make a change if I want (e.g., with
> ly:grob-set-property!). I just don't know the equivalent process for
> getting my hands on a context to access its properties.

The equivalent process to _what_?  You did not specify _how_ you are
getting your hands on a grob, so how can one answer with an "equivalent"
process for getting your hands on a context?

For example: 
  \override TimeSignature.stencil = #(lambda (grob) ... )
  \override Arpeggio.before-line-breaking = #(lambda (grob) ... )
 
> Now, when you say a music _expression_ that contains callbacks might be used,
> do you mean like this (Warning: made-up, non-functional pseudo-code ahead):
>
> %%%%%%%
>
> test = { \applyContext ... (get currentBarNumber, change MMR stencil using
> currentBarNumber set bar number visibility, etc.) ... }
>
> { c1 \test R1*2 d2 e }

That's probably the most straightforward mechanism through which a music
_expression_ can trigger accesses to context properties.  It's actually
not used all that often, but it's there too.  Yes.

Thank you! Knowing that is enough to encourage me to look more deeply into that. If \applyContext isn't used all that often, what would you recommend in its place? A custom engraver?

Much appreciated,
Abraham


View this message in context: Re: Accessing Context Properties
Sent from the User mailing list archive at Nabble.com.

reply via email to

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