A peak-valley detector of an analog signal which provides a digital output of the analog signal. A digital counter is used having an output coupled to a digital-to-analog convertor. The output of the digital-to-analog convertor is compared to an input analog signal. The output of the comparator is used to control the input of a clock signal to the counter. A selective invertor controls whether the comparator's output allows counting for signals above or below the digital-to-analog convertor's output level.