A controller (150, 350, 402) adapted to be used in an ac-to-dc power converter, the controller comprising: an oscillator configured to generate a clock signal having a frequency; a drive circuit configured to receive the clock signal and to generate a drive signal in response thereto, the drive signal being used to control switching of a switch (141, 341, 450) of the power converter so as to control a transfer of energy across an energy transfer element from an input (Vin, 130, 315, 410, 621) of the power converter to an output (V O) of the power converter, wherein a switching frequency of the drive signal is based on the frequency of the clock signal and is much greater than a frequency of a time-varying inductor voltage (Vind) across an inductor of the energy transfer element; an input voltage block configured to receive a first signal representative of an instantaneous value of an input voltage provided to the input (Vin, 130, 315, 410, 621) of the power converter and to generate a second signal representative of the magnitude of the time-varying inductor voltage in response thereto; characterized in that the controller includes a frequency modulator adapted to receive the second signal, the frequency modulator being coupled to the oscillator and configured to control the frequency of the clock signal during each a.c. power line half cycle of the time-varying inductor voltage in response to a magnitude of the time-varying inductor voltage in order to reduce a peak-to-peak ripple value in an output current of the power converter that is due to the lower frequency time variations in the inductor voltage, wherein the frequency modulator is configured to control the frequency of the clock signal during each a.c. power line half cycle to be a fixed frequency when the magnitude of the inductor voltage is less than or equal to a threshold voltage, and wherein the frequency modulator is configured to vary the frequency of the clock signal during each a.c. power line half cycle to be less than the fixed frequency to adjust a shape of an input current of the power converter when the magnitude of the inductor voltage is greater than the threshold voltage. an oscillator configured to generate a clock signal having a frequency; a drive circuit configured to receive the clock signal and to generate a drive signal in response thereto, the drive signal being used to control switching of a switch (141, 341, 450) of the power converter so as to control a transfer of energy across an energy transfer element from an input (Vin, 130, 315, 410, 621) of the power converter to an output (V O) of the power converter, wherein a switching frequency of the drive signal is based on the frequency of the clock signal and is much greater than a frequency of a time-varying inductor voltage (Vind) across an inductor of the energy transfer element; an input voltage block configured to receive a first signal representative of an instantaneous value of an input voltage provided to the input (Vin, 130, 315, 410, 621) of the power converter and to generate a second signal representative of the magnitude of the time-varying inductor voltage in response thereto; characterized in that the controller includes a frequency modulator adapted to receive the second signal, the frequency modulator being coupled to the oscillator and configured to control the frequency of the clock signal during each a.c. power line half cycle of the time-varying inductor voltage in response to a magnitude of the time-varying inductor voltage in order to reduce a peak-to-peak ripple value in an output current of the power converter that is due to the lower frequency time variations in the inductor voltage, wherein the frequency modulator is configured to control the frequency of the clock signal during each a.c. power line half cycle to be a fixed frequency when the magnitude of the inductor voltage is less than or equal to a threshold voltage, and wherein the frequency modulator is configured to vary the frequency of the clock signal during each a.c. power line half cycle to be less than the fixed frequency to adjust a shape of an input current of the power converter when the magnitude of the inductor voltage is greater than the threshold voltage.