The MEMS microphone produces I2S digital audio - 32bit words per channel, 24 bits of MSB aligned data per word, of which 18bits are significant. Data on non-connected channels are tri-state - adding a pull down resistor to the data line can clear up the unconected channel, which makes it easier to determine whats what.
Here's the I2S config:
Code: Select all
const i2s_config_t i2s_config = {
.mode = i2s_mode_t( I2S_MODE_MASTER | I2S_MODE_RX ), // Receive as Master
.sample_rate = 22050, // 22kHz is equivalent to 11kHz maximum audio frequence, re Nyquist
.bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT, // 32 clock pulses per channel
.channel_format = I2S_CHANNEL_FMT_ONLY_LEFT, // Only capture the LHS channel
.communication_format = i2s_comm_format_t( I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB ), // Philips format
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1, // Interrupt level 1
.dma_buf_count = 9, // (9-1)*256 = 2048 samples per read (1 buffer in use and unavailable during read)
.dma_buf_len = 256, //
.use_apll = false, //
.tx_desc_auto_clear = false, //
.fixed_mclk = 0 };
Code: Select all
// Create the complex vector
for ( int i = 0; i < 2048; i++ )
{
int val = ( *(uint16_t*) &m_samples [ i ] ); // m_samples are the raw 32 bit words
y_cf [ i * 2 + 0 ] = val; // Not using windowing, but is in the basic math demo
y_cf [ i * 2 + 1 ] = 0;
}
dsps_fft2r_sc16( data, length ); // The FFT calc
dsps_bit_rev_sc16_ansi( data, length ); // Bit reverse used in the 32 - Do not know what this does or why
dsps_cplx2reC_sc16( data, length ); // Convert one complex vector to two complex vectors - Do not know what this does or why
Code: Select all
10 * log10f(
( y_cf [ i * 2 + 0 ] * y_cf [ i * 2 + 0 ]
+ y_cf [ i * 2 + 1 ] * y_cf [ i * 2 + 1 ] ) / 2048) )
Any thoughts appreciated!