lilypond-user
[Top][All Lists]
Advanced

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

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


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

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)                                                                                                
    )                                                                                                                  
    \transpose #(ly:make-pitch 0 0) #k #music                                                
  #}                                                                                                                  
)                                                                                                                      
\score {                                                                                                          
  \new Staff {                                                                                                  
    \key a \major                                                      
    \test { Fa So La fa so }                                                                              
   }                                                                                                                  
}



reply via email to

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