I2S/MEMS microphone example

Sorry for the major hold up! Here’s the code for adding an external audio codec. Since your device is a microphone and doesn’t use the transmit side, I’ve commented that out.

/** Daisy Seed Initialization */
seed.Init(true);

/** secondary audio */
/** Configure the SAI2 peripheral for our secondary codec. */
SaiHandle::Config external_sai_cfg;
external_sai_cfg.periph = SaiHandle::Config::Peripheral::SAI_2;
external_sai_cfg.sr = SaiHandle::Config::SampleRate::SAI_48KHZ;
external_sai_cfg.bit_depth = SaiHandle::Config::BitDepth::SAI_24BIT;
// external_sai_cfg.a_sync = SaiHandle::Config::Sync::SLAVE;
external_sai_cfg.b_sync = SaiHandle::Config::Sync::MASTER;// external_sai_cfg.a_dir = SaiHandle::Config::Direction::TRANSMIT;
external_sai_cfg.b_dir = SaiHandle::Config::Direction::RECEIVE;
external_sai_cfg.pin_config.fs = seed::D27;
external_sai_cfg.pin_config.mclk = seed::D24;
external_sai_cfg.pin_config.sck = seed::D28;
external_sai_cfg.pin_config.sb = seed::D25;
// external_sai_cfg.pin_config.sa = seed::D26;

/** Initialize the SAI new handle */
external_sai_handle.Init(external_sai_cfg);

AudioHandle::Config audio_cfg;
audio_cfg.blocksize = 24;
audio_cfg.samplerate = SaiHandle::Config::SampleRate::SAI_48KHZ;
audio_cfg.postgain = 1.0f;

seed.audio_handle.Init(audio_cfg, seed.AudioSaiHandle(), external_sai_handle);

Your audio callback should have two new samples for the mic in, so it’ll be:

in[0][i] // on board codec L in, as usual
in[1][i] // on board codec R in, as usual
in[2][i] // mic L in. (I looked at the datasheet, and the mic claims to have L and R, which is a bit weird!)
in[3][i] // mic R in

out[0][i] // on board codec L out, as usual
out[1][i] // on board codec R out, as usual

Let me know how that works or if you have any other questions!