Right. In the general case, you need to recurse through 'elements and 'element similar to the following:
(define-public (change-pitches music converter) ;; Recurse through music, applying converter to pitches. ;; The converter function must take a single pitch as its ;; argument and return a new pitch. These are LilyPond ;; scheme pitches, e.g. (ly:make-pitch 0 2 0) (let ((es (ly:music-property music 'elements)) (e (ly:music-property music 'element)) (p (ly:music-property music 'pitch))) (cond ((ly:pitch? p) (ly:music-set-property! music 'pitch (converter p))) ((pair? es) (map (lambda (x) (change-pitches x converter)) es)) ((ly:music? e) (change-pitches e converter))))) Cheers, Mike On Sat, Jan 29, 2011 at 8:22 PM, <banners...@ccacompanies.com> wrote: > Thanks > > (car ) was the trick I would have been looking for a long time to come up > with that one. > > (car (...))- returns the first member of a list. > > I'm assuming that if that member is a function it returns the functions > result, which is why we get the solution? > > Scott > > > -----Original Message----- > From: Michael Ellis [mailto:michael.f.el...@gmail.com] > Sent: Saturday, January 29, 2011 07:01 PM > To: banners...@ccacompanies.com > Cc: lilypond-user@gnu.org > Subject: Re: Nesting ly:music-property error > > Sorry, my previous answer was rubbish. The following runs without error and > prints the pitch object. myN = #(define-music-function (parser location myx > ) (ly:music?) (display-scheme-music (ly:music-property (car > (ly:music-property myx 'elements)) 'pitch)) myx) \myN c Cheers, Mike On Sat, > Jan 29, 2011 at 6:46 PM, Michael Ellis wrote: > Hi Scott, > > I think the > problem is that the music in your example doesn't have an > 'elements > property. You can eliminate the error by changing the third > line in your > code to > > #(display-scheme-music (ly:music-property $myx 'pitch)) > > but > what gets displayed is an empty list '(). Probably not what you > want, > right? > > Some of the more experienced Schemers on the list may be able to > offer > better help. > > Cheers, > Mike > > > > On Sat, Jan 29, 2011 at 6:28 > PM, wrote: >> myN = #(define-music-function (parser location myx ) > (ly:music?) >> #{ >> #(display-scheme-music (ly:music-property > (ly:music-property $myx 'elements) >> 'pitch)) >> #}) >> >> \myN c > _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user