SoundHelix is a free, versatile and flexible Java framework for composing and playing algorithmic random music. SoundHelix is an algorithmic random music generator which can play generated songs on MIDI devices in real-time. It can also write the generated songs as MIDI files, e.g., for using or post-processing them in third-party MIDI software.
Here is the setup on a win7 machine.
Edit the example to use also different midi outputs via LoopMidi or/and midi file output.
https://www.soundhelix.com/
http://www.tobias-erichsen.de/software/loopmidi.html