Music knowledge representation

Mr.SpOOn mr.spoon21 at gmail.com
Mon Sep 29 14:29:44 EDT 2008


On Mon, Sep 29, 2008 at 6:49 PM, D'Arcy J.M. Cain <darcy at druid.net> wrote:
> On Sun, 28 Sep 2008 16:37:11 +0200
> "Mr.SpOOn" <mr.spoon21 at gmail.com> wrote:
>> Hi,
>> I'm working on an application to analyse music (melodies, chord sequences etc.)
>
> Sounds interesting.  Will this be Open Source?

Well, yes, I think.

> Have you considered having the object take a key option with default to
> 'C' so that you don't have to mark as many accidentals - or, more
> correctly, mark actual accidentals rather than always marking the
> "black keys?"

Well, one of the analysis task would consist in finding a possible
tonality from a set of note. Or, more useful, give a set of playable
notes over certain given chords.


> Couldn't the note class simply have a list of all the notes and have a
> simple method calculate the actual pitch?

That's not really how it works. There exists just 12 octave
independent pitch classes. This means that there is a pitch class C
with all possible Cs. There ambiguities with accidentals, because
different named notes fall in the same pitch class. The difference is
important for the musical theory, because C# and Db belongs to the
same pitch class (actually they are the same note, they sounds
completely identical -- because on the piano you play them pressing
the same key), but in a scale they have a very different role.

For example, the interval C F# is an "augmented fourth", because what
really matters are the natural note (C and F), and their distance if
4. Then it is augmented due to the #-

But the interval C Gb (Gb is the same as F#) is a "diminished fifth".

So I can't list all pitches.


>    def interval(self, lower, higher)
>        if lower > higher:
>            # uncomment one of the two following lines depending
>            # on the behaviour you want
>            #lower,higher = higher,lower
>            #higher += 12
>
>        # could use some error trapping
>        return self.interval_name[higher - lower]
>
> Note that lower and higher could be a note object that you have to
> convert to integers first.

I can't estabilish which note is higher, because all the analysis part
is octave independent. Anyway thanks for the ideas.

I think itertools is what I need.



More information about the Python-list mailing list