I have noticed for some time that the line-in signal from the codec (WM8731) can have some strange noise components. When the input is silent, like when it's left open or shorted to ground, I would have expected the signal to be pretty close to zero and have a flat noise floor when looked at in the frequency domain. I noticed that the noise components can be moved around, and sometimes made to almost disappear, by poking at the audio input in different ways or feeding it different signals. My guess was that there was something non-optimal about the power supply or the I2S clocking. But the weirdness reached a new level when I noticed that a new batch of chips (labelled "58AJMDN") made different noises than the old ones ("56ADMDN"). The old would have a soft band of noise around 2 kHz + harmonics, while the new ones had a sharper noise peak around 1 kHz. This prompted deeper investigations, and furrows upon my forehead.
After doing all the physical/analog things, like exchanging codecs between boards, adding decoupling capacitance and trying different weird clocking and PLL options, I started to go through the datasheet again and toggle configuration bits. There was something that made a clear difference — turning off the automatic high-pass (DC removal) in the ADC made most of the problem disappear. There was quite a large DC offset to be removed in software then, and that offset seems to be internal to the chip somehow.
The picture above is a spectrum captured with Baudline, over USB, of the line-in signal. The measurement was with the line-in connector essentially shorted (there was a pair of headphones connected). The DAC was fed with the incoming signal in the first two cases, then with a generated sine signal in the third case.
- Green — with automatic high-pass in WM8731
- Red — with DC correction in software instead
- Orange — automatic high-pass turned off, playing 1500 and 2000 Hz sine tones with DAC
All of those have some noise where it shouldn't be, but it's centred around different frequencies. The peaks at around 1050 Hz, with harmonics, can be audible and annoying at very low levels. Whiteish noise at the same low level isn't really audible, or at least it's very much easier to not care about. And a bit of crosstalk between output and input in an integrated codec chip is also pretty easy to forgive.
Everything I change gives slightly different weird results. Disabling the DAC and muting the DAC generates some artefacts. Letting the DAC output a constant DC signal of 100 (S16 samples) yields a pretty nice and flat noise floor from the ADC, but there are still some strange spikes here and there.