lilypond-user
[Top][All Lists]
Advanced

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

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


From: Leah Velleman
Subject: Accessing context properties (e.g. the current key) from a music function?
Date: Thu, 30 Apr 2015 16:16:27 -0400

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 (i.e. "do" in a fixed-do system) to the tonic of the current key, so that

\key a \major
\movableDo { do re mi fa so }

will produce the same output as

\key a \major
a b cs d e

Of course, it would be possible to require the user to repeat the key information, by writing this:

\key a \major
\movableDo a { do re mi fa so }

But this is inconveniently redundant, and makes errors more likely in large source files, since the key must now be written in many different places. So I'm trying to avoid doing it this way if possible.)

In any case, I'm having a very difficult time figuring out how a music function can get access to the key. It seems that the issue is that the key is a context property; music functions do not take a context as an argument, and thus can't get access to context properties the way a function written with make-apply-context could. But I can't see how to get around that limitation, or indeed whether it would be possible to get around it at all.

Suggestions?

-Leah

reply via email to

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