Jeroen's Project Journals

  • DSP/DAC

  • A 4-channel USB DAC built around a pair of TI PCM5102A's with advanced DSP capabilities provided by a Teensy 4.0. Includes a 3D printed enclosure, OLED display and rotary click-encoder control

  • Gallery

Bit-depth and volume control (a bit of a rant, I'm afraid)

2023-12-17

While both the processor on the Teensy and the external DAC chips are 32-bit capable, I belatedly discovered the Teensy Audio Library is entirely 16-bit. This is quite unfortunate, as this has implications for the final sound quality. Here’s the problem: The Teensy registers as a 16-bit capable USB sound device, and outputs 16-bit data over I2S to the DACs. For maximum sound quality we want to utilize the full 16-bit range, as this results in the most accurate analog waveforms. However, the DACs have a 2.1 Vrms line-level output, which is very high. This line-level signal is amplified by a power-amp before it can drive the speakers. A power-amp has a fixed gain, for example 20, 30 or 40 dB, which corresponds to 10, 32 or 100 times the input voltage. But even a modest gain of 20 dB would turn the 2.1 Vrms signal of the DACs into a speaker-destroying, ear-splitting amplified signal, so we need to have some form of volume control. This is done by adding attenuation (the opposite of amplification) somewhere in this chain. We can do this digitally on the host PC or Teensy or analog(ly?) on the line-level signal. Attenuating the speaker-level signal would produce large amounts of heat, so that’s not an option.

Digital volume control reduces the bit-depth, because in order to reduce the peak-peak voltage of the output signal we need to feed the DAC with smaller numbers (= fewer bits). If our digital processing is done using 24- or 32-bits this is not a problem since most source-material (including CD-quality) is 16-bit. A 16-bit signal can be attenuated by -48dB (for 24-bit DSP) or -96dB (for 32-bit DSP) without loosing any information/sound-quality. Unfortunately at this point we don’t have that luxury with the Teensy. It receives, processes and outputs audio data fully in 16-bits, so attenuating the signal by e.g. -18 dB (1/8th gain) already reduces the bit-depth from 16 to 13.

That leaves us with analog volume control. In practice, this means running the line-level signal through a voltage divider, typically a logarithmic potentiometer with 2 or more stacked together for multi-channel volume control. Unfortunately anything you do with an anlog signal introduces some amount of noise, which gets amplified and therefore impacts sound-quality.

All of the above is partly specific to my situation. I purchased 3 cheap mono amplifiers without understanding any of this, and it turns out they are hardwired with a 36 dB gain. This would turn the 2.1 Vrms signal into a monstrous 132 Vrms speaker signal if the amps were capable of producing that. In practice, of course, they are limited by their supply voltage and start clipping the signal long before that. But in my case this means the signal needs attenuation by -16 dB just to prevent the amps from clipping. And even then the speaker-level signal is way too loud to be usable. So I’m still debating what to do with this. I might try to modify the mono-amps to a lower gain, and I’m also looking into ways to do the DSP in 32 bits. I’ll probably needto do both, I suspect.