|
From: | Gilles |
Subject: | Re: Extract notes within music function |
Date: | Wed, 07 Nov 2012 21:28:18 +0100 |
User-agent: | Opera Mail/12.02 (Win32) |
Is it possible to extract individual notes from the music passed to a music function, e.g.:\myFunction { c d e f } Within myFunction, can I do something like car notes cdr notes
Here is a kind of template, but i am not absolutely sure it's what you want.
%%%%%%%%%%%%%%%%%%%% myFunction = #(define-music-function (parser location music)(ly:music?) (map-some-music (lambda (evt) (let ((name (ly:music-property evt 'name))) (cond ((eq? name 'EventChord) ; to see the structure of a chord (display-scheme-music evt); to comment ; do something with the chord evt) ; return the modified chord - don't go deeper ((eq? name 'NoteEvent) ; to see the structure of a note (display-scheme-music evt); to comment ; do something with note evt) ; return the modified note - don't go deeper (else #f)))) ; => #f = continue, go deeper music)) music = \relative { c2->\f <e g c>2-> } \myFunction \music %%%%%%%%%%%%%%%%%%%% -- Gilles
[Prev in Thread] | Current Thread | [Next in Thread] |