Hi,
I'm writing a method to create musical chords.

This method must follow a specific set of syntax rules. At least, this
is my idea, but maybe there's a better way.
Anyway, in the code I have class Chord which is a set.

The costrunction of a chord is based on a root note and a structure,
so by default, giving just a note, it creates a major chord adding the
third and fifth note.

So, in pseudo-code: Chord(C) -> [C, E, G]

And this is the base case. All the other rules must specify what kind
of note to add or which one should be modified.

For example:   C min, means to add the third minor note: C Eb G

C 9 is a base chord plus a the ninth note, but this implies the
presence of the seventh too, so it results in: C E G B D

But I can also say: C 9 no7, so it should just be: C E G D, without the seventh.

There are also more complex rules. For the eleventh, for example, it
should add also the ninth and seventh note. In the normal case it adds
their major version, but I can specify to add an augmented nine, so
this modification must have precedence over the base case.

Anyway, I think I can use a chain of  if-clauses, one per rule and at
the end remove the notes marked with "no". But this seems to me a very
bad solution, not so pythonic. Before I proceed for this way, do you
have any suggestion? Hope the problem is not too complicated.

Thanks,
Carlo
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to