Music knowledge representation

M

Mr.SpOOn

Hi,
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?
 
A

Aaron \Castironpi\ Brady

Hi,
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?

Hi,

Here is a link to someone else's design they asked about on the
newsgroup a couple weeks ago.

http://groups.google.com/group/comp...084b984dc?lnk=st&q=sharpnote#921cba3084b984dc
 
A

Aaron \Castironpi\ Brady

:D
It's always me.

I think my question is more specific. I need some sort of cycle.

So if I have a list with A, B, C, D, when I iter over it I need to get
an A after the D.

This one was an easy guess:

cycle( iterable)

Make an iterator returning elements from the iterable and saving a
copy of each. When the iterable is exhausted, return elements from the
saved copy. Repeats indefinitely.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top