Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 2 1 2 LastLast
Results 1 to 25 of 42

Thread: Audio library, I2S DAC oversampling?

  1. #1
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    533

    Audio library, I2S DAC oversampling?

    Just checking here if these measured numbers are as expected:

    Code:
    Teensy 3.2,    PCM5102A, LRCK =  44.1 kHz, BCK = 2.8224 MHz [64.LRCK], MCLK = 11.29 MHz, "AudioOutputI2S           i2s1;"
    Teensy 3.2,    UDA1334,  LRCK =  44.1 kHz, BCK = 2.8224 MHz [64.LRCK], MCLK = 11.29 MHz, "AudioOutputI2S           i2s1;"
    Teensy 3.2,    PT8211,   LRCK = 176.4 kHz, BCK = 5.6469 MHz [32.LRCK], MCLK = 11.29 MHz, "AudioOutputPT8211        pt8211_1;"
    
    Teensy 4.0,    PCM5102A, LRCK =  44.1 kHz, BCK = 2.8224 MHz [64.LRCK], MCLK = 11.29 MHz, "AudioOutputI2S           i2s1;"
    Teensy 4.0,    UDA1334,  LRCK =  44.1 kHz, BCK = 2.8224 MHz [64.LRCK], MCLK = 11.29 MHz, "AudioOutputI2S           i2s1;"
    Teensy 4.0,    PT8211,   LRCK = 176.4 kHz, BCK = 5.6469 MHz [32.LRCK], no MCLK,          "AudioOutputPT8211        pt8211_1;"
    Using FrankB's recently updated code for Teensy LC:

    Code:
    Teensy LC,    PCM5102A,  LRCK = 44.1 kHz,  BCK = 1.4117 MHz [32.LRCK], no MCLK, "AudioOutputI2S           i2s1;"
    Teensy LC,    UDA1334,   LRCK = 44.1 kHz,  BCK = 1.4117 MHz [32.LRCK], no MCLK, "AudioOutputI2S           i2s1;"
    Teensy LC,    PT8211,    LRCK = 44.1 kHz,  BCK = 1.4117 MHz [32.LRCK], no MCLK, "AudioOutputPT8211        pt8211_1;"

    So only the PT8211 is doing 4x oversampling with a Teensy 3.2/4.0?
    And is it correct that PT8211 and T4.0 does not have MCLK?

    Using Arduino 1.8.13, Teensyduino 1.53, modified output_i2s & output_pt8211 to support TLC.

    Thanks,
    Paul

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,103
    Yup, that looks right.

    Not sure why we're turning on MCLK with PT8211 on Teensy 3.2. Maybe just leftover code from I2S?

  3. #3
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    8,282
    Yup, left over code.

  4. #4
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    533
    Allright, thanks for the confirmation.

    Paul

  5. #5
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    8,282
    Not sure if we should disable it, now..

  6. #6
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    8,282
    RE: Oversampling: I see no reason why it should not work with other Chips, too.
    But it would need even more switches or output-objects... so ... maybe it's better to just keep it simple?!?

    If we want to clean these things - well the whole PT8211 code can be integrated into the I2S code.
    The PT8211 has one single flag different ("Frame sync early").

    But then we need *simple* way to switch it on or off. Same for oversampling with other chips.The SGTL can handle it, too.

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,103
    Many of the I2S DACs do this oversampling in their hardware.

  8. #8
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    533
    For simplicity, I wouldn't mind standardizing on LRCK = 44.1 kHz, BCK = 1.4117 MHz [32.LRCK] and MCLK = 11.29 MHz for all I2S DAC's [but maybe this is too short-sighted].
    I checked on the scope what the output spectra are for the different LRCK's/BCK's for the PT8211 and the PCM5102. Output signal 1kHz sine.

    PT8211, Teensy 3.2, LRCK: 176.4, BCK: 32*LRCK:
    Click image for larger version. 

