I2S input - what boards support it
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- erlendf
- Posts: 6
- Joined: Tue Dec 17, 2013 3:05 am
I2S input - what boards support it
I want to connect an I2S audio source to the microcontroller. With Feather S2 ESP32 I have got I2S output working, but the Feather does not seem to have support for either hardware I2S input, nor a driver. To test I have the Mems I2S microphone break-out. I prefer using Circuitpython. If required, I would like to buy a more suited microcontroller, but it should also have wi-fi and Circuitpython. I just do not know which board to buy - or if I have to?
- mikeysklar
- Posts: 14194
- Joined: Mon Aug 01, 2016 8:10 pm
Re: I2S input - what boards support it
@erlendf,
Have you tried running the "Where's my PDMIn?" code example on your Feather S2?
https://learn.adafruit.com/adafruit-pdm ... 3038798-11
Have you tried running the "Where's my PDMIn?" code example on your Feather S2?
https://learn.adafruit.com/adafruit-pdm ... 3038798-11
Code: Select all
import board
import audiobusio
from microcontroller import Pin
def is_hardware_PDM(clock, data):
try:
p = audiobusio.PDMIn(clock, data)
p.deinit()
return True
except ValueError:
return False
except RuntimeError:
return True
def get_unique_pins():
exclude = ['NEOPIXEL', 'APA102_MOSI', 'APA102_SCK']
pins = [pin for pin in [
getattr(board, p) for p in dir(board) if p not in exclude]
if isinstance(pin, Pin)]
unique = []
for p in pins:
if p not in unique:
unique.append(p)
return unique
for clock_pin in get_unique_pins():
for data_pin in get_unique_pins():
if clock_pin is data_pin:
continue
if is_hardware_PDM(clock_pin, data_pin):
print("Clock pin:", clock_pin, "\t Data pin:", data_pin)
else:
pass
- erlendf
- Posts: 6
- Joined: Tue Dec 17, 2013 3:05 am
Re: I2S input - what boards support it
PDM or I2S - Adafruit says two opposite things:
About the PDM microphone board you say: It's digital but its not PWM and it's not I2S. Then in an other place you say: It's easy to use the Adafruit PDM microphone breakout with CircuitPython, using the built-in audiobusio module and PDMIn class. It allows you to record an input audio signal from the microphone using I2S. Then, about the I2S microphone board you say: , you will often find an I2S peripheral, that can take digital audio data in! That's where this I2S Microphone Breakout comes in.
I am confused; I thought PDM was a raw pulse coded format, whereas I2S is a digital protocol - and that the two have nothing to do with each other. With the I2S microphone breakout do I not simply need the microcontroller to read the I2S protocol as an input? Does anybody know of a microcontroller that does this?
About the PDM microphone board you say: It's digital but its not PWM and it's not I2S. Then in an other place you say: It's easy to use the Adafruit PDM microphone breakout with CircuitPython, using the built-in audiobusio module and PDMIn class. It allows you to record an input audio signal from the microphone using I2S. Then, about the I2S microphone board you say: , you will often find an I2S peripheral, that can take digital audio data in! That's where this I2S Microphone Breakout comes in.
I am confused; I thought PDM was a raw pulse coded format, whereas I2S is a digital protocol - and that the two have nothing to do with each other. With the I2S microphone breakout do I not simply need the microcontroller to read the I2S protocol as an input? Does anybody know of a microcontroller that does this?
- erlendf
- Posts: 6
- Joined: Tue Dec 17, 2013 3:05 am
Re: I2S input - what boards support it
@mikeysklar, thank you for your reply, but as I am describing in my latest post it is not PDM I want, but I2S.
- mikeysklar
- Posts: 14194
- Joined: Mon Aug 01, 2016 8:10 pm
Re: I2S input - what boards support it
@erlendf,
At this time with CircuitPython the only support I see is for I2SOut and PDMIn. This is why I suggested running the PDMIn code. In our docs we still consider PDMIn to be recording over I2S.
https://circuitpython.readthedocs.io/en ... hlight=i2s
There is some example code to discover usable I2S output pins, but nothing for I2S input.
https://learn.adafruit.com/adafruit-max ... iring-test
At this time with CircuitPython the only support I see is for I2SOut and PDMIn. This is why I suggested running the PDMIn code. In our docs we still consider PDMIn to be recording over I2S.
https://circuitpython.readthedocs.io/en ... hlight=i2s
There is some example code to discover usable I2S output pins, but nothing for I2S input.
https://learn.adafruit.com/adafruit-max ... iring-test
Code: Select all
import board
import audiobusio
from microcontroller import Pin
def is_hardware_i2s(bit_clock, word_select, data):
try:
p = audiobusio.I2SOut(bit_clock, word_select, data)
p.deinit()
return True
except ValueError:
return False
def get_unique_pins():
exclude = ['NEOPIXEL', 'APA102_MOSI', 'APA102_SCK']
pins = [pin for pin in [
getattr(board, p) for p in dir(board) if p not in exclude]
if isinstance(pin, Pin)]
unique = []
for p in pins:
if p not in unique:
unique.append(p)
return unique
for bit_clock_pin in get_unique_pins():
for word_select_pin in get_unique_pins():
for data_pin in get_unique_pins():
if bit_clock_pin is word_select_pin or bit_clock_pin is data_pin or word_select_pin\
is data_pin:
continue
if is_hardware_i2s(bit_clock_pin, word_select_pin, data_pin):
print("Bit clock pin:", bit_clock_pin, "\t Word select pin:", word_select_pin,
"\t Data pin:", data_pin)
else:
pass
- erlendf
- Posts: 6
- Joined: Tue Dec 17, 2013 3:05 am
Re: I2S input - what boards support it
Thanks, but it makes me wonder what the Adafruit I2S MEMS Mic breakout is for? It specifically says that it is not PDM, but I2S.
Regards,
Erlend
Regards,
Erlend
- mikeysklar
- Posts: 14194
- Joined: Mon Aug 01, 2016 8:10 pm
Re: I2S input - what boards support it
Erlend,
On the Arduino side I2S mic input is supported as I2S not PDMin.
https://learn.adafruit.com/adafruit-i2s ... g-and-test
https://github.com/adafruit/Adafruit_ZeroI2S
https://www.arduino.cc/en/Tutorial/Libr ... ialPlotter
On the Arduino side I2S mic input is supported as I2S not PDMin.
https://learn.adafruit.com/adafruit-i2s ... g-and-test
https://github.com/adafruit/Adafruit_ZeroI2S
https://www.arduino.cc/en/Tutorial/Libr ... ialPlotter
- erlendf
- Posts: 6
- Joined: Tue Dec 17, 2013 3:05 am
Re: I2S input - what boards support it
@mikeysklar, thank you for your reply. I will put the I2S ambition to rest for now, then - until someday there will be CircuitPython support for it. Instead I will connect my Feather M4 to a separate audio recorder/player with it's own Flash, codec, and uC. The benefit is also that the audio work will not bog down the M4. I intend to test out a board callled SOMO II for this purpose, because the codec from Ada would unfortunately need the M4 to do the processing.
My application needs to play audio from a range of short soundbites, as well as be able to record 1 soundbite of max 15sec, that can be replayed later.
Thanks for clarifying the I2S stuff,
Erlend
My application needs to play audio from a range of short soundbites, as well as be able to record 1 soundbite of max 15sec, that can be replayed later.
Thanks for clarifying the I2S stuff,
Erlend
Please be positive and constructive with your questions and comments.