Code Monkey home page Code Monkey logo

Comments (26)

s-hadinger avatar s-hadinger commented on May 26, 2024 1

Will investigate in a couple of days

from tasmota.

Staars avatar Staars commented on May 26, 2024 1

Okay, I have found my INMP441 and could fix the crashes with i2srec.
It was possible to record raw audio in Berry, but the MP3 encoder ist totally broken at the moment, so no luck with i2srec for now. This makes it impossible to stream MP3 for obvious reasons too, although there was another bug that would crash the ESP before the start of the (non working) stream.
There are a few more glitches.

from tasmota.

Staars avatar Staars commented on May 26, 2024 1

INMP441 works here now for MP3 audio recording and streaming on the S3 without distortion and the expected (mediocre) sound quality.
I hope this is repeatable on other platforms too.

Please allow some time for testing and code refactoring as we need some new variables in the driver setting.

from tasmota.

rug1024 avatar rug1024 commented on May 26, 2024

Thanks to @Staars for giving the hint on i2sconfig. And yes, I am using INMP441.
With "RxMode=0" and "Mp3Preallocate=1" the error in the console is gone, but still getting the issue that
IP:81/stream.mp3 does not load.

from tasmota.

Staars avatar Staars commented on May 26, 2024

Meanwhile @rug1024 could try the following things (with seriallog 3):

  1. Check general microphone functionality with i2srec, e.g.:
    i2srec /test.mp3
    (then after a few seconds)
    i2srec (to stop recording and finish writing)
    Download and test MP3 file.

  2. Provide console output while accessing http://IP:81/stream.mp3 from your browser.
    Please also check output of i2sstream and test behaviour of switching stream server on/off with i2sstream 0/i2sstream 1.

from tasmota.

rug1024 avatar rug1024 commented on May 26, 2024

On executing i2srec the device instantly crashed and does not reboot anymore.
Power cycle also not successfull, think it needs to be reflashed with Esptool.

from tasmota.

s-hadinger avatar s-hadinger commented on May 26, 2024

Can you guys describe your configuration (especially template) when the crash happens?

Also the output of command I2SConfig

from tasmota.

Staars avatar Staars commented on May 26, 2024

The crashes in i2srec will happen in every mic-only-configuration at the moment, because these calls can not work without an output instance.


The i2sstream does not start the mic at the moment and crashes without starting it by hand withi2smic 1.

But I still only get garbage MP3 data from the encoder ... which I do not understand yet.

from tasmota.

Staars avatar Staars commented on May 26, 2024

After more bugfixing I have the driver working including MP3 streaming, but the INMP441 is a special animal, that seems to need an unusual I2S configuration. ATM this microphone produces garbled/distorted sound, but at least it works somehow. I have found more infos in other projects, but need to test this myself.

The good thing is, that the new driver is very flexible and can be extented quite easily to reflect very different configurations with one firmware image. You can already exchange the connected microphone (i.e. from Standard to PDM), reconfigure it and use it without reflashing the ESP32.
IMHO it is a huge step forward.

from tasmota.

rug1024 avatar rug1024 commented on May 26, 2024

Great news! Thanks for the effort!
The distortion you report has occurred here too, also in previous Tasmota-builds (afaik since 12.x).
Found out just yet: It's only there when streaming live, when recording via i2srec it's not.
I attached a sample of what it sounds like (recorded with my mobile in front of the speaker).
audio.zip
Next thing: the distortion is only with my ESP32S3, on two other ESP32S2 the stream is clean (Tasmota 13.4.0 Master, Core/SDK Version: 2.0.14 / 4.4.6.240105).
Since these mics don't cost much, what other types can you recommend? Willing to buy and test.

from tasmota.

Staars avatar Staars commented on May 26, 2024

Interesting point about the different behavior of different SOC's.

I will have to check this too as currently the INMP441 is connected to a S3. In theory it should not matter, but I would not be too surprised to find the same.

My PDM micro is a cheap clone of this:
https://learn.adafruit.com/adafruit-pdm-microphone-breakout/overview

But is not extensively tested by me so far. Initial impression is good.

from tasmota.

rug1024 avatar rug1024 commented on May 26, 2024

Great news! Ordered myself 2 of these PDM Mics for testing (like the JST-SH plug).
Will compare to INMP441 and report.

from tasmota.

rug1024 avatar rug1024 commented on May 26, 2024

@Staars
Can you please post your compiler options?
Not quite getting the PDM Mic working yet.

from tasmota.

Staars avatar Staars commented on May 26, 2024

Current state of changes here:
https://github.com/Staars/Tasmota/tree/i2s

There are more refactoring steps ahead, but with the next PR I would like to change as few things as possible.

[env:tasmota32s3-i2s]
extends                     = env:tasmota32_base
board                       = esp32s3-qio_opi
build_flags                 = ${env:tasmota32_base.build_flags}
                              -DFIRMWARE_TASMOTA32
                              -DUSE_I2S
                              -DUSE_I2S_AUDIO
                              -DUSE_I2S_MIC
                              -DUSE_SHINE
                              -DMP3_MIC_STREAM
                              -DUSE_I2S_AUDIO_BERRY
                              -DOTA_URL='""'
lib_extra_dirs              = lib/libesp32, lib/libesp32_div, lib/lib_basic, lib/lib_ssl, lib/lib_i2c, lib/lib_audio
lib_ignore                  = Micro-RTSP

