Music knowledge representation
mr.spoon21 at gmail.com
Sun Sep 28 16:37:11 CEST 2008
I'm working on an application to analyse music (melodies, chord sequences etc.)
I need classes to represent different musical entities. I'm using a
class Note to represent all the notes. Inside it stores the name of
the natural version of the note (C, D, E, F...) and an integer to
calculate the accidentals.
Then I have a class Pitch, to represent the different 12 pitch
classes, because different notes, such as C# and Db, belong to the
same pitch class.
In these classes I also have some arithmetic method to perform
additions or subtractions between pitches and integers.
I also need to represent intervals between notes. An interval must
have a degree (first, second, third), that may be represented with a
simple integer and a size counted in semitones. Then, with these
informations it can retrieve its name, for example: perfect fifth.
The degree is calculated between natural notes. So the degree of
Interval(C, E) is "third", or 3. This may be simple, if I put the
notes in an ordered sequence. But, when I have to calculate, for
example Interval(E, C). It should count till the end of the sequence,
so if I have:
C D E F G A B
after the B it should continue with C. I'm not sure how to implement
this. Is there a suitable data structure for this purpose?
More information about the Python-list