It is shown that optical synthesis of terahertz and millimeter-wave frequencies can be achieved using two-mode and mode-locked discrete mode diode lasers. These edge-emitting devices incorporate a spatially varying refractive index profile which is designed according to the spectral output desired of the laser. We first demonstrate a device which supports two primary modes simultaneously with high spectral purity. In this case sinusoidal modulation of the optical intensity at terahertz frequencies can be obtained. Cross saturation of the material gain in quantum well lasers prevents simultaneous lasing of two modes with spacings in the millimeter-wave region. We show finally that by mode-locking of devices that are designed to support a minimal set of four primary modes, we obtain a sinusoidal modulation of the optical intensity in this frequency region.