logo elektroda
logo elektroda
X
logo elektroda

ESP32 AudioKit 2.2 - no sound when playing WAV from SD, code from ESP8266Audio

Said 36 0
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 21782733
    Said
    Level 2  
    Hey, I have an ESP32 AudioKit 2.2 and I want to play a WAV file through this, unfortunately it doesn't quite work for me. I have written code that loads the file from the SD card and using https://github.com/earlephilhower/ESP8266Audio, I run it. In the logs, I've done a start and an end and it takes as long as the song has (27 seconds). Unfortunately I can't hear anything in the headphones on the output. Can anyone help/answer how to improve this?

    I've also tried using https://github.com/schreibfaul1/ESP32-audioI2S, but in that case you can hear the buzz for about 27 seconds as well.

    My current code.

    #include <Arduino.h>
    #include <AudioFileSourceSD.h>
    #include <AudioGeneratorWAV.h>
    #include <AudioOutputI2S.h>
    #include <SD.h>

    #define SD_CS 13
    #define SD_MOSI 15
    #define SD_MISO 2
    #define SD_SCK 14

    AudioGeneratorWAV *wav;
    AudioFileSourceSD *file;
    AudioOutputI2S *out;

    void setup() {
    Serial.begin(115200);

    SPI.begin(SD_SCK, SD_MISO, SD_MOSI, SD_CS);

    if (!SD.begin(SD_CS)) {
    Serial.println("SD card error");
    return;
    }

    file = new AudioFileSourceSD("/squid.wav");
    out = new AudioOutputI2S(0, 0);
    out->setGain(1);
    out->begin();

    wav = new AudioGeneratorWAV();
    wav->begin(file, out);

    Serial.println("Beginning WAV playback...")
    }

    void loop() {
    if (wav->isRunning()) {
    wav->loop();
    } else {
    Serial.println("Playback complete");
    wav->stop();
    delay(1000);
    }
    }
    AI: On which audio output are you trying to listen to audio (jack, speaker, other)? Have you tried connecting other headphones or a speaker to rule out a hardware problem?
    I have tried earphones output, lineout and rout/lout.
    AI: What parameters does your WAV file have (sample rate, number of channels, bit resolution)? Have you perhaps tried with another WAV file with different parameters?
    16-bit, mono, 44100 Hz
  • ADVERTISEMENT
ADVERTISEMENT