> Would it be possible to tell changePitch to automatically repeat the pitch
> of a tied note?
Well, i have just read your message just yesterday. Sorry.
Here is a function that automatically repeats the pitch
of a tied note.
I'll try to include it in a next release of changePitch.ly


-- 
Gilles
\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 }
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to