Real-time music analysis and generation of harmonic accompaniment