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):
G=[]
for c in gtxt.lower():
if c in vmap.keys():
G.append(guidoPitches[(len(vmap.keys())*random.choice([0,1,2]))+vmap[c]])
return G
guido('Ut queant laxis resonare.')
No comments:
Post a Comment