Skip to content

i2s stereo is reversed in Raspberry Pi Pico #10230

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

Closed
VinceParsons opened this issue Apr 7, 2025 · 2 comments · Fixed by #10250
Closed

i2s stereo is reversed in Raspberry Pi Pico #10230

VinceParsons opened this issue Apr 7, 2025 · 2 comments · Fixed by #10250
Assignees
Labels
audio bug rp2 Both RP2 microcontrollers
Milestone

Comments

@VinceParsons
Copy link

VinceParsons commented Apr 7, 2025

CircuitPython version and board name

Verified on 8.x, 9.x, and even the 10 pre-releases. raspberry_pi_pico_w, but also verified on a pico 2w.

Code/REPL

import board
import audiobusio
import audiocore
import time

audioOut = audiobusio.I2SOut(bit_clock=board.GP8, word_select=board.GP9, data=board.GP7)
sound = audiocore.WaveFile("leftright.wav")
audioOut.play(sound)

while audioOut.playing:
	time.sleep(1)
	
print("done")

Behavior

No error messages, but left and right channels are reversed. The same code (pins adjusted, of course) on a WaveShare ESP32-S3-Zero works correctly.

Description

Only tried on i2s, not PWM audio. Is reversed whether or not a mixer is used, or whether file is .wav or .mp3.

Additional information

No response

@Neradoc Neradoc added the rp2 Both RP2 microcontrollers label Apr 7, 2025
@tannewt tannewt added the audio label Apr 8, 2025
@tannewt tannewt added this to the 10.0.0 milestone Apr 8, 2025
@tannewt
Copy link
Member

tannewt commented Apr 8, 2025

We can probably modify the PIO I2SOutput code to change the word select polarity and it'll be fixed. I'm not sure we ever checked this.

@dhalbert dhalbert self-assigned this Apr 11, 2025
@dhalbert
Copy link
Collaborator

dhalbert commented Apr 11, 2025

I tested with a Metro RP2040 and a two-channel I2S audio amp (Adafruit Pi Speaker Bonnet). The channels are swapped most of the time but not quite all the time. There are actually four different PIO programs in the code: two for left_justified or not, and two for swapping the order of bit_clock and word_select or not. Those two pins must be consecutive, but we allow them to be in either order.

bit_clock word_select left_justified Left/Right swapped using swapped bit_clock/word_select pins program
D2 D3 False swapped -
D3 D2 False correct swapped-pin program
D2 D3 True swapped -
D3 D2 True swapped swapped-pin program

It is not clear to me what left_justified is actually doing, because the output sounds the same. There are PIO program differences, though.

(Side comment: At first I tested with a UDA1134 stereo amp, and got terrible noise on one channel when there was any signal on that channel. This is odd and is a completely separate issue. The problem was confined to RP2040 + UDA1334. The UDA1334 worked OK with a SAMD51 doing I2S. Maybe this is a missing pull or something like that.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audio bug rp2 Both RP2 microcontrollers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants