So for a school project I need to be able to route audio from a USB sound card to I2S. More specifically, the I2S will be connected to an XMOS xCore-200 Multichannel Audio Platform. I need to write a program that will receive audio input from a USB sound card and send it to the XMOS via I2S and vice versa (receive audio via i2S from the XMOS and send it out via the USB sound card, which will have basic 3.5mm jacks for input and output). I have had no luck finding info on programming I2S on the RPi.

So first, is this even possible to do?

If so, where can I find a code manual or guide that can show me how to do this. I would prefer to program it in C++ or a similar language if possible.

  • @JaromandaX Ive ready over that page as well as many others. Its not what it says it is, it merely praises the high quality audio that I2S provides and then lists a few DACs that can be used for it. I am looking for a guide to assist in programming the RPi to send the audio out and receive audio via I2S and also on how to route the I2S audio to a USB sound card
    – wlegra2
    Apr 20, 2017 at 6:52
  • right - sorry, I must admit I didn't read past the title in that link :p I'll remove the comment, sorry for wasting your time Apr 20, 2017 at 6:56
  • @JaromandaX no problem. I understand, i also thought this kind of information would be easy to find
    – wlegra2
    Apr 20, 2017 at 6:58
  • Can you be more clear ? Do you have the XMOS wired up and working already ? What stage is this project at ? Do you need to wire up the XMOS and write the driver for it first ?
    – Matt
    Apr 20, 2017 at 22:05
  • @Matt our project is a two semester school project. The first semester is for designing how the system will work, and in the second semester, the parts are purchased and our project will be physically assembled. Right now we are in the first semester, attempting to confirm that our design is possible. So nothing has been physically wired or programmed yet. I am simply looking for code libraries that i can be used to do this so i can confirm that it is possible
    – wlegra2
    Apr 20, 2017 at 22:13

1 Answer 1


You can route audio from USB to I2S using Linux. For the Pi, start by working out whether you want to use the XMOS on the I2S side, or alternatively choose an I2S sound card, here is a list of some of the available cards.

Next you will want to plug both sound cards into the Pi. Remove the PWM audio interface from the deivce tree by commenting out dtparam=audio=on in /boot/config.txt and putting the I2S card's overlay there so it boots on startup and it working.

Finally, you will want to route the audio from the usb card to the I2S card. Imagine your usb card is hw:1 and your I2S card is hw:0. You can do this something like the following :

arecord -D hw:1 | aplay -Dplug:dmix -

You use the dmix plugin on the output (or instead dsnoop on the input) to ensure that clock drift is accounted for. Why clock drift you ask ? Because the two sound cards will operate with different master clocks and whilst they may both have the same sample rate, they will clock at slightly different frequencies.

  • Thank you so much. For our implementation, i was planning on wiring the I2S pin outs directly to the XMOS board, as the XMOS board has a built in DAC which (I assume) would remove the need for a separate I2S board with a DAC. (Please correct me if im wrong). So essentially all i would need to do is put the XMOS boards "overlay" in place of the PWM aufio interface and then call arecord and aplay as you have it above?
    – wlegra2
    Apr 26, 2017 at 17:47
  • Also, is it possible for the Raspberry Pi to both send and receive I2S audio from the XMOS board? I know the RPi can send I2S but for our purposes it also needs to be able to receive it and route it to USB sound card output
    – wlegra2
    Apr 26, 2017 at 17:56
  • Not sure why you need the XMOS at all. Can't you choose an I2S audio card which already works ? There are some which have both input (ADC) and output (DAC) I2S lines already working. In the list of cards above, you can find such cards.
    – Matt
    Apr 27, 2017 at 19:31
  • Its for a project to build an audio switching unit. The idea is to route the usb in audio over I2S to the XMOS which will route it out of any output on the xmos. And also route any input on the XMOS over I2S to the rpi and out the usb
    – wlegra2
    Apr 27, 2017 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.