Imported code from Brain on Music. Still need to sort through what I
need.