Out of the box this should work with an PDM microphone.
i2sconfig {"Rx":{"Mode":0}} would change to standard mode with default settings for INMP441 with left channel.
i2sconfig {"Rx":{"SlotMask":2}} would change this to right channel.

I2smgain should be set to something like 30-60.

i2sconfig {"Sys":{"Mp3Preallocate":1}} is needed for both. Correct pin settings are of course needed too.

from tasmota.

rug1024 avatar rug1024 commented on May 26, 2024

Will need some time for testing and trying to get this running.
Just wondering what that is for:
grafik

from tasmota.

Staars avatar Staars commented on May 26, 2024

Forget the current docs, the aim for the new driver was to configure "everything" at runtime.

So things like PDM, left/right, mono/stereo, ... do not need a different firmware. You will be even able to swap out the microphone to a total different type later or back and forth without reflashing.

from tasmota.

rug1024 avatar rug1024 commented on May 26, 2024

I tried to compile with Gitpod using your fork, unfortunately this does not work very well.
Since I also use ESP32S3 for testing, could you send me compiled binary just to find out if my mic is working at all?

from tasmota.

Staars avatar Staars commented on May 26, 2024

Then please head over to Discord and find me there or use Tasmotas compiling-development channel.

from tasmota.

Jason2866 avatar Jason2866 commented on May 26, 2024

Tested with M5stack core 2 and i2rec works. saytime does work too.

from tasmota.

Jason2866 avatar Jason2866 commented on May 26, 2024

@Staars Can we close this? Everything I tested is working.

from tasmota.

gemu2015 avatar gemu2015 commented on May 26, 2024

i currently focus on other things,

but after a short test on 2 esp32s3 devices i2splay does only produce some noise while it works on an esp32. i2ssay and i2stime works on all devices, so the i2s channel seems to be ok.

i have a couple of problems with core 3 with several devices such that i will stay at core2 for some more weeks.
e.g. jpeg decoder crashes, (now in rom, used to be in flash)
par8 and par16 display does no longer work. (currently no time to investigate)

from tasmota.

Jason2866 avatar Jason2866 commented on May 26, 2024

@gemu2015 not related to i2s but parallel display do work with core 3.0.0 and uDisplay driver.

EDIT: RGB Display is working. Don't have a parallel display to test.

from tasmota.

s-hadinger avatar s-hadinger commented on May 26, 2024

Unfortunately I don't have any PAR8/PAR16 display... So I can't help

from tasmota.

sfromis avatar sfromis commented on May 26, 2024

I was trying to get I2S audio to work with small 8Ω speaker connected to a board having a MAX98357A. Configured the I2S gpios for BCLK, WS and DOUT to match, and left the SD and GAIN pins unconnected, as indicated on the external DAC wiring suggestions in the docs. The board schematics indicate that GAIN is pulled down, and SD connected directly to the ESP32-S3, no pull-up/down, so unconfigured would be floating.

No luck with commands I2SSay or I2STime.

As MAX98357A specs says that SD_MODE pulled low means shutdown, I decided to config the ESP32-S3 pin as Output Hi and now the test cases worked (not great voice quality, but I'm not very demanding).

Not knowing much about I2S audio, I'm wondering if this suggestion should just be made part of the docs, or if there are complications needing extra considerations.

from tasmota.

Jason2866 avatar Jason2866 commented on May 26, 2024

@sfromis imho mentioning SD_MODE needs a defined state should be in the docs.

from tasmota.

sfromis avatar sfromis commented on May 26, 2024

Did a small test getting a WebRadio MP3 stream to play. Got a few seconds of garbled sound first, but then normal audio. Next step was interrupting it with the command I2STime (saw no clean way of stopping a stream), and got:

[14:34:11.626] 14:34:11.037 CMD: I2SWr http://listen.livestreamingservice.com/181-jazzmix_128k.mp3
[14:34:12.517] 14:34:11.928 I2S: Tx i2s_channel_enable err=0x0000
[14:34:13.041] 14:34:11.934 MQT: t337blng/stat/I2SWR = {"I2SWR":"http://listen.livestreamingservice.com/181-jazzmix_128k.mp3"}
[14:34:13.041] 14:34:12.452 I2S: updateClockConfig i2s_channel_disable err=0x0000
[14:34:13.043] 14:34:12.454 I2S: updateClockConfig i2s_channel_reconfig_std_clock err=0x0000
[14:34:13.044] 14:34:12.455 I2S: updateClockConfig i2s_channel_enable err=0x0000
[14:34:57.870] 14:34:57.282 CMD: i2stime
[14:34:57.880] 14:34:57.290 I2S: updateClockConfig i2s_channel_disable err=0x0000
[14:34:57.880] 14:34:57.291 I2S: Could not write samples (count=1): 259
[14:34:57.880] 14:34:57.292 I2S: Could not write samples (count=1): 259
[14:34:57.881] 14:34:57.293 I2S: Could not write samples (count=1): 259
[14:34:57.883] 14:34:57.294 I2S: Could not write samples (count=1): 259

Last message in a loop until I killed it (power off). First set of time stamps from my terminal program.

(Found how to stop the stream, just the command I2SWr without URL).

from tasmota.

Related Issues (20)

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.