Any idea why I'm seeing a difference in the audio quality between the Audio Adaptor Board and the PT8211 Audio Kit?

brispo

Active member
I recently picked up a Teensy 4.0, The Audio Adaptor Board, and the PT8211 Audio Kit for my drum project.

I converted a .wav kick drum sample to .cpp and .h using wav2sketch. I've managed to get both the Audio Adaptor Board and the PT8211 Audio kit working, but I've noticed that the PT8211 has substantially more noise than when the exact same .cpp/.h sound is played through the Audio Adaptor Board. Any idea why this might be?

These are recordings made directly off of each audio shield with a Zoom H2. The difference is pretty noticeable to me.

PT8211 Kick
Audio Adaptor Board Kick
 
These are recordings made directly off of each audio shield with a Zoom H2. The difference is pretty noticeable to me.
Agree, the noise is indeed clearly noticable at the PT8211 recording. The PT8211 DAC is definitely not the best in class but I don't recall it to be this bad.
Would you mind sharing the original .wav kick drum sample so that I can try to reproduce the setups here as well?

Paul
 
Sounds like anti-aliasing is missing when the PT8211 is employed - the SGTL5000 will have an internal antialiasing filter, but as I understand it the PT8211 is a simple DAC with first-order hold only. Any chance of sharing the raw wav file?
 
Sure here's the original .wav file:

kick10.wav

I've been using the wav2sketch tool to convert .wav files like this to .cpp and .h, though I did notice an error when trying to compile (I use PlatformIO on VScode, mainly for Git integration).

I did have a few issues with the compiled .cpp files. Mainly, I got an error around the PROGMEM on line 6: "this declaration has no storage class or type specifier"

What I did to resolve this issue was to add "#include <Arduino.h>" to the top of the .cpp file, and remove the line break after PROGMEM so that line 6 became: "PROGMEM const unsigned int AudioSamp..."

I doubt this is the issue though, as I used the exact came .cpp and .h files for both recordings from my original post, just played them through different audio shields. Just thought it was worth mentioning though.
 
Hmm, nothing obvious in the upper part of the spectrum, doesn't really suggest anti-aliasing issue. Perhaps the PT8211 is getting distorted digital data somehow?
 
Hmm could it be my soldering? I feel like I'm fairly handy with an iron, but maybe I should inspect/reflow my joints? Any particular pins I should focus my attention on?
 

Attachments

  • PXL_20241027_213032673.MP~2.jpg
    PXL_20241027_213032673.MP~2.jpg
    239.1 KB · Views: 31
Was able to reproduce the issue here as well.
The setup:

IMG_20241028_110704.jpg


Teensy4_AudioSampleLongerkick.ino:
C++:
#include <Audio.h>

// WAV files converted to code by wav2sketch
#include "AudioSampleLongerkick.h"

// GUItool: begin automatically generated code
AudioPlayMemory playMem1;
AudioOutputPT8211 pt8211_1;
AudioConnection patchCord1(playMem1, 0, pt8211_1, 0);
AudioConnection patchCord2(playMem1, 0, pt8211_1, 1);
// GUItool: end automatically generated code

void setup() {
  AudioMemory(10);
}

void loop() {
  playMem1.play(AudioSampleLongerkick);
  delay(2000);
}
AudioSampleLongerkick.h:
C++:
// Audio data converted from audio file by wav2sketch_js

extern const unsigned int AudioSampleLongerkick[15617];
AudioSampleLongerkick.cpp:
C++:
// Audio data converted from audio file by wav2sketch_js

#include "AudioSampleLongerkick.h"
#include <Arduino.h>

