lilypond-user
[Top][All Lists]
Advanced

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

Re: Ambitus


From: David Kastrup
Subject: Re: Ambitus
Date: Sat, 27 Feb 2010 16:03:15 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.92 (gnu/linux)

Neil Puttock <address@hidden> writes:

> On 5 February 2010 00:18, Neil Puttock <address@hidden> 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.

But wouldn't scores in a book use separate engraver instantiations and
have separate ambitus for that reason?

> \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))))))

Uh, what's with the $defaultheader here?

>    (define (ambitus-markup key pitches)
>      (let* ((music (make-sequential-music
>                     (list (make-time-signature-set 2 4)
>                           (make-grob-property-set 'TimeSignature
>                                                   'stencil #f)
>
>    (ly:parser-define! parser 'pitches '())
>    (ly:parser-define! parser 'key-list '())

What does that do?  Why per-parser?

>    (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))

What does this do?  Route the music expression through a parser with a
simple listener, then regurgitate it for the outer context?

> \new Staff \ambitus \relative c'' {
>   \key g \major
>   g8 a b c d e fis g
>   a1
> }

It would seem that this approach would not work when you want, say, an
ambitus per Voice, and the input is not continuous, but repeatedly
switches between contexts.

Then you don't have the whole music available as one music expression.

But frankly: I don't get half of what you are doing here, so I may well
be mistaken.

-- 
David Kastrup





reply via email to

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