Re: Accessing context properties (e.g. the current key) from a music function?

2015-05-05 Thread Leah Velleman
The problem arises because \applyContext is evaluated later than \transpose. When music functions do their work, contexts have not been created yet, The output shows that the original binding of k is in effect when \transpose is called. Aha! Thank you — that makes sense.

Re: Accessing context properties (e.g. the current key) from a music function?

2015-05-01 Thread David Nalesnik
Hi Leah, On Thu, Apr 30, 2015 at 7:28 PM, Leah Velleman leah.velle...@gmail.com wrote: To do something like you want, you really would need access to context properties Ok — good to know I haven't missed some simple solution. It seems like there ought to be some way of smuggling

Re: Accessing context properties (e.g. the current key) from a music function?

2015-05-01 Thread David Nalesnik
On Fri, May 1, 2015 at 7:48 AM, David Nalesnik david.nales...@gmail.com wrote: test = #(define-music-function (parser location music) (ly:music?) (let ((k ERROR)) #{ \applyContext #(lambda (context) (set! k (ly:context-property context 'tonic))

Accessing context properties (e.g. the current key) from a music function?

2015-04-30 Thread Leah Velleman
I'm looking to write a \transpose-like music function that will need to be able to find out what the current key is. (In case it matters: The reason I'm doing this is to make it possible to enter music using movable-do solfege. The idea is to have a function \movableDo that will transpose from C

Re: Accessing context properties (e.g. the current key) from a music function?

2015-04-30 Thread David Nalesnik
On Thu, Apr 30, 2015 at 6:41 PM, David Nalesnik david.nales...@gmail.com wrote: P.S. Now I'm going to set out to break it... Well, with simultaneous music you do end up having to repeat the key. \test \new PianoStaff \new Staff \new Voice { \key re \major \voiceOne

Re: Accessing context properties (e.g. the current key) from a music function?

2015-04-30 Thread Leah Velleman
Oh goodness, something heinous happened to the formatting there. Let me try that again. k = ERROR test = #(define-music-function (parser location music) (ly:music?) #{ \applyContext #(lambda (context) (set! k (ly:context-property context 'tonic)) (display k) )

Re: Accessing context properties (e.g. the current key) from a music function?

2015-04-30 Thread Leah Velleman
Ah! I hadn't even gotten as far as thinking about key-change events *within* the scope of the music function, though you're right that those would be an issue too (and your suggestion looks like a sensible way of dealing with them). What I was trying to get at was the key that was current before

Re: Accessing context properties (e.g. the current key) from a music function?

2015-04-30 Thread David Nalesnik
Leah, On Thu, Apr 30, 2015 at 6:34 PM, Leah Velleman leah.velle...@gmail.com wrote: Ah! I hadn't even gotten as far as thinking about key-change events *within* the scope of the music function, though you're right that those would be an issue too (and your suggestion looks like a sensible way

Re: Accessing context properties (e.g. the current key) from a music function?

2015-04-30 Thread David Nalesnik
Hi Leah, On Thu, Apr 30, 2015 at 3:16 PM, Leah Velleman leah.velle...@gmail.com wrote: I'm looking to write a \transpose-like music function that will need to be able to find out what the current key is. (In case it matters: The reason I'm doing this is to make it possible to enter music

Re: Accessing context properties (e.g. the current key) from a music function?

2015-04-30 Thread David Nalesnik
Hi Harm, On Thu, Apr 30, 2015 at 6:36 PM, Thomas Morley thomasmorle...@gmail.com wrote: 2015-05-01 1:23 GMT+02:00 David Nalesnik david.nales...@gmail.com: %% \version 2.18 \language italiano % the closest preset :) test = #(define-music-function

Re: Accessing context properties (e.g. the current key) from a music function?

2015-04-30 Thread Leah Velleman
To do something like you want, you really would need access to context properties Ok — good to know I haven't missed some simple solution. It seems like there ought to be some way of smuggling information out of an \applyContext. But I guess there's a variable scope issue that keeps you

Re: Accessing context properties (e.g. the current key) from a music function?

2015-04-30 Thread Thomas Morley
2015-05-01 1:23 GMT+02:00 David Nalesnik david.nales...@gmail.com: Hi Leah, On Thu, Apr 30, 2015 at 3:16 PM, Leah Velleman leah.velle...@gmail.com wrote: I'm looking to write a \transpose-like music function that will need to be able to find out what the current key is. (In case it