Added waveform analysis and beat detection.