Algorithm for music composition