|
From: | David Nalesnik |
Subject: | Re: Accessing context properties (e.g. the current key) from a music function? |
Date: | Thu, 30 Apr 2015 18:41:32 -0500 |
This seems to work as well, or am I missing something?> %%%%%%%%%%%%%%%%%%%%%%%%%%
>
> \version "2.18"
>
> \language "italiano" % the closest preset :)
>
> test =
> #(define-music-function (parser location music)
> (ly:music?)
> (let ((t (ly:make-pitch 0 0))) ; C is the default tonic
> (music-map
> (lambda (mus)
> (if (music-is-of-type? mus 'key-change-event)
> (set! t (ly:music-property mus 'tonic)))
> (if (music-is-of-type? mus 'note-event)
> #{
> \transpose #(ly:make-pitch 0 0) #t #mus
> #})
> mus)
> music)
> music))
>
\test
\new Staff {
\new Voice {
{
\key re \major
do'4 mi' sol' do'' <do' mi' sol'>1
}
{
\key fa \major
do'4 mi' sol' do'' <do' mi' sol'>1
}
{
\key sol \minor
do'4 mib' sol' do'' <do' mib' sol'>1
}
}
}
Cheers,
Harm
[Prev in Thread] | Current Thread | [Next in Thread] |