earlephilhower / ESP8266Audio

Arduino library to play MOD, WAV, FLAC, MIDI, RTTTL, MP3, and AAC files on I2S DACs or with a software emulated delta-sigma DAC on the ESP8266 and ESP32
GNU General Public License v3.0
1.99k stars 433 forks source link

EspressIf Esp32-Wroom-32D - High pitched whisling noise #614

Closed thehamzan6 closed 1 year ago

thehamzan6 commented 1 year ago

Did anyone try to get this library to work on playing WAV audio files from an SD card on esp32-wroom-32d.

esp32-devkitC-v4-pinout

According to this, the diagram shows that the internal DAC is on pin 25 and 26, in which I am using pin 25. If I connect the speaker directly to pin25 and ground, it makes a high pitched whisling sound that hurts the ears.

Switching to a 1-T circuit as described on the github repository read me, it just amplifies the high pitched noise (speaker to 5v instead of 3.3).

Attached is my code:

#include "SPI.h"
#include "FS.h"
#include "SD.h"
#include "AudioFileSourceSD.h"
#include "AudioGeneratorWAV.h"
#include "AudioOutputI2SNoDAC.h"
#include "AudioFileSourceID3.h"

#define SD_CS 5

AudioGeneratorWAV *wav;
AudioFileSourceSD *file;
AudioOutputI2SNoDAC *out;
AudioFileSourceID3 *id3;

void setup()
{
  // SD
  pinMode(SD_CS,OUTPUT);
  if (!SD.begin(SD_CS)) {
    Serial.print("SD init fail.");
  };

  //ESP8266Audio
    file = new AudioFileSourceSD;
    file->open("/insanity.wav");
    id3 = new AudioFileSourceID3(file);
    out = new AudioOutputI2SNoDAC();
    //out->SetBitsPerSample(8);
    //out->SetOutputModeMono(true);
    //out->SetChannels(2);
    wav = new AudioGeneratorWAV();
    wav->begin(id3, out);
    Serial.print(wav->isRunning());
}

void loop()
{}

I would like to mention that the WAV file is 8-bits, 32khz