On 30 Dec 2010, at 23:16, Felipe Gonçalves Assis wrote:
1. How should we represent alterations?
It is clear to me that the most general representation would be as
a list of integers of arbitrary length (see sections 1 and 2 of the
attachment).
I made a proposal for a representation, and there is Haskell code
available if you are interested.
In it, the staff positions are expressed by a linear combinations of a
sequence of seconds m, M, n_0, ..., n_k (whatever names you want to
give them). If one only has a minor second m and a major second M,
then sharps raise with the interval M - m and the flats lower with
that interval.
So I generalized this as to compute for any set of accidentals. The
algorithm will depend on the typesetting preferences, but it is
possible to compute them without any reference to pitches at all.
1.1. How do we implement the mapping from alterations to tones?
A simple idea is to replace the list of integers by a list of
rationals,
corresponding to the value of the alteration in tones. This is the
current approach, except for the fact that the list has length 1.
Rational numbers are not sufficient for the theoretically given: one
must be able to take roots, for example when computing meantone values.
So, for the exact given values, I added those roots. This suffices, as
one is never going to add the numbers of the intervals - interval
addition correspond to multiplication of numbers. The implementation
representation I chose was as a prime factorization - a map from prime
numbers to rational numbers. This seems to work well, as one is
typically just working with a few small prime numbers.
But when working with inexact intervals, like in pitch bends or given
s cents, etc., this proved inconvenient.
So I added an inexact part, a floating point number (double). The
representation is thus (r, x), where r is the exact number above, and
x a floating point number. When x = 1.0, the representation is
considered exact.
_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel