First, follow the instructions here to install a Python MIDI package.
For an example of how to work with the midi library, try running python example.py
then open example.mid
to hear the output.
For an example of the CSP counterpoint application, try running python main.py
then open solution.mid
to hear the output.