From a previous snippet, you can play any sound file
(including midi) with pys60.
http://bigbold.com/snippets/posts/show/400
Now, what if you can generate a midi file as well?
I found a pure python midi file library.
http://www.mxm.dk/products/public/pythonmidi
I modify it a bit, just to make a single file for easy download.
http://larndham.net/service/pys60/smidi.py
With it, you can play a single note with the following code.
1
2 >>> import smidi
3 >>> m = smidi.MidiOutFile('C:\\out.mid')
4 >>> m.header()
5 >>> m.start_of_track()
6 >>> m.update_time(0)
7 >>> m.note_on(note=0x40)
8 >>> m.update_time(192)
9 >>> m.note_off(note=0x40)
10 >>> m.update_time(0)
11 >>> m.end_of_track()
12 >>> m.eof()
13
14 >>> from audio import Sound
15 >>> s = Sound.open('C:\\out.mid')
16 >>> s.play()
17 >>> s.close()
These 10 lines can be made into a simple function.
Then, you can just type a line and play any note you like
on you mobile phone.
1
2 >>> from smidi import play
3 >>> play([(64,192), (32, 192)])
Ah... so pythonic. ^_^