Hi,
For what is worth, I've released the source of a generative piece made some months ago.
It needs ZynAddSubFx (http://zynaddsubfx.sourceforge.net/) for the actual output sound. If you're on linux you can use jack to route the midi messages from pd to zyn. Just use a big buffer size for jackd to alleviate the cpu load.
http://www.cesaremarilungo.com/music/zen_mind.php
Temporary licence: just be kind.
www.cesaremarilungo.com