A Class D amp works by taking the analog input signal and creating a PWM (pulse width modulation) replica of it-essentially a train of pulses, which correspond to the amplitude and frequency of the input signal. In its most basic form, a comparator circuit is used to match the input signal with the PWM signal.