raspberrypi / pico-extras

BSD 3-Clause "New" or "Revised" License
468 stars 117 forks source link

audio_i2s.pio comment regarding FIFO word reverses channels #59

Open rde2 opened 1 year ago

rde2 commented 1 year ago

The comment in audio_i2s.pio explaining the word format reverses the 'ws' (LRCLK) value. The PIO sends the first (most significant) 16 bits with LRCLK = 1 and the second with LRCLK = 0. For stereo samples the second 16-bit half in memory corresponds to bits 31:16 and hence is the right channel (assuming I2S where LRCLK = 0 for left).

; Autopull must be enabled, with threshold set to 32.
; Since I2S is MSB-first, shift direction should be to left.
; Hence the format of the FIFO word is:
;
; | 31   :   16 | 15   :    0 |
; | sample ws=0 | sample ws=1 |
rde2 commented 1 year ago

I believe that I2S requires the left channel to be sent before the right, so playback may be out of sync. See the thread https://forums.raspberrypi.com/viewtopic.php?p=2087056#p2087056 for a discussion.