new code to generate spectrogram & time domain plot