Music AI Program

Terry Hancock hancock at anansispaceworks.com
Sun Dec 15 03:14:05 EST 2002


On Saturday 14 December 2002 08:59 pm,  Joel wrote:
>     I'm trying to find a way to give the computer all the strings. I've
> tried variables such as e4=4 for E string fret 4, with a dummy value of
> 4...all 22 of them for every string, but I'm not really sure what would work
> best. I only finished a Python tutorial a few weeks back!

IMHO, use a dictionary with tuple keys:

notes = {
            ('E',4): 4,
            ('F',2): 4
            }

and so on. If you need more than one piece of info attached to each note, use 
a tuple.  I gather that you mean for this to map to a quality score that your 
algorithm is going to use to select notes.

I would also use a mechanism like this to map the note identification tuple 
to the means of producing the notes. This could be standard arguments for a 
MIDI driver function or even (more advanced, but possibly more flexible) a 
lambda or defined function to call the driver (in the latter case a "factory" 
class generating callable instances is actually better than a straight 
function).  This is more flexible, because you can easily alter the factory 
to support alternate backend actions: play the MIDI, play on your sound card, 
write the data to disk, drive a musical notation generator like MusicTeX, and 
so on.

Cheers,
Terry

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

"Some things are too important to be taken seriously"




More information about the Python-list mailing list