Old code for waveform manipulations