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 _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user