Measuring peak values or amplitude or envelope of ac or of pulses