Refactor of generate waveform (crashing on larger mp3)