Name:	SDS00020.png 
Views:	30 
Size:	20.3 KB 
ID:	23342

    PT8211, Teensy LC, LRCK: 44.1, BCK: 32*LRCK:
    Click image for larger version. 

Name:	SDS00021.png 
Views:	22 
Size:	20.6 KB 
ID:	23343

    PCM5102, Teensy 3.2, LRCK: 44.1, BCK: 64*LRCK:
    Click image for larger version. 

Name:	SDS00023.png 
Views:	24 
Size:	20.2 KB 
ID:	23344

    PCM5102, Teensy LC, LRCK: 44.1, BCK: 32*LRCK:
    Click image for larger version. 

Name:	SDS00022.png 
Views:	22 
Size:	20.2 KB 
ID:	23345

    The PT8211 seems to have some advantage of the 4x oversampling, but it's minor.
    The PCM5102 does have 8x internal oversampling at LRCK 44.1 kHz [TI calls it 8x interpolation filter]. The UDA1334 also has an internal interpolation filter. The PT8211 does not. I'm not sure about the SGTL5000.

    Is there an advantage of 64*LRCK versus 32*LRCK?

    By the way, don't rely too much on the absolute figures of the above FFT's. My rather cheap Siglent scope is known to be not very accurate for FFT's due to the non-linearity of the internal amplifiers, as admitted by Siglent in an email conversation I had with them [but hey, for the money it's doing pretty well].

    Regards,
    Paul

  9. #9
    Quote Originally Posted by PaulStoffregen View Post
    Many of the I2S DACs do this oversampling in their hardware.
    I would actually say that pretty much ALL current high quality sigma-delta audio DACs have oversampling built-in with multistage decimator and FIR filters that have quality way above what is offered by library and zero computational overhead from uC side.
    I don't see any reason to use oversampling except PT8211 that simply has no reconstruction filters at all. By the way in my measurements PT8211
    output is actually much worse than Teensy 4's MQS (Medium Quality Sound) with regards to distortion and S/N ratio.

    I don't know but to me it seems like your Siglent scope is super noisy / non-linear or you are overdriving it (suggested by harmonics in the spectrum). On my end PCM5102 is super quiet (S/N+D > 98dB)

  10. #10
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    533
    I don't know but to me it seems like your Siglent scope is super noisy / non-linear or you are overdriving it (suggested by harmonics in the spectrum). On my end PCM5102 is super quiet (S/N+D > 98dB)
    Yes, my Siglent 1202X-E has issues in that area. That's what I emailed them about.
    I'm expecting that when I keep the signal within screen limits, I'm not overdriving it. But the pictures below tell a different story... The user manual does not mention anything about vertical sensitivity related to FFT.
    Here are 2 sets of screenshots at 1V/div and 2V/div vertically.

    At 1V/div:
    Click image for larger version. 

Name:	SDS00033.png 
Views:	22 
Size:	53.6 KB 
ID:	23378 Click image for larger version. 

Name:	SDS00032.png 
Views:	19 
Size:	20.1 KB 
ID:	23379

    At 2V/div:
    Click image for larger version. 

Name:	SDS00031.png 
Views:	19 
Size:	39.1 KB 
ID:	23380 Click image for larger version. 

Name:	SDS00030.png 
Views:	21 
Size:	19.9 KB 
ID:	23381

    Just curious: what kind of scope/spectrum analyzer are you using at your end?

    Paul

  11. #11
    I am using studio grade ADC AK5394A (123dB SNR/ 123dB DR) with Visual Analyser. With regards to your results, your power supply may be the culprit too. Disconnect USB and try running from some high quality low noise power supply or batteries. USB power is noisy.

  12. #12
    Senior Member
    Join Date
    Jul 2020
    Posts
    980
    Most 'scope front-ends aren't linear enough for any kind of audio quality measurement work! They are designed for a large bandwidth with constant group-delay,
    and are typically 8-bit so only have 50dB of dynamic range to start with. 100dB is more like the dynamic range you need, as well as low distortion front-end.

    FFT (aka dynamic signal) analyzers are the tool designed for the job. Good soundcards can act as a substitute for some measurements, but typically
    aren't calibrated.

  13. #13
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    533
    Quote Originally Posted by MarkT View Post
    Good soundcards can act as a substitute for some measurements, but typically aren't calibrated.
    Yes, using a Scarlett 2i2 USB audio interface, sampling at 24 bit/96 kHz and the data fed into TrueRTA, shows more realistic values than the scope:

    Click image for larger version. 

