Optical waveform synthesizer and its application to high-harmonic generation