PCM5102 DAC, can the Audio System Design Tool output 32 bit over I2S?

Status
Not open for further replies.

PaulS

Well-known member
Been playing with a sub-$10 PCM5102 DAC board and it works well using the Audio System Design Tool.

PCM5102 DAC board.jpg

With this minimal code I was able to output a decent sinewave:
Code:
// PCM5102 bd   Teensy
// VCC          Vin [5V]
// GND          GND
// LRCK         23
// DIN          22
// BCK          9

#include <Audio.h>

AudioSynthWaveformSine   sine1;
AudioOutputI2S           i2s1;
AudioConnection          patchCord1(sine1, 0, i2s1, 0);
AudioConnection          patchCord2(sine1, 0, i2s1, 1);

void setup()
{
  AudioMemory(4);
  AudioNoInterrupts();
  sine1.frequency(5000);
  sine1.amplitude(1.0);
  AudioInterrupts();
}

void loop()
{
}

Since this DAC can also handle 24 or 32 bit data, I was wondering whether I could use the AudioSynthWaveformSineHires object to output its 32bit data over I2S.
However the description of the AudioOutputI2S object clearly states "Transmit 16 bit stereo audio", so I guess it's not possible?

What would I need to do to make this happen? Rewrite output_i2s.cpp ?

Thanks,
Paul
 
Since this DAC can also handle 24 or 32 bit data

Since the A-weighted SNR is 112 dB, the best case scenario is about 18.7 bits of actual analog performance.

Sadly, TI doesn't give an unweighted spec, so it's really a matter of guesswork how much the A weighting is "helping" the spec to look better.

We've covered this over and over on other threads. There are no audio DACs where you truly get an analog signal with noise floor (not to mention distortion) slow low that more than about 19 bits really matters. Those very best chips tend to be quite expensive and power hungry.

No audio DACs reproduce an analog signal which truly representing 24 bits of resolution.

Maybe someday we'll support more than 16 bits in the software. But don't expect much, unless you're really into placebo effects. Analog circuitry in these chips simply isn't a whole lot better than 16 bits.
 
@ Frank,
Thanks for the confirmation. I was just curious how to use the lower 16 bits of the AudioSynthWaveformSineHires object.

@ Paul,
Yes, I have read the threads you mention. Personally I'm really doubting the audibility of 24 bit versus 16 bit.
In my opinion, the reason why 24 bit recordings in general seem to sound better than 16 bit recordings is because way more attention has been put into the recording process itself, not because of the extra 8 bits.
Using audio editors I decimated a number of 24 bit recordings to 16 bit. I could not hear a difference on my supposed-to-be-24 bit-DAC but the recordings still sound great!

Regards,
Paul
 
16 Bits are 65536 values. The human eye for example can see around 130 different values of gray (for colors even less)..that"s 7 bit.. :)

I remember a test in a HIFI Magazine, very long time ago.. when CD Players where new. There was a blind test, and most tested "audiophile" people were not able to say if a they heard a Vinyl or CD. Vinyl is way below 16Bit.
 
I was just curious how to use the lower 16 bits of the AudioSynthWaveformSineHires object.

Today there really isn't any way to use those bits.

That sine code was pretty much just a math experiment, back when William Hollender was working on a board with the CS4272 chip. Sometimes I do stuff like that... pour a couple all-nighters into something that's interesting & a technical challenge, even if it's not really useful or commercially important for PJRC (one of the many ways PJRC is so different from far more financially successful companies like Adafruit & Sparkfun). Fiddling with the Taylor series approximation and optimizing it with the DSP extensions would be a prime example.

At some point in the (likely distant) future we may overhaul the library to support 24 bits (using floats - where the main benefit will be easier implementation of certain filters - and satisfy the 24 bit placebo effect so many people want), but certainly not until Teensy 4 is released and a ton of more important stuff is done first, including some major work to update the website.
 
Last edited:
Basically, the human ear can (in the best case) perceive dynamics of ~120dB which means that true 20 or 21 bit would be sufficient to cover everything.
Using a higher resolution (24bit or 32bit) during digital signal processing might make sense, though, since it gives the needed headroom, i.e. for compressing or expanding dynamics, or just to be a little more lenient about losing 1 or 2 LSBs during mathematical operations. Remember, multiplying 2 q1.31 numbers gives a q2.30 result in the upper word which means that you lost already 6dB for a single multiply if you don’t want to eat up additional CPU cycles to recover the lost bit from the lower word.
When it comes to converting everything back to analog, I fully support Paul’s statement above. More bits in the DAC’s spec sheet do not forcibly lead to a better result at ear level, especially since (for the sake of production costs and reduced peripheral components) most DACs, and the PCM5102 is not an exception, do internal over sampling and further digital signal processing (probably sacrificing a few more of the input bits, see above) to feed a simple 1bit delta-sigma converter (much cheaper than a laser trimmed R ladder network for true 16bit resolution and saving on the external reconstruction filter, which would normally be a Bessel filter with at least 3 capacitors and 2 inductors) at the end. The S/N ratio might be impressive when A-weighted over the audible range but might show ugly things above, which translates in intermodulation and a THD level of only around -93dB which means that... yes, we are even worse than 16 bit here!
 
There are a couple of folks who have gotten 32-bit transfers through the I2S and DMA subsystems. I did 32-bit transfer for the TI AIC3206 along as part of my Tympan project. See the I2S classes in the src directory:

https://github.com/Tympan/Tympan_Library

My main goal with this repo was to extend the Teensy Audio framework so that the core data type was 32bit float instead of 16 bit ints. As part of that extension, I also jumped to 32-bit I2S transfers.

If you do choose to do it for your DAC, you need to do both the I2S/DMA mods (like I did) *and* you need to make changes to your dac configuration code to tell it to run in 32bit mode.

Chip
 
Status
Not open for further replies.
Back
Top