Raspberry Pi Pico Pio I2S and Touch

I have raspberry Pi Pico and programming it via the Arduino IDE and libraries.
I can run generating Audio out via I2S to external DAC. It works with earlephilhower library and uses pio as far as I know because there are no I2S ports on Pico. It works OK but that is really all that is in that sketch. It plays a programmed list repeating loop with no control buttons.

I wanted to add some control buttons and tried touch buttons. There are no touch pins on the Pico so this is programmed via pio using Geriko PicoCapSense library… MultiCapSensing for RP2040 Pico.
I tried this in a new sketch first and it worked… I got 8 touch pads working creating 2 pio, 4 pads on each pio, using 2 pins each pad having a 1Meg and a 1K resistor to each pin for each pad.

I tried to add this sketch to my Audio sketch and even with 1 pio created and only 1 touch pad it slowed to sketch down to all I could hear was clicks…???
Does this mean that I2S is using all pio resources and then none available for touch. ??
I would welcome some help please or example sketch using I2S and touch…?? and how to spread the load.
Regards

I would suggest something simpler: use a mpr121 I2C breakout. They are really cheap and provide you with 12 touchpads. There are also ready to use mpr121 breakouts with touchable areas with numbers or even music controls. Since mpr121 are so common, you will certainly also find suitable Arduino libraries.

This will definitely remove load from your pico.

Thanks for reply. Yes I was thinking of this but wanted to keep things as small as possible, poss all 1 board. My query is it the pio that has no resource left for the touch when I2S is running or is it just the speed of what is happening in the loop. Reading 8 touch seems to take a long time on pico. I would still need to read the mpr121 as often as possible. I can poss try 8 digitalread with digital inputs and see if it is time in loop that is problem. and chech response time and breakup in audio. Is there any way I can know if i1S is running is it using all pios …??

You have some more things to try: interrupts and the pico has a second core. So one core could take care of the touch, the other of I2S.

i2s, on a Pi is done via PCM, and uses a specific set of pins.
PCM at Raspberry Pi GPIO Pinout
I would think it should be doable on a Pico, your just not limited to using specific pins. Pimoroni did it here.
Pico Audio Pack (Line-Out and Headphone Amp) (pimoroni.com)
Looks to be Experimental and Circuit Python though?
There is a link to some C++ stuff though.
raspberrypi/pico-playground (github.com)

Thanks for replies, looks like too many options. I have always used Arduino IDE for prog sketches in Uno etc etc. Wanted to try out the Rpi Pico that why I used the Rpi library plugins for I2S and touch. All the googling I did tols me it wasnt available on the Pico except programmed via PIO.
But now you say I2S is available…?? but it is called PCM which is the coding for the sampling not the transmission. Is there a library for the Arduino IDE for I2S or is it only available by Circuit Python. Also the Touch is it available by Circuit Python. I’m not all that familiar with Python so will need to do some reading and is it reliable or just a teaching tool.
I tried running 2 cores on the Arduino, just using setup() and loop() for core0 doing I2S, and setup1() and loop1() for core1 doing touch. I didnt see any difference from before, as soon as the sketch attempted to read touch it slowed down to just clicks.
I tried just polling in the loop reading 8 digitalRead pins and do not seem to have any problem Pico still keeps play the I2S sound and responds to the change as per the digital button pressed. So I don’t think there would be any problem reading the output from the mpr121.
I would still was a 1 board solution if possible, so, is ther any examples anywhere of how to setup the PIOs for multiple tasks and how to share the resources properly…??

I have ZERO C skills. And what I know in Python I learned the hard way, self taught. Same thing with Micro python, I’m learning as I go along. Python seemed to be the predominant programing language on the go for a Raspberry Pi, so I went that way.

Had a go at using Python and got you I2S links working OK. Used pins 20,21,22 and had to set left_justified =True for the PT8211 DAC I am using.
I then came across this webpage … Adafruit CircuitPython API Reference — Adafruit CircuitPython 8.1.0-beta.0 documentation …It has load of info on Python and looks like libraries for everything including “touch”. and it is a ref manual of all the functions and statements available…Why is this not better advertised on the RPi websites. Most of the RPi sites show simple examples or videos that work OK but no ref to where the functions come from.
As I2S and touch are available why would anyone want to implement these via PIO…??