Bare-bones code from the Chapter 3 "Algorithmic composition: swarm music" from "Sound and music" by T. Blackwell, M. Grierson, M. Pearce, C. Rhodes and A. Smaill.
Formatted, put into separate files with appropriate names.
You are supposed to follow the book, and to fill the gaps in code where indicated.
The result should look something like this (particles move, music is playing).