About Me

My photo
By day I'm a propeller-head geek. I design software for electronic components for a major automotive supplier. When I'm not earning a paycheck, I enjoy playing music -- primarily jazz and classical but I dabble in other genres as well. I also compose, arrange, and play with electronic gadgets and toys. My other hobbies include photography, colored pencil drawing, genealogy, model railroading, and crosswords.

Wednesday, May 15, 2013

A Simple Composition Algorithm According to Guido

I'm reading Musimathics, by Gareth Loy. Composition and methodology is the subject of volume 1, chapter 9, where "Guido's Method" is discussed. The author presents an implementation of Guido's method in his own devised language called MUSIMAT but I wanted to see if I could do the same in Python. So here it is:

import random

guidoPitches = [                        'G3', 'A3', 'B3',
                'C4', 'D4', 'E4', 'F4', 'G4', 'A4', 'B4',
                'C5', 'D5', 'E5', 'F5', 'G5']
vmap = {'a':0, 'e':1, 'i':2, 'o':3, 'u':4}

def guido(gtxt):
    for c in gtxt.lower():
        if c in vmap.keys():
    return G

guido('Ut queant laxis resonare.')

No comments: