I am trying to set up my Raspberry Pi Zero W to record audio through a microphone while simultaneously playing a separate audio file through headphones.
Here's my setup:
- I have connected the Adafruit I2S MEMS microphone to my Pi according to the instructions here. I have connected the mic's SEL pin to RPi 3.3V so that it outputs on the I2S right channel.
- Then I have connected the MAX98357 I2S Amp according to the instructions here. I have connected the amp's SD pin to RPi 3.3V so that it receives data on the I2S left channel. Note: I have connected the amp to a 3.5mm headphone jack, so in the part where it says "Disable headphone audio" in the instructions, I have instead enabled it by adding snd_bcm2835 to /etc/modules, and uncommenting dtparam=audio=on in /boot/config.txt (it doesn't work unless I do this, however I have gotten it to work without doing this in some later tests that I will talk about).
The problem comes when I try and use them at the same time, in which case only one of them will work (whichever I start using first). If I start by playing a music track through the amp and then start recording from the mic, I can hear the music but get no output to the audio file. If I start recording with the mic and then start playing a music track, the mic records successfully but I can't hear anything through the headphones.
When I use dmesg, I get the error: bcm2835-i2s 20203000.i2s: Trying to bind component to card "snd_rpi_hifiberry_dac" but is already bound to card "snd_rpi_simple_card"
Things I have tried:
- I followed the advice given here, from someone who apparently had the same issue, using the old kernel install method for the amp (also similar advice given here). It made the error go away in dmesg, but still I can't use both devices simultaneously.
- I tried the advice given here from jnickel, to change the id number to 1 instead of 0 when editing my_loader.c. When I did this, I found that I didn't need to uncomment dtparam=audio=on in /boot/config.txt, but ultimately I still had the same problem.
- I tried connecting both SD on the amp and SEL on the mic to RPi GND, i.e. switching the channels, but that did nothing either.
I have also dug into many other semi-related forums about this issue but nothing I tried works. To my knowledge this should be possible to achieve since I2S is made to use two channels at the same time.
I would highly appreciate any advice or insight into what might be the problem, as I have spent many, many frustrating hours trying to get this to work.
I'd happily provide more info on my specs if needed!