A "switching" power supply (like virtually all modern computer power supplies) works by "rectifying" the incoming 120V 60Hz (in the US) AC power into DC (at around 170 volts), "filtering" with capacitors, then using a semiconductor circuit to "chop" the DC voltage around 1000 times a second to turn it back into crude AC. (What's referred to as a "square wave", vs the "sine wave" of ordinary AC.) This "chopped" voltage then runs through a transformer to produce the desired output voltages. The outputs are again rectified to DC and filtered, to produce the desired voltages for the computer.
With this scheme, basic voltage regulation is performed by adjusting the "duty cycle" of the chopped voltage. When the power supply is lightly loaded the circuitry doesn't produce a nice symmetrical "square wave" but instead a series of narrow spikes, and that "spikey" waveform is more likely to produce annoying audible noise in the transformers and other components and is also more likely to produce "electrical noise" that you would, eg, hear in a nearby radio.
Additionally, when a power supply is lightly loaded more of the magnetic field inside a transformer escapes to the case of the transformer and to surrounding components (since less is captured by the "secondary" coil of the transformer), and this "escaping" magnetic field is more apt to cause noise.
It sounds some of these chargers are just cheap, the noise, means their output isn't "clean" – Ramhound – 2014-10-27T20:41:40.123
1https://en.wikipedia.org/wiki/Magnetostriction, https://en.wikipedia.org/wiki/Coil_noise (I'll be writing a full answer shortly) – bwDraco – 2014-10-27T20:59:53.087
I have a AA battery charger I bought from SparkFun. It makes this very low—but perceptible—buzzing noise that drives me nuts. Not sure what causes that but I do know I just use it as a backup charger now since the noise is quite distracting. https://www.sparkfun.com/products/retired/10052
– JakeGould – 2014-10-27T21:12:16.897I've edited the question to expand the scope to computer power supplies to ensure that it is on topic for Super User. – bwDraco – 2014-10-27T21:49:30.480
This question has been asked many times before. Most recent in memory is here.
– Jason – 2014-10-27T23:22:51.957The whine is usually because the minimum amount of electrical current is not being drawn from the (switched mode) power supply. When "plugged in but not connected to a device", zero current (and power) is drawn from the AC adapter simply because there is no load attached to the power supply. Switched mode power supplies do not operate efficiently with small or no electrical loads. See other comments & answers for the mechanical details. – sawdust – 2014-10-28T01:08:52.947
3@Ramhound Audible noise from a power supply does not imply noise in the electrical output. – nobody – 2014-10-28T03:40:45.150
@AndrewMedico I have a different personal experience; – Ramhound – 2014-10-28T10:20:56.287
@Jason: I'm making this the canonical question. I've voted to close as duplicate on the question you've linked to and tagged this question [community-faq-proposed]. – bwDraco – 2014-10-28T11:39:23.967
@DragonLord I appreciate that, but this is a poor question to pick. AC adapters for "gadgets" aren't computer hardware, which makes this off-topic. – Jason – 2014-10-28T15:46:51.930
@Jason: I've rewritten the post to further broaden the topic area and give equal weight to computer power supplies. – bwDraco – 2014-10-28T16:06:19.740
@DragonLord If this is to be canonical, can we totally hijack the question? High frequency noise in computers caused by vibrating coils is just as commonly caused by motherboards and video cards. – Jason – 2014-10-28T16:19:37.757
When I first got my desktop it had this problem (actually I asked about it here). I found after time it went away by itself. Also it was normally only audible when the computer was first powered on or powered off. It was damn annoying, as the pitch varried.
– Celeritas – 2014-10-30T02:56:29.717