Apple is close to buying the music recognition app Shazam for about $400m (£300m), media reports say.