"Mehmet Okonsar" <[EMAIL PROTECTED]> writes:

> can the function be modified for NOT having the alteration or the natural on
> repeated notes in the same octave..
> ********
> forceAlterations =
>   #(def-music-function (parser location music) (ly:music?)
>      (music-map (lambda (m)
>                   (if (eqv? (ly:music-property m 'name) 'NoteEvent)
>                       (set! (ly:music-property m 'force-accidental) #t))
>                   m)
>                 music)
>      music)
> *********

Please keep discussion on the mailing list.

I'm not sure what you exactly want.  If you want that alterations of
notes on the same octave AND the same bar are not repeated, the quick
answer is: I don't know. Otherwise, you might experiment with the
following function and try to tailor it to your needs.

\version "2.7.0"

forceAlterations = 
  #(let ((alteration-memo (make-hash-table 50)))
     (define (last-alteration ly-pitch)
       (hash-ref alteration-memo
                 (cons (ly:pitch-notename ly-pitch)
                       (ly:pitch-octave ly-pitch))))
     (define (register-alteration! ly-pitch)
       (hash-set! alteration-memo
                  (cons (ly:pitch-notename ly-pitch)
                        (ly:pitch-octave ly-pitch))
                  (ly:pitch-alteration ly-pitch)))
     
     (def-music-function (parser location music) (ly:music?)
       (music-map (lambda (m)
                    (if (eqv? (ly:music-property m 'name) 'NoteEvent)
                        (let ((pitch (ly:music-property m 'pitch)))
                          (if (not (equal? (last-alteration pitch)
                                    (ly:pitch-alteration pitch)))
                              (set! (ly:music-property m 'force-accidental) #t))
                          (register-alteration! pitch)))
                    m)
                  music)
        music))

\forceAlterations { 
  \time 5/4
  c' des' e' fis' gis' 
  c' des' e' fis' gis' 
  c' d' e' f' g' 
  c' d' e' f' g' 
}

But I don't think this is near what you want.

nicolas


_______________________________________________
lilypond-user mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to