Open mikenorgate opened 1 year ago
Yeah, I know, it would make sense of course. But unfortunately it lacks a few features for now that I consider rather important. First one is probably quite easy to fix/implement. Currently sample rate/bits per sample are hardcoded there as 16bits@16kHz. Sound meter will of course work with it, but you might need to recalculate all IIR coefficients and probably loose some precision. I don't know how much the difference will be, but I'd prefer rather more precision than less :) I hope, ability to specify audio quality via config will be implemented in the official i2s_audio component at some point.
i2s_driver_config_t config = {
.mode = (i2s_mode_t) (I2S_MODE_MASTER | I2S_MODE_RX | I2S_MODE_PDM),
.sample_rate = 16000,
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
.channel_format = I2S_CHANNEL_FMT_ONLY_RIGHT,
.communication_format = I2S_COMM_FORMAT_STAND_I2S,
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
.dma_buf_count = 4,
.dma_buf_len = 256,
.use_apll = false,
.tx_desc_auto_clear = false,
.fixed_mclk = 0,
.mclk_multiple = I2S_MCLK_MULTIPLE_DEFAULT,
.bits_per_chan = I2S_BITS_PER_CHAN_DEFAULT,
};
Second feature is probably more complicated. Currently I'm reading audio data in a separate FreeRTOS task, which means that it can read/process audio even if there are other long running tasks in parallel (like HTTP/MQTT requests). Depending on your config/setup you might have or have not them, but I do have and I'd like not to loose audio data.
Considering these 2 issues, I'd say I don't plan to use official i2s_audio for now, but if it will change in future, I can change my mind :)
Hi Stas,
bits_per_sample was added recently. Hopefully, sample rate would come soon too: https://github.com/esphome/feature-requests/issues/2289
Cheers!
Now that ESPHome has an official i2s_audio component https://esphome.io/components/i2s_audio.html do you have any plans to update the sound level meter to use that implementation?