|
From: | David Nalesnik |
Subject: | Re: Accessing context properties (e.g. the current key) from a music function? |
Date: | Fri, 1 May 2015 07:48:17 -0500 |
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 from doing it straightforwardly:k = "OOPS"text = #(define-music-function (parser location music) (ly:music?) #{ \applyContext #(lambda (context) (set! k (ly:context-property context 'tonic))(display k)
)\transpose #(ly:make-pitch 0 0) #k #music#}) \score { \new Staff { \key a \major \test { Fa So La fa so } } }In that code, the (display k) works fine, displaying #<Pitch a>. But then the \transpose #(ly:make-pitch 0 0) #k #music gets ahold of the global definition of #k rather than the local one and so you end up with a type error: expecting pitch, found "OOPS".So maybe the question is, does Lilypond Scheme have anything like global variables?
[Prev in Thread] | Current Thread | [Next in Thread] |