On 5 February 2010 00:18, Neil Puttock <n.putt...@gmail.com> wrote: > Yes (see attached file). I had to move the markup outside the > 'finalize method though, since it wouldn't evaluate it directly.
I've come to the conclusion using an engraver is a waste of time; its only benefit is that the storage of the pitches/key signature is simpler. I think combining my original approach of a music function with some extra listener code is better, since it allows scores in a book to have separate ambitus. \version "2.13.14" \header { } ambitus = #(define-music-function (parser location music) (ly:music?) (define (add-stream-listener global listener . types) (apply ly:add-listener (cons* listener (ly:context-events-below global) types)) global) (define (process-event event) (case (ly:event-property event 'class) ((note-event) (set! pitches (cons (ly:event-property event 'pitch) pitches))) ((key-change-event) (and (null? key-list) (set! key-list (ly:event-property event 'pitch-alist)))) ((Finish) (set! pitches (stable-sort pitches ly:pitch<?)) (if $defaultheader (module-define! $defaultheader 'ambitus (ambitus-markup key-list pitches)))))) (define (ambitus-markup key pitches) (let* ((music (make-sequential-music (list (make-time-signature-set 2 4) (make-grob-property-set 'TimeSignature 'stencil #f) (make-music 'KeyChangeEvent 'pitch-alist key) (make-event-chord (list (make-music 'NoteEvent 'duration (ly:make-duration 2 0 1 1) 'pitch (first pitches)))) (make-event-chord (list (make-music 'NoteEvent 'duration (ly:make-duration 2 0 1 1) 'pitch (last pitches))))))) (score (ly:make-score music)) (layout (ly:output-def-clone $defaultlayout))) (ly:output-def-set-variable! layout 'indent 0) (ly:score-add-output-def! score layout) (make-score-markup score))) (ly:parser-define! parser 'pitches '()) (ly:parser-define! parser 'key-list '()) (let* ((global (ly:make-global-context $defaultlayout)) (listener (ly:make-listener process-event)) (global-disp (ly:context-events-below global))) (ly:connect-dispatchers (ly:make-dispatcher) global-disp) (add-stream-listener global listener 'note-event 'key-change-event 'Finish) (ly:interpret-music-expression music global) music)) \new Staff \ambitus \relative c'' { \key g \major g8 a b c d e fis g a1 } Cheers, Neil _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user