\include "changePitch.ly" %% to download here : %% http://gillesth.free.fr/Lilypond/changePitch/ %% LSR here : %% http://lsr.di.unimi.it/LSR/Item?id=654 checkForTies = #(define-music-function (parser location music) (ly:music?) "A tieded note will get automatically the same pitch than the previous note (= the note with the tie symbole)" (define (rel-callback x p) ; set pitch to the prev value (ly:prob-set-property! x 'pitch p) p) (let ((tieNote? #f) (startSamePich? #f) (stopSamePich? #f)) (map-some-music (lambda (x) (and (note-or-chord? x) (let ((tags (ly:music-property x 'tags))) (if (not (memq cPSamePitch tags)) (begin (set! tieNote? (pair? (extract-named-music x '(TieEvent)))) (set! stopSamePich? (and startSamePich? (not tieNote?))) (set! startSamePich? (and tieNote? (not startSamePich?))) (cond (startSamePich? (ly:music-set-property! x 'tags (cons cPSamePitch (delq cPSamePitchEnd tags)))) (stopSamePich? (ly:music-set-property! x 'to-relative-callback rel-callback) (if (not (memq cPSamePitchEnd tags)) (ly:music-set-property! x 'tags (cons cPSamePitchEnd tags)))) (tieNote? (ly:music-set-property! x 'to-relative-callback rel-callback) (ly:music-set-property! x 'tags (cons cPSamePitch (delq cPSamePitchEnd tags))) (set! startSamePich? #t))))) x))) music))) %%%%%%%%%%%%%%%%%%%%%%% %% test 1 \changePitch \checkForTies { c4 c4~ \tuplet 3/2 { c8 c8 c8 } c4 | } \relative c' { c d e f g a b c d e } %% test 2 (with \samePitch) \changePitch \checkForTies { c4 c4~ \tuplet 3/2 \samePitch { c8 c8 c8 } c4 | } \relative c' { c d e f g a b c d e }