lilypond-user
[Top][All Lists]
Advanced

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

RE: Generating pitches depending on key signature


From: Mark Stephen Mrotek
Subject: RE: Generating pitches depending on key signature
Date: Sat, 28 Apr 2018 07:58:32 -0700

Lukas,

A snippet to create octaves. Perhaps you could modify.

http://lsr.di.unimi.it/LSR/Item?id=445

Mark

-----Original Message-----
From: lilypond-user [mailto:address@hidden On Behalf Of Lukas-Fabian Moser
Sent: Saturday, April 28, 2018 2:16 AM
To: lilypond-user <address@hidden>
Subject: Generating pitches depending on key signature

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
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user




reply via email to

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