Move waveform generation away from main