[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: LSR - Adding extra fingering with scheme - Needs update.
From: |
David Kastrup |
Subject: |
Re: LSR - Adding extra fingering with scheme - Needs update. |
Date: |
Tue, 10 Sep 2013 03:01:55 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
Thomas Morley <address@hidden> writes:
> #(define (make-text-script x)
> (make-music 'TextScriptEvent
> 'direction DOWN
> 'text x))
>
> #(define (add-text-script m x)
> (cond ((music-is-of-type? m 'event-chord)
> (set! (ly:music-property m 'elements)
> (cons (make-text-script x)
> (ly:music-property m 'elements))))
> ((music-is-of-type? m 'note-event)
> (set! (ly:music-property m 'articulations)
> (cons (make-text-script x)
> (ly:music-property m 'articulations))))
> (else (let ((es (ly:music-property m 'elements))
> (e (ly:music-property m 'element)))
> (map (lambda (y) (add-text-script y x)) es)
(for-each ...
> (if (ly:music? e)
> (add-text-script e x))
> )))
> m)
#(define (add-text-script m x)
(define (append-property! music property element)
(set! (ly:music-property music property)
(append! (ly:music-property music property)
(list element)))
music)
(map-some-music
(lambda (m)
(cond ((music-is-of-type m 'event-chord)
(append-property! m 'elements (make-text-script x)))
((music-is-of-type m 'note-event)
(append-property! m 'articulations (make-text-script x)))
;; don't recurse into other rhythmic events
((music-is-of-type m 'rhythmic-event) m)
;; recurse:
(else #f)))
m))
That's the "proper" variant (as opposed to the original, it _returns_
the modified music however). One has to note that the improper variant
will generally work as well: adding material to 'articulations works for
both 'event-chord as well as 'note-event so one can drop the
distinction. It's not what LilyPond itself would do, however.
Of course, not recursing into other rhythmic events is just an
optimization that's not particularly important.
--
David Kastrup