Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distorted sound with PT8211 I2S-DAC (regression) #6940

Closed
tfry-git opened this issue Dec 24, 2019 · 5 comments
Closed

Distorted sound with PT8211 I2S-DAC (regression) #6940

tfry-git opened this issue Dec 24, 2019 · 5 comments

Comments

@tfry-git
Copy link
Contributor

Using the cheap PT8211 I2S-DAC, all I get is highly distorted sound output. Scoping the output it looks like the sign bit is either disregarded or misinterpreted. The output is "cut" on the center line, and the lower half is shifted upwards to be above the upper half.

Output was working fine in a February 2018 development snapshot of the core, but is no longer in version 2.6.3. I suppose the issue may have been introduced with #4574 / #4571 .

The culprit appears to be in the following line of code:

I2SC |= I2SRF | I2SMR | I2SRMS | I2STMS | (div1 << I2SBD) | (div2 << I2SCD);

changing this to I2SC |= I2SRF | I2SMR | I2SRMS | (div1 << I2SBD) | (div2 << I2SCD); (removing "| I2STMS") fixes the issue for me, but probably breaks stuff elsewhere.

@earlephilhower
Copy link
Collaborator

#4571 is the cause.

The old Arduino code was sending data 1 bit too early ("Japanese format") and was broken for the standard I2S ("Philips" IIRC). Your DAC datasheet specifies Japanese mode, so it's kind of uncommon in that respect compared to reports I've had from ESP8266Audio.

The current mode isn't going to change, and there is not (yet) and API to allow setting the I2S mode, so you'll need to keep your patch. For 3.0 we're probably going to reset the I2S API completely, making something closer to the Arduino I2S class (which is, itself, kind of hokey). We're tracking that in #427 (yes, it's that old!).

Closing this one as wontfix for now, and tracked in #427.

@NoNamedCat
Copy link

How can I use the PT8211 with this library now? I cant use the DAC now because the i2s driver changed in the sourcecode and i cant see how i need to modify the library. Please help?

@NoNamedCat
Copy link

Ok... I find it and is working now:

In the line 493 of the file core_esp8266_i2s.cpp change this line to:

i2sc_temp |= I2SRF | I2SMR | I2SRMS | (div1 << I2SBD) | (div2 << I2SCD);

@masm31
Copy link

masm31 commented Jun 30, 2024

it work for esp8266 ,How about in esp32?

@masm31
Copy link

masm31 commented Jul 2, 2024

it work for esp8266 ,How about in esp32?
i found , just add out->SetLsbJustified(true); and work for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants