Friday, April 10, 2009

PC audio hardware

The idea has occasionally wandered across my mind (leaving a messy trail) that the audio outputs of a modern PC should be capable of generating fairly high quality audio test signals, and further that if the PC audio inputs are up to scratch they could be used to digitise the results of stuffing these test signals through external equipment-under-test, so that with a bit of signal processing jiggery-pokery the PC should be capable of quickly providing THD readings, frequency response curves (for RIAA networks and the like) and so on and so forth, basically the sort of things I used to do (albeit crudely) in the seventies with test gear that cost monopoly money (to build, that is, couldn't just buy it. Or would have cost the earth if I'd had any money. I was making it up as I went along with bits and pieces I managed to beg, borrow or, um, liberate).

This is hardly original, I hear you think. "Well, it was when I first did it" I respond grumpily, "analysing audio output stages using boxcar sampling thirty years ago. All my own ideas, too. Were you even born? Huh?" And other suchlike grumping sounds that an olde dinosaur makes when challenged. Where was I? Oh, yes...

In fact, aside from electrical noise (hard to avoid inside a PC) I'd have thought that a modern audio DAC/ADC combination from even the cheap end of the PC market would comprehensively outperform the hardware I was using back then. Hah! Foolish crem...

So, tonight while I'm feeling a little under the weather (man flu setting off an opportunistic dental abscess) I decide to have a play with this idea rather than doing anything particularly demanding. A few minutes in Delphi generating an accurate sinewave (no - I'm not slowing down - you can generate an inaccurate sinewave in seconds, but doing it properly requires it to be generated with correct dithering (TPDF) applied to the fractional bits that would otherwise be truncated, and that needs a little thought) and lo - I'm sat here listening to a 1KHz sinewave. Sounds nice enough and everything's looking good for a quick and dirty THD test set until I look at the waveform on t'scope.

(A special hell is reserved for anyone even thinking about questioning the triangular dither. If you think it could be better using a shaped function then you need to brush up on dithering - shaped functions are only suitable for final output - you really don't want to skew the noise frequency distribution going in to the gear under test. Running error accumulation instead of dither? Just don't. Tie the dither generation into the ADC with synchronous correction in the readback? Good thinking but not with unknown systems inbetween... Besides, it's not always a sinewave and I'd hardly tell you what I'm intending to do with this eventually, would I? triangular it is then. Good...)

Now, I admit I was expecting a reasonably clean looking sinewave. Dumb, but I admit it. Oh, crem-the-eternal-pessimist was expecting noise, and hum, and mush of various kinds, but with a smooth sinewave hiding underneath it all none the less. A sinewave lurking behind the sort of noise and mush that will average out give enough signal processing, is the point. Hah! Idiot. I'm not feeling well, that's my excuse.

Here it is:

Magnified (x2.5 post sampling):

Well, it's a sinewave, I suppose, but at first sight it looks like a sinewave generated using a raw 8-bit DAC. Very reminiscent of the stepped waveforms I'd expect from a cheap embedded design that didn't care much, not a supposed high quality (hah) DAC system.

So, does this motherboard, which claimed good audio qualities, use short DACs? A moment of experimentation and it becomes clear - it's not a short DAC but the cheapskate designers of the motherboard haven't applied any analogue reconstruction filter to the output... Nada. Zip. Not even a token RC filter...

Same again, but at 10KHz:

I suppose we should be thankful that they've at least upsampled the digital data to 96KHz, so at least most of the shit they're throwing out is well outside the audio band. Mind you, I bet they did that so they can cut back on the DAC length/ADC input filters and then just didn't bother to fit either. Gah...

Oh, I know, I could always use off-board audio hardware but that's not the point; if this is the normal sort of performance the idea's useless. Gah.

My laptop does rather better, clean looking sinewaves at 1KHz and 10KHz, so filtered at least, though that might be just the headphone driver not keeping up with the edges ;)

[that lot was edited into some degree of coherence after some sleep]

Maybe I was being too picky anyway. Even for simple tests I'd probably use the stereo outputs to generate antiphase signals and then use a differential amplifier to get rid of as much common mode noise as possible, so it's no great bother to put a quick and dirty reconstruction filter in/in front of that stage... I wonder if it's worth doing the same sort of thing going back in; turn the signal into a differential pair for the stereo inputs and subtract them in software? Have to think about that, doubt it'd do that much good. Hmm...


  1. Well, I now at least understand what is happening - these DACs don't have reconstruction filters not because the motherboard manufacturer couldn't be bothered, but because they're no longer considered necessary to meet the required standards.

    "Ah, well, never mind, quite a lot of stuff will cope" seems to be the attitude. Ho hum.

  2. [aside] I got into a rather unexpected disagreement about this when I mentioned it in an electronics conference, where some engineers I have time for disagreed with my revulsion for the practice of outputting unreconstructed audio waveforms... It was an interesting experience - it reminded me that it's possible to know a great deal about electronics but actually not have any 'feel' for the subject at all. Depressing experience...