Giter VIP home page Giter VIP logo

Comments (2)

stas-sl avatar stas-sl commented on May 31, 2024 1

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.

https://github.com/esphome/esphome/blob/59d6b3afa09c51dc92f036fb8ee746d84489a3ea/esphome/components/i2s_audio/microphone/i2s_audio_microphone.cpp#L27-L41

  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 :)

from esphome-sound-level-meter.

wojciechczyz avatar wojciechczyz commented on May 31, 2024 1

Hi Stas,

bits_per_sample was added recently. Hopefully, sample rate would come soon too:
esphome/feature-requests#2289

Cheers!

from esphome-sound-level-meter.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.