Added spectrogram writer function