Folks,

Assume I want a function that adds a second note a fifth a bove a given pitch (of course this is but an abstraction from a more complicated project).

The difficulty is that this should behave accoding to the key signature in place. Hence, the fifth should not be always perfect but instead be whatever occurs in the active key four note steps above the given pitch. (Quite as in figured bass accompaniment.) Hence:

\version "2.19.80"

addFifth = #(define-music-function (pitch dur) (ly:pitch? ly:duration?)
              (let*
               ((delta (+ 4 (ly:pitch-steps pitch)))
                (new-pitch (ly:make-pitch 0 delta 0))
                (pitches (list pitch new-pitch) )
                (chordNotes (map (lambda (p) (make-music
                                              'NoteEvent
                                              'duration dur
                                              'pitch p))
                              pitches))
                )
               #{
                 #(make-music 'EventChord 'elements chordNotes)
               #}
               )
              )

{
  \addFifth c' 1  % should yield <c g> -> ok
  \addFifth cis' 1    % should yield <cis g> -> ok
  \key a \major
  \addFifth c' 1   % should yield <c gis> -> NOT OK
  \addFifth cis' 1  % should yield <cis gis> -> NOT OK
}

I expect that this amounts to taking the alteration of my new-pitch from the alteration-alist that is "active". But from what I can gather from old postings on -user, this information seems not to be available at the time a music function is called (correct?). What would be the way to go for this?


Best
Lukas


_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to