Hey Jim, I think this does what you want... \version "2.13.29"
createKey = #(define-music-function (parser location m k) (ly:music? list?) (let* ((p (ly:music-property (car (ly:music-property m 'elements)) 'pitch)) (o (ly:pitch-octave p)) (n (ly:pitch-notename p)) (a (ly:pitch-alteration p)) (tonic (ly:make-pitch o n a)) (pitch-alist (ly:transpose-key-alist k tonic))) (make-music 'KeyChangeEvent 'tonic tonic 'pitch-alist pitch-alist))) majorKey = #(define-music-function (parser location m) (ly:music?) #{ \createKey $m \major #}) % canonical \relative c' { \key b \major a b } % new way \relative c' { \majorKey b a b } On 7/30/10 5:37 AM, "jim.showalter" <jim.showal...@verizon.net> wrote: > I have searched the archives and cannot find why the following is happening. > They are contrived to demonstrate a larger problem. > > This one works as expected > > majorKey = #(define-music-function (parser location note ) (ly:music?) > #{ > a $note g > #}) > > { > \majorKey g > } > > > > But what I really want to do is something like this. > > majorKey = #(define-music-function (parser location note ) (ly:music?) > #{ > \key $note \major > #}) > > { > \majorKey g > } > > I get an error message about that it is expecting "\default or > NOTENAME_PITCH" I get a similar error for > transpose. Is there another variable type (other than ly:music) that should > be used? Can anyone explain this behavior? > > Thanks, > Jim > > > _______________________________________________ > lilypond-user mailing list > lilypond-user@gnu.org > http://lists.gnu.org/mailman/listinfo/lilypond-user > _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user