I may have missed something but I can’t find any libraries or examples for the Raspberry Pi Pico Audio pack.
The product page refers to the Pico SDK but, other than bit banging the audio into the card using DMA or manually toggling the GPIO pins I can’t see any higher level support.
Have I missed something or am I going to have to start reading up on the DMA, timer and interrupt functions and roll my own driver?
The software end of things for the Pico accessories seems a bit underbaked at the moment, I think some boards have hit the shop before the accompanying code is finished. It might be worth poking @Gadgetoid on twitter or Github to see what the deal is, the repo page says that the audio pack has a library, so he may have just forgotten to unhide it?
You’ll note there’s no I2S peripheral… instead of having specific hardware support for serial-data-like peripherals like these, the RP2040 comes with the PIO state machine system which is a … way to create custom hardware logic and data processing blocks. … … … often we bitbang the timing-specific protocol… for the RP2040, we instead use a PIO object that reads in the data buffer and clocks out the right bitstream… Same with I2S audio in or out.
That says I2C, which is not the same as I2S. The RP2040 doesn’t have I2S hardware units, but it’s possible to emulate one using the Programmable IO, which is what your later links are describing.
Has anyone had any luck getting the i2s example from pico-extras working with the pico-audio?
It certainly isn’t working for me.
Edit: Ok I managed to get a very glitchy looking sinewave out of one of the outs using the example.
Appears the API expects you to set the GPIO number not the pin number, so its really:
The web page for the device on the pimoroni store incorrectly tells you to set them to 12 and 14 respectively.
Now to figure out how to get stereo out before making an i2S API for humans.
as promised on the product page: Please note that Pico Audio Pack only currently works with the C/C++ Pico SDK! We have Micro Python support planned but it is not available yet.
Any idea when this will happen?
As a newbie to pico, and python, (and so much more) a BUMP from the heart…
Sorry Mike not yet, been dead super busy at work and i’ve not had the mental bandwidth to get round to making a friendlier lib. Defo near the top of my todo list tho!
MicroPython support depends on MicroPython upstream adding some support for i2s audio, which is still very much in the taking-shape phase: https://github.com/micropython/micropython/pull/4471 (note, the linked discussion is not about Pico, but its conclusion will set the precedent that Pico MicroPython i2s support should try and follow)
Thanks it is there now.
I kept a copy of what I downloaded after your first announcement above and it wasn’t in it. Maybe it took GitHub a bit of time to serve up the new one. Off to try it, looks a step up from the Raspberry Pi one.
Sorry to be so thick again but I can’t get your code to compile. I copied the pico_audio project and ran a cmake …
pi@raspberrypi400:~/pico_audio/build $ cmake … -DPICO_SDK_POST_LIST_DIRS=/home/pi/pico/pico-extras
I got a warning saying
“No cmake_minimum_required command is present”
and another one saying
" Manually-specified variables were not used by the project:
PICO_SDK_POST_LIST_DIRS
"
Then a make commend instead of compiling did nothing.
So I must be missing a step any idea what it is?
I used an other (modified) cmake file that I had used to run the sine_wave program from the pico-playground. This compiled everything but fell over when it came to linking the modules.
tnx to @gadgetoid for the clarifications and the link to ‘pico_audio’. I discovered I had that example in an installed clone of the pimoroni-pico repository. After adding to settings.json in VSCode:
“cmake.configureSettings”: {
“PICO_SDK_PATH”: “${ENV:PICO_SDK_PATH}”,
“PICO_SDK_POST_LIST_DIRS”: ["${ENV:PICO_DRV}/pico/pico-extras", “…some other path…”] },
I was able to successfully build and flash the pico_audio example to a RPi Pico with back-to-back connected the pico-audio pack. It made the audio working on both a little speaker and on a set of headphones for a mobile phone. Audio worked on either ‘phones’ or ‘line out’.
Btw: ${ENV:PICO_SDK_PATH} and ${ENV:PICO_DRV} are environment variables that I defined in (~/.bashrc) of a MS Windows 10 WSL1/Ubuntu 20.04 session.
paulsk