lilypond-user
[Top][All Lists]
Advanced

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

Re: question about transposing an interval of a 4th


From: John Mandereau
Subject: Re: question about transposing an interval of a 4th
Date: Mon, 22 Dec 2008 00:29:52 +0100

Le dimanche 21 décembre 2008 à 09:47 -0800, Graham Percival a écrit :
> On Sun, Dec 21, 2008 at 11:26:16PM +1100, Cameron Horsburgh wrote:
> > He wants it diatonic, so it's not that easy. \transpose c' g {a b c} 
> > would produce {e fis g} instead of {e f g}.
> 
> Oops, I forgot my first-year theory.  In this case, he'd need to
> write a scheme function.  Actually, it wouldn't be hard at all...
> this is a perfect intro-level scheme tweak.
> 
> I leave it as an exercise for the reader.  Neil, Trevor, Valentin:
> please don't give the answer.  :)

Ha!  I won't give the whole answer either, but as I already analyzed the
problem some time ago, I can't resist telling about it here, only
figuring out data types and Lily Scheme function to be used (see Scheme
functions in the Internals Reference) and the actual Scheme code writing
are left now.

ly/scale-definitions-init.ly provide a few scale definitions; each scale
definition maps a scale degree to a pitch difference (measured in whole
tones) against the diatonic scale.

Then, diatonic transposition from (scale1 pitch1 degree1) to (scale2
pitch2 degree2) (where pitchx carries both the octave and the tonic) is
a matter of composing three functions:

- converting each pitch from LilyPond representation (octave note alter)
to (octave scale-degree alter) representation using the inverse map of
scale1;

- mapping (octave scale-degree alter) to
((octave + virtual-new-degree/7) (virtual-new-degree mod 7) alter)
where virtual-new-degree = scale-degree + degree2 - degree1

- converting (new-octave new-degree alter) back to a Lily pitch using
scale2.

Transposition in modes with more than 7 notes is also possible but it's
quite harder, unless we use more than 7 note names :-P.

Well, diatonic transposition should definitely be a builtin function.
If nobody has written it in a few days, I'll take it over.

Cheers,
John





reply via email to

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