Xinyuan-LilyGO / T-Deck

297 stars 54 forks source link

Can't completely load any Audio example #63

Open richonguzman opened 3 days ago

richonguzman commented 3 days ago

tried using the "Audio.h" for playing a mp3 file through T-deck speaker, but cant find a way to even import libraries needed on platformio to make use of the speaker play.

any small guide as which library to use?

lewisxhe commented 3 days ago

Copies of all used example libraries are placed in the lib directory

“Audio.h” is here https://github.com/Xinyuan-LilyGO/T-Deck/tree/master/lib/ESP32-audioI2S

richonguzman commented 3 days ago

Copies of all used example libraries are placed in the lib directory

“Audio.h” is here https://github.com/Xinyuan-LilyGO/T-Deck/tree/master/lib/ESP32-audioI2S

should this also work if using Platformio instead of Arduino IDE ?

lewisxhe commented 3 days ago

Of course it works. There is no difference between the two except the way they are built.

richonguzman commented 3 days ago

I copy all the "ESP32-audioI2S" folder into /lib folder of my project.

then I compile in Platformio with this:

`

include "Audio.h"

include "FS.h"

ifdef HAS_I2S

namespace AUDIO_Utils {

    void setup() {
        // nothing yet
    }

}

endif`

I get :

/Users/myUserName/.platformio/packages/framework-arduinoespressif32@3.20009.0/libraries/SD_MMC/src/SD_MMC.h:21:10: fatal error: FS.h: No such file or directory

even adding: #include "FS.h" it still get this error and could not go further

lewisxhe commented 3 days ago

Post your platfromio.ini

richonguzman commented 3 days ago

[env:ttgo_t_deck_plus] framework = arduino monitor_speed = 115200 lib_ldf_mode = deep+ platform = espressif32 @ 6.3.1 board_build.partitions = huge_app.csv monitor_filters = esp32_exception_decoder board = esp32-s3-devkitc-1 board_build.mcu = esp32s3 build_flags = ${common.build_flags} -Werror -Wall ${common.usb_flags} -D TTGO_T_DECK_PLUS -D BOARD_HAS_PSRAM -D HAS_SX1262 -D GPS_BAUDRATE=38400 -D HAS_TFT -D USER_SETUP_LOADED -D ST7789_DRIVER -D TFT_WIDTH=240 -D TFT_HEIGHT=320 -D TFT_RGB_ORDER=TFT_BGR -D TFT_INVERSION_ON -D TFT_MISO=38 -D TFT_MOSI=41 -D TFT_SCLK=40 -D TFT_CS=12 -D TFT_DC=11 -D TFT_RST=-1 -D TFT_BUSY=-1 -D TFT_BL=42 -D TFT_BACKLIGHT_ON=1 -D TOUCH_CS=-1 -D LOAD_GLCD -D LOAD_FONT2 -D LOAD_FONT4 -D LOAD_FONT6 -D LOAD_FONT7 -D LOAD_FONT8 -D SPI_FREQUENCY=40000000 -D SPI_READ_FREQUENCY=16000000 lib_deps = adafruit/Adafruit BusIO @ 1.16.1 adafruit/Adafruit Unified Sensor @ 1.1.14 adafruit/Adafruit BME280 Library @ 2.2.4 adafruit/Adafruit BMP280 Library @ 2.6.8 adafruit/Adafruit BME680 Library @ 2.0.4 bblanchon/ArduinoJson @ 6.21.3 h2zero/NimBLE-Arduino @ 1.4.1 jgromes/RadioLib @ 6.6.0 mathieucarbou/AsyncTCP @ 3.2.5 mathieucarbou/ESPAsyncWebServer @ 3.2.3 mikalhart/TinyGPSPlus @ 1.0.3 paulstoffregen/Time @ 1.6.1 peterus/esp-logger @ 1.0.0 shaggydog/OneButton @ 1.5.0 bodmer/TFT_eSPI @ 2.5.43

lewisxhe commented 3 days ago

Yours is too complicated, I added a simple playback example

lewisxhe commented 3 days ago

You can try adding this in lib_deps = esphome/ESP32-audioI2S@2.0.6

richonguzman commented 3 days ago

You can try adding this in lib_deps = esphome/ESP32-audioI2S@2.0.6

added "esphome/ESP32-audioI2S @ 2.0.6" in lib_deps (and deleted the other from "/lib")

compiled just to test without adding any more code than before and same:

"In file included from /Users/ricardoguzman/.platformio/packages/framework-arduinoespressif32@3.20009.0/libraries/SD_MMC/src/SD_MMC.cpp:16: /Users/ricardoguzman/.platformio/packages/framework-arduinoespressif32@3.20009.0/libraries/SD_MMC/src/SD_MMC.h:21:10: fatal error: FS.h: No such file or directory"

include "FS.h"

      ^~~~~~

compilation terminated. Compiling .pio/build/ttgo_t_deck_plus/lib735/SPIFFS/SPIFFS.cpp.o *** [.pio/build/ttgo_t_deck_plus/libabd/SD_MMC/SD_MMC.cpp.o] Error 1

lewisxhe commented 3 days ago

It seems that there is a problem with the platformio index and it cannot find the correct dependencies.

There is no problem running it alone

richonguzman commented 3 days ago

It seems that there is a problem with the platformio index and it cannot find the correct dependencies.

There is no problem running it alone

how could I add this "alone"??

lewisxhe commented 3 days ago

In my example, it is normal https://github.com/Xinyuan-LilyGO/T-Deck/commit/7aa23db0230ce803f3efe6043ed15ad7d1eeb431

I was wondering why this avatar looks so familiar, it turns out to be you again. Hahahaha

I just tested it in your project, please fork a fork, comment out the following header file, and it can be compiled normally. This must be caused by a problem with the reference of platformio

image

richonguzman commented 3 days ago

In my example, it is normal 7aa23db

I was wondering why this avatar looks so familiar, it turns out to be you again. Hahahaha

I just tested it in your project, please fork a fork, comment out the following header file, and it can be compiled normally. This must be caused by a problem with the reference of platformio

image

sorry to push so much lately but I'm willing to make lots of upgrades for this!!! 😃

so: 1) library import on platformio.ini is now : esphome/ESP32-audioI2S @ 2.0.7 2) edited the library without "SD_MMC.h" and others. 3) have to add "es7210" folder from T-Deck main to my own /lib

now it can be added a mp3 and plays:

but I have 2 issues: 1) is the quality of the mp3 defined as a minimum to be listened fine? 2) when the board finishes playing the audio it make a noise when it stops

lewisxhe commented 3 days ago
  1. By looking at the source code, we can see that the volume can be set to 0~21 https://github.com/Xinyuan-LilyGO/T-Deck/blob/7aa23db0230ce803f3efe6043ed15ad7d1eeb431/lib/ESP32-audioI2S/src/Audio.cpp#L4515
  2. What does it mean when you make a sound when you stop? How do you run it?
richonguzman commented 3 days ago
  1. What does it mean when you make a sound when you stop? How do you run it?

void playMP3(const String& filename) { bool findMp3 = false; findMp3 = audio.connecttoFS(SPIFFS, filename.c_str()); if (findMp3) { audio.setVolume(21); while (audio.isRunning()) { audio.loop(); // delay(3); } /*audio.setVolume(0); delay(10); audio.stopSong(); delay(50);*/ //audio.stop(); } }

non of this posible added mods allow me to play a mp3 and avoid the 0,5sec crack sound when play stops

lewisxhe commented 2 days ago

I didn't notice any popping sounds when I ran it. Does this have anything to do with the audio file?