// Converted from longerkick.wav, using 44100 Hz, 16 bit PCM encoding
PROGMEM
const unsigned int AudioSampleLongerkick[15617] = {
0x81007999,0x00260000,0x00920041,0x05ae021b,0x06c30739,0x044e063a,0x037c034b,0x04b4047d,
0x04a304e0,0x04110473,0x02bb0351,0x031a02d1,0x03d40394,0x04bb0437,0x0529051c,0x0531050e,
0x05fc0587,0x063b061f,0x061d062f,0x06050611,0x06d80636,0x07ae0788,0x0715077b,0x0686069f,
0x0814070b,0x07f80868,0x088807ef,0x09a20940,0x0a3b09f2,0x0b0e0aa5,0x0c5e0b86,0x0e880d56,
0x0ccc0e58,0x0bc60c65,0x0a4d0a42,0x0d470c3a,0x0df60d9b,0x0e330e1b,0x0ef30ec0,0x0e8b0e49,
0x0fbd0f25,0x0f810fc7,0x10a60f2b,0x10cd1202,0x108d0f0b,0x0f7a1161,0x14bb10a3,0x0de412c5,
0x15c01052,0x11cf14a6,0x1ba11645,0x0ff117f1,0x13e70e59,0x18a817fa,0x19a319ca,0x1c171a4e,
0x17fc1ca8,0x0cbf0f4b,0x1be512b5,0x17ac1ed0,0x0c2a0dbc,0x2504169d,0x2b692dc1,0x08521b7b,
0x0844029c,0x25b215b8,0x1a3a2ace,0xfb900289,0x162f063d,0x2b5a2579,0x131f2464,0xfaa80245,
0x04affb51,0x20e213a1,0x27ed27e0,0x1d382338,0x183e19c3,0x0fc61507,0x02b30885,0x0fc7064e,
0x239f19c6,0x21842756,0x09eb1449,0x15fc0baa,0x169f1d53,0xfc7e07dd,0xf77cf6f3,0x10370216,
0x156e1615,0x079b113d,0xfc52fe27,0x0e630323,0x13e815f9,0x00ca098b,0xfd13fe1e,0x013efde6,
0x01ed033f,0xfe26ff40,0xfc38fe43,0xfebafbc2,0xfa87fe73,0xf231f782,0xec71ecf0,0xeabfed17,
0xe9a0e947,0xeb10e9ea,0xefddeca8,0xef5af259,0xe1e6e80a,0xdc54ddb8,0xdd11dc54,0xe163dfdf,
0xdc6fe05e,0xdb39dad5,0xd312d81d,0xd258cf5f,0xd9ffda57,0xc687cf2d,0xc47bc481,0xce7fc8b8,
0xca8dcdf6,0xcd30c9a7,0xcc10cf97,0xc490c7cc,0xbc2dbfa5,0xc080bd0a,0xc1afc246,0xbe61bf4c,

// deleted large part of code

0xffeaffe9,0xffeaffeb,0xffebffea,0xffeaffea,0xffebffeb,0xffecffeb,0xffecffed,0xffeeffed,
0xffeeffee,0xffeeffee,0xffeeffee,0xffefffef,0xffefffee,0xffefffef,0xfff1fff0,0xfff0fff1,
0xfff1fff1,0xfff1fff2,0xfff4fff2,0xfff4fff2,0xfff4fff4,0xfff4fff4,0xfff4fff4,0xfff4fff4,
0xfff5fff4,0xfff5fff6,0xfff6fff6,0xfff6fff6,0xfff7fff7,0xfff8fff8,0xfff8fff8,0xfff8fff8,
0xfff9fff9,0xfffafffa,0xfffbfffa,0xfffbfffa,0xfffbfffb,0xfffcfffc,0xfffdfffc,0xfffefffd,
0xffffffff,0x0000ffff,0x0000ffff,0x00020001,0x00010001,0x00020001,0x00020002,0x00030003,
0x00030003,0x00040003,0x00040004,0x00040005,0x00060005,0x00060005,0x00070007,0x00080008,
0x00090008,0x0008000a,0x000a0009,0x000a000a,0x000a000b,0x000c000b,0x000c000c,0x000c000c,
0x000d000c,0x000e000d,0x000d000e,0x000f000e,0x000e000d,0x000e000e,0x000f000f,0x000f0010,
0x0011000f,0x00110010,0x00100011,0x00120011,0x00110011,0x00120012,0x00130012,0x00130014,
0x00130013,0x00130013,0x00130013,0x00140014,0x00150015,0x00130013,0x00150015,0x00140014,
0x00150014,0x00150015,0x00160016,0x00150015,0x00140014,0x00150015,0x00130015,0x00150013,
0x00150014,0x00150015,0x00140015,0x00160015,0x00160016,0x00160015,0x00150015,0x00150015,
0x00150014,0x00140015,0x00150015,0x00150014,0x00140015,0x00140014,0x00140013,0x00130015,
0x00130013,0x00130013,0x00120013,0x00120012,0x00130012,0x00130012,0x00140013,0x00120012,
0x00120012,0x00110012,0x00120012,0x00110011,0x00100011,0x00120010,0x00110011,0x00100011,
0x00100010,0x00100011,0x0010000f,0x00100010,0x000f000f,0x0010000f,0x000f0010,0x00110010,
0x00100010,0x00100010,0x00100010,0x000f0010,0x0010000f,0x000e000f,0x00100010,0x000e000e,
0x000f000e,0x000f0010,0x000e000f,0x000f000e,0x000e000f,0x000f000e,0x000f000f,0x000d000e,
0x000d000f,0x000e000d,0x000e000f,0x000c000d,0x000c000d,0x000d000c,0x000c000c,0x000c000b,
0x000b000c,0x000a000b,0x000c000b,0x000b000b,0x000b000a,0x000b000b,0x000a000a,0x000a000b,
0x000b000c,0x000b000a,0x00090009,0x00090008,0x00080008,0x0009000a,0x00080009,0x000a0008,
0x00080008,0x00090009,0x00080008,0x00080007,0x00080008,0x00080008,0x00070008,0x00080008,
0x00070007,0x00070006,0x00070008,0x00070007,0x00070008,0x00080006,0x00060007,0x00060006,
0x00060006,0x00060006,0x00060006,0x00040005,0x00050004,0x00050004,0x00050004,0x00040004,
0x00030003,0x00030005,0x00030003,0x00030002,0x00020003,0x00020002,0x00020002,0x00020002,
0x00020002,0x00020002,0x00010002,0x00010001,0x00000002,0x00010000,0xffffffff,0x00000000,
0xfffeffff,0xffffffff,0xfffeffff,0xfffefffe,0xfffeffff,0xfffdfffd,0xfffcfffc,0xfffcfffc,
0xfffefffc,0xfffcfffd,0xfffcfffc,0xfffbfffc,0xfffbfffb,0xfffcfffb,0xfffafffb,0xfffbfffb,
0xfffafffc,0xfffbfffa,0xfffafffa,0xfffafffb,0xfffafffa,0xfff9fff9,0xfff8fff8,0xfff8fff8,
0xfff7fff7,0xfff7fff8,0xfff7fff6,0xfff7fff8,0xfff5fff7,0xfff6fff6,0xfff7fff6,0xfff6fff5,
0xfff6fff5,0xfff5fff5,0xfff4fff5,0xfff4fff4,0xfff4fff5,0xfff4fff3,0xfff3fff3,0xfff2fff3,
0xfff3fff2,0xfff2fff3,0xfff2fff1,0xfff1fff2,0xfff0fff1,0xfff0fff0,0xfff1fff0,0xfff1fff1,
0xfff0fff1,0xfff0fff0,0xffefffef,0xffefffef,0xffefffef,0xffeffff0,0xffedffed,0xffeeffed,
0xffecffed,0xffeeffed,0xffedffed,0xffedffec,0xffedffec,0x0000ffec,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,
};

