lilypond-user
[Top][All Lists]
Advanced

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

Re: force accidentals


From: Nicolas Sceaux
Subject: Re: force accidentals
Date: Sun, 10 Jul 2005 16:37:30 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin)

"Mehmet Okonsar" <address@hidden> 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




reply via email to

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