Name:	TrueRTA.jpg 
Views:	40 
Size:	131.7 KB 
ID:	23400

    Sure, not calibrated though...

    Paul

  14. #14
    Now do the same with PT8211 and you will see how bad it really is. I would say it is no better than '80s compact cassette.

  15. #15
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    533
    Quote Originally Posted by tomas View Post
    Now do the same with PT8211
    Here you go:

    Click image for larger version. 

Name:	TrueRTA_PT8211_1kHz.jpg 
Views:	37 
Size:	131.0 KB 
ID:	23403

    and you will see how bad it really is
    Yep.

    Paul

  16. #16
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    533
    And for completeness, here is the output of the Adafruit UDA1334-based board:

    Click image for larger version. 

Name:	TrueRTA_UDA1334_1kHz.jpg 
Views:	32 
Size:	128.8 KB 
ID:	23404

    Almost as good as a PCM5102A-based board.

    Paul

  17. #17
    Exactly, noise floor approx -58dB that is less than 10 bits. Good cassette decks in '80s were able to get >70dB.

  18. #18
    Senior Member
    Join Date
    Jul 2020
    Posts
    980
    Let me say it again, FFT plots of signal spectrum are not useful for measuring noise floor, you need a PSD plot for that.
    Noise is measured in W/Hz, or V/√Hz, and an FFT bin is typically not exactly 1Hz wide...

  19. #19
    SNR is measured in dB. And it was observation / comment / remark (hence "approx" word), not measurement. PT8211 is so bad, not only with regards to noise but mainly to distortion that I wonder why would anyone use it. Teensy 4 MQS output is actually better, esp with regards to distortion and has zero cost (OK, except one resistor and one capacitor, because as I can see someone is into nitpicking). I2S sigma delta DACs are cheap and there is no reason to use R2R register ladder PT8211 that has no reconstruction filter, big problems with nonlinearity and noise. R2R dacs are good for upto 8 bits.
    Last edited by tomas; 01-23-2021 at 04:42 PM.

  20. #20
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    533
    In case anyone is interested, here is a readable paper on the difference between PSD (power spectral density) and FFT, and why FFT is not suitable for noise floor measurements.

    Paul
    Last edited by PaulS; 01-23-2021 at 08:58 PM.

  21. #21
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    654
    @Paul: your link is broken and seems to produce SPAM !?

  22. #22
    Senior Member
    Join Date
    Jul 2020
    Posts
    980
    This is the correct link, https://www.ap.com/blog/fft-spectrum...erent-scaling/

    The basic insight is that a discrete spectrum is measured differently from a continuous spectrum since measurement bandwidth matters for the latter.

  23. #23
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    654

  24. #24
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    533
    Thanks Frank, corrected the link.

    Paul

  25. #25
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    533
    For completeness, here are the measurements on the SGTL5000/PJRC audio adapter board:

    Click image for larger version. 

Name:	TrueRTA_SGTL5000_1kHz.jpg 
Views:	25 
Size:	129.0 KB 
ID:	23697

    and the TDA1543 [that old, non-A version in an 8DIP packaging]:

    Click image for larger version. 

Name:	TrueRTA_TDA1543_1kHz.jpg 
Views:	16 
Size:	129.8 KB 
ID:	23698

    Disclaimer: these are all non-laboratory measurements so your mileage may vary...

    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •