lilypond-user
[Top][All Lists]
Advanced

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

Re: add tenuto


From: Gilles THIBAULT
Subject: Re: add tenuto
Date: Mon, 2 Jun 2008 00:00:56 +0200

 

#(define (addTenutoFilterFunction event)
 (let ( (eventname (ly:music-property  event 'name)) )
  (if (eq? eventname 'EventChord)
    (let ( (elements (ly:music-property event 'elements)) )
      ; don't add staccato to rests!
      (if (not (eq? (ly:music-property (car elements) 'name) 'RestEvent))
        (set! (ly:music-property event 'elements)
          (append elements (list (make-music 'ArticulationEvent 'articulation-type "tenuto"))
          ))))))
)

addTenuto = #(define-music-function (parser location music) (ly:music?)
 (music-filter addTenutoFilterFunction music)
)

\new Staff \relative { \addTenuto { c d e f~ f e d c } }
 
 
Could it be possible to exclude those notes, that follows the one with the tie?
Yes but perhaps music-filter is not convenient for that because it gives you the differents events in a order : sub-elements, elements.
here is a version which seems to work with ties.
(i do not test it a lot)
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

#(define tieEvent? #f)
 
#(define (add-Tenuto music)
 (let (
    (eventname (ly:music-property  music 'name))
    (elts (ly:music-property music 'elements))
    (elt  (ly:music-property music 'element))
 )
 (cond
    ((pair? elts)
        (begin
            (if (and
                    (eq? eventname 'EventChord)
                    (eq? (ly:music-property (car elts) 'name) 'NoteEvent)
                    (not tieEvent?)
                 )   
                (set! (ly:music-property music 'elements)
                        (append elts (list (make-music 'ArticulationEvent 'articulation-type "tenuto"))))
                (set! tieEvent? #f)  
            )
            (map add-Tenuto elts)
        )
    )
    ((ly:music? elt) (add-Tenuto elt))
    ((eq? eventname 'TieEvent) (set! tieEvent? #t))
 ) 
 music
))
 
addTenuto = #(define-music-function (parser location music) (ly:music?)
 (set! tieEvent? #f)
 (add-Tenuto music)
)
 
 
\new Staff \relative { \addTenuto { c d e f~ f e d c } }
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
Gilles

reply via email to

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