The noise was again clearly audible.
Tried to capture it from the spectrum analyzer: link, will expire in 2 days.
While the sample is playing, the noise level is substantial. Then it drops to almost zero after the sample.

I have the feeling the PT8211 generates a lot of intermodulation distortion.
Tried also a fading out 440Hz sine signal and the noise is horrible.

Paul
 
Try editing output_pt8211.h at line 40. Does changing the oversampling algorithm or just disabling oversampling have any effect?

Arduino IDE installs the libraries in a hidden folder, so you may need to do something special to find the location. On Windows is within {AppData}/Local/Arduino15. You can turn on verbose output during compile in File > Preferences (or Arduino IDE > Setting if using MacOS), then look at the compiler commands to see the full pathnames.
 
Sure, here is the sketch:
C++:
#include <Audio.h>

// WAV files converted to code by wav2sketch
#include "AudioSampleSine440hz.h"

// GUItool: begin automatically generated code
AudioPlayMemory playMem1;
AudioOutputPT8211 pt8211_1;
AudioConnection patchCord1(playMem1, 0, pt8211_1, 0);
AudioConnection patchCord2(playMem1, 0, pt8211_1, 1);
// GUItool: end automatically generated code

void setup() {
  AudioMemory(10);
}

void loop() {
  playMem1.play(AudioSampleSine440hz);
  delay(6000);
}
Please copy the attached AudioSampleSine440hz.h & .cpp files to the sketchfolder. I added the fading sine wav file as well in the .ZIP.

Paul
 

Attachments

  • FadingSine440Hz.zip
    275.3 KB · Views: 21
To rule out any issue with the wav2sketch procedure, I setup the Teensy 4.0 & PT8211 to act as a USB audio adapter like so:

C++:
#include <Audio.h>

// GUItool: begin automatically generated code
AudioInputUSB usb1;
AudioOutputPT8211 pt8211_1;
AudioConnection patchCord1(usb1, 0, pt8211_1, 0);
AudioConnection patchCord2(usb1, 1, pt8211_1, 1);
// GUItool: end automatically generated code

void setup() {
  AudioMemory(10);
}

void loop() {
}

Then played the original longerkick.wav file on a laptop through that adapter to the same amp & speakers: same DAC noise present during playing the wav file.

Paul
 
Hi, just went on DSP route Hilbert coefficients and having problems understanding the math involved. I see PT8211 is 16 bit R-2R , but according to a simple sampling law, any signal must be sampled at minimum 2 times the highest signal freq. Are you sure the sampling is done at 44000 Hz for CD like quality ? If any good oscilloscope available, inspect DIN, WS and BCK signals while sampling
 
Are you sure the sampling is done at 44000 Hz for CD like quality ? If any good oscilloscope available, inspect DIN, WS and BCK signals while sampling
Yes, I'm sure the samplerate is 44.1kHz or 176.4kHz. The PT8211 has been subject of discussion here on the forum for years and measurements with scopes and logic analyzers have been done. For example, see this thread and this thread.

Paul
 
Well, if code looks fine then some extra checks are required. Make sure ground connection is not done using long wires. Make sure Vdd is seriously decoupled using Low pass low impedance RLC filter, try add a 100 uH coil in series with Vdd but tight to groundon both ends using not only 47uF and 100nF, raise it up to 1000 uF, add 100nF and 1nF also. On output, design and add an RC audio low pass filter but multiple order, not just 1, with cut off frequency to be about 20 Khz to convert any square form back to sine and knock off any harmonics. As a last testing step, power up teensy and P8211T using a 5v battery clean power source, will be amazed by how dirty a phone charger can be. Start generating sampling audio signals from 200Hz up to 15Khz and observe if all spectrum is affected or just a part of it. Any latest DSO oscilloscope have this function, FFT spectrum analysis.
Good luck !
 
Back
Top