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

L and R channels are swapped. #116

Closed
Oppa-YA opened this issue Nov 4, 2021 · 11 comments
Closed

L and R channels are swapped. #116

Oppa-YA opened this issue Nov 4, 2021 · 11 comments

Comments

@Oppa-YA
Copy link

Oppa-YA commented Nov 4, 2021

Hello, after testing for left and right channels i found out that RIGHT channel is playing from LEFT and wise versa. They are swapped. I double checked PCM 5102 datasheet schematics and my PCM board are definitely are correct with L/R channels.
I double checked my phone with my other bluetooth headphones and they receiving correct L and R channels.
So ESP32 sending I2S signal with swapped L/R channels to PCM 5102. Could this be fixed in library?
You can test this with "Stereo test" app from google play.

@pschatzmann
Copy link
Owner

I am confused. My library does not have any concept of left or right.

@Oppa-YA
Copy link
Author

Oppa-YA commented Nov 4, 2021

I am confused. My library does not have any concept of left or right.

Ah i see. So it's probably a bug in ESP-IDF Framework.
BTW could you test this on your hardware? I used this app.
Screenshot_20211104-104843-01

@pschatzmann
Copy link
Owner

Not really.

I don't have any hardware which would make any hard coded decision if channel 0 or 1 is left or right.

@pschatzmann
Copy link
Owner

pschatzmann commented Nov 4, 2021

I could add a method which would swap the channels:

void setup() {
  a2dp_sink.set_swap_lr_channels(true);
  a2dp_sink.start("MyMusic");  
}

@Oppa-YA
Copy link
Author

Oppa-YA commented Nov 4, 2021

I could add a method which would swap the channels:

void setup() {
  a2dp_sink.setSwapChannels(true);
  a2dp_sink.start("MyMusic");  
}

That would be great, thanks! Will wait for it.

I also found a confirmation of that issue and somebody proposed how to fix it. The only problem that I don't understand how to do it.
espressif/esp-idf#3399

Some info from that thread:
"Hi @redchenjs, We have do some test, and the PCM decoded by the SBC actually has the correct left and right channel order.
And the problem appear on the I2S side, our Drvier code defaults to the left channel in the high position, only need to set I2S_CONF_REG (0x0008) when I2S configuration the I2S_TX_MSB_RIGHT bit of the register, L/R, can be flipped over."

Seems like one guy forked a framework and fixed it, i don't know why official is still not fixed, are you using official one?
Here is how that guy seems to fix it (i cant test it):
redchenjs/esp-idf@3040a4d

@pschatzmann
Copy link
Owner

If you go to Tools -> Board -> Board Manager and select ESP32
Which version are you using ? The latest is 2.0.0

@pschatzmann
Copy link
Owner

I added the method set_swap_lr_channels().
Can you help me to test it ?

@Oppa-YA
Copy link
Author

Oppa-YA commented Nov 4, 2021

It does not compile with version 2.0.0. But it compile with 1.0.6. But if i compile it in Arduino IDE it has a bug, devices won't connect to ESP again if I disconnect from ESP. That's why i used VS Code + Platformio now, i don't know how to check board version in it.
Screenshot 2021-11-04 112736

Screenshot 2021-11-04 113655

@Oppa-YA
Copy link
Author

Oppa-YA commented Nov 4, 2021

I added the method set_swap_lr_channels(). Can you help me to test it ?

Yes, how, i need to download code again from github? Give me 5 minures.

@pschatzmann
Copy link
Owner

pschatzmann commented Nov 4, 2021

Are you sure that you use the latest library version in Arduino?
I just tested both versions in Arduino and I don't get any compile errors.
Dont forget to add a2dp_sink.set_swap_lr_channels(true); - If you have an old version this does not compile as well

@Oppa-YA
Copy link
Author

Oppa-YA commented Nov 4, 2021

Are you sure that you use the latest library version in Arduino? I just tested both versions in Arduino and I don't get any compile errors. Dont forget to add a2dp_sink.set_swap_lr_channels(true); - If you have an old version this does not compile as well

Don't know why but after second time i deleted ESP32 lib(board) and installed again version 2.0.0 it worked!
I used code like this, L/R channels are playing correct now, thank you very much!

The only problem left is i tried to upload code from Platformio (which i used before) - i got it to work and flashed to ESP but if i disconnect audio cable and re-connect it again - L/R swap back itself to default wrong positions. It's so confusing.

@Oppa-YA Oppa-YA closed this as completed Nov 4, 2021
@Oppa-YA Oppa-YA reopened this Nov 4, 2021
@Oppa-YA Oppa-YA closed this as completed Nov 4, 2021
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

2 participants