schreibfaul1 / ESP32-audioI2S

Play mp3 files from SD via I2S
GNU General Public License v3.0
1.09k stars 284 forks source link

audio.connecttoFS() can't play audio with 8 BITS_PER_SAMPLE ? #786

Closed kaloprojects closed 1 month ago

kaloprojects commented 3 months ago

Hi Schreibfaul1, :) first of all i want to send you a huge Thank you! your AUDIO.H library is awesome, using audio.connecttohost() + audio.connecttoFS() daily, also love your Google and OpenAI TSS call. fyi: I referenced to your library on my Github project (code snippets for variable Voice Recording via I2S & SpeechToText transcription via Deepgram), let me know if you don’t wish to be referenced in my README then i can remove, no problem.

To the topic/subject - the issue i found: Are you aware that your current 'audio.connecttoFS()' does not support audio with real '8-bit width data ? Pretty sure it is not your fault, have seen that latest I2S reference is telling that ish_std.h always using 16-bit-with (even if 8BIT defined!). See here: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/i2s.html#std-tx-mode. This Espessif workflow of course is a pain, inflating size to double (each 2nd byte is zero), makes not much sense in my opinion. So what i did (in my I2S recording procedure: converting this I2S 'fake' 8BIT with upper msb zeros into real 8 bit waves (and storing with proper wav header). Reason: Pretty simple, 8bit wave files (mono) have half size of 16 bit so any actions SD file read and sending to STT services have double speed. So meanwhile using 8bit only .. but can’t play them any longer with your library

I attached a zip with correct wave files (correct wav header too), both work perfect on PC .. but on ESP32 the 'audio.connecttoFS()' fails with the 8 bit version. Could you pls. check once ? Thank you !

kaloprojects commented 3 months ago

here to test: Audio_Samples.zip

schreibfaul1 commented 2 months ago

Some external DACs, like the PCM5102A, require 16...32 bits per sample. This is the reason why I always convert 8 to 16 bit. 8 bit mono wav is rarely used, I hope it works better now,

kaloprojects commented 2 months ago

Cool :) .. thank you for adding in your code update for #786 .. yes 8bit is rarely used, but for the fast transfer on websockets (e.g. for STT services) it helps a lot, so I'm happy that native 8bit will be supported now with lastest fix. I just wanted to test, ...

.. but i have dummy (newbie) question ;): the updated code is not automatically merged in the lastest Arduino/ESP package (fyi: i am using Arduino 1.8.19 due Win7 and latest ESP 3.0.2), am i right ? .. so i have manually to install your latest zip, correct ?

The reason i ask: I tried to install your zip wie IDE Library manager, then got the message 'ESP32-audioI2S-master.zip' _already installed .. but funny: It is not listed at all in my IDE Manager. Strange, so i cant delete or update in aproper way._ But in my local "C:\Users..\Documents\Arduino\libraries i indeed can find an older version from April (no idea why, maybe i loaded this zip once and forgot about).

Long story short: should i manually delete my folder 'C:\Users..\Documents\Arduino\libraries\ESP32-audioI2S-master' .. and install the latest zip (3.0.11ff) from your side again via IDE library manager again .. or is it part of a future (e.g. ESP3.0.4 package) anyhow ? sorry for this dummy question, just wanted to make sure i install the right way (and telling the folks on my Github project correctly how to install your latest code branch).

Thank you again for brief answer!

schreibfaul1 commented 2 months ago

I'm not very familiar with the Arduino IDE, I don't know where the libraries are stored by default. My suggestion would be to download the repository as a zip and then unzip the src folder into your sketch folder.

kaloprojects commented 2 months ago

Haha .. same on my side (so i am not alone on this) , this Arduino IDE is a bit tricky. i deleted folder .. installed your latest zip file (from today, 3.0.11g with the pitch bug fix too):

it works PERFECT :), Thank you so much for this work!. I also tested the low resolution wav files (8kHz /8bit mono) they work well and fast for STT services (i tested with Deepgram) .. and your latest fix allows us now to play such tiny wav files also ESP32 I2S DACs. So GREAT.

Thank you Schreibfaul ! :)

github-actions[bot] commented 1 month ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 1 month ago

This issue was closed because it has been inactive for 14 days since being marked as stale.