Simple I2S sketch produces no sound after restart #1907
-
Hello, First of all thanks for this library, it's quite useful and easy to use. I've got a Nano ESP32 (ESP32-S3, with Arduino) connected to a MAX98357A, itself connected to the speakers of an old laptop. I tested this library with the following code (a simple sine wave to I2S): #include "AudioTools.h"
AudioInfo info(44100, 2, 16);
SineWaveGenerator<int16_t> sineWave(32000);
GeneratedSoundStream<int16_t> in(sineWave);
I2SStream i2s;
StreamCopy copier(i2s, in);
void setup(void) {
Serial.begin(115200);
delay(5000);
AudioLogger::instance().begin(Serial, AudioLogger::Warning);
auto config = i2s.defaultConfig(TX_MODE);
config.copyFrom(info);
if (i2s.begin(config)) {
Serial.println("I2S started successfully");
} else {
Serial.println("I2S failed to start!");
}
in.begin(info);
sineWave.begin(info, N_B4);
Serial.println("Setup Complete");
}
void loop() {
copier.copy();
} It works correctly (no error message, I can hear some sound) when I upload the sketch from the Arduino IDE. However, when I press the RST button of the ESP32 or when I unplug/plug the USB cable, there is no sound anymore even though no error is displayed ( It only works again when I first upload the I2S Simple Tone example sketch from the Arduino I2S library, and then upload the previous sketch. It also works when I upload the previous sketch several times in a row, but stops working as soon as I press the RST button of the ESP32 or when I unplug/plug the USB cable. My guess is that it's an error with I2S that is not properly initialized. Have you encountered this before? If no, I can directly use the I2S Arduino library, but I want to see first if I can use audio-tools as it's much easier. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
No, that does not make any sense: Rebooting and resetting of the AudioKit with a regular ESP32 (which uses the same API) has always been working w/o issues. I rather tend to think that it might be a hardware issue: did you try e.g. to connect the SD pin to 3.3V ? You can check if you can reproduce the issue also with the Arduino ESP32 I2S API... |
Beta Was this translation helpful? Give feedback.
-
Why don't you use your first example and just replace the I2SStream with I2SClass ? If you keep the pins the same, it should be
|
Beta Was this translation helpful? Give feedback.
No, that does not make any sense: Rebooting and resetting of the AudioKit with a regular ESP32 (which uses the same API) has always been working w/o issues.
I rather tend to think that it might be a hardware issue: did you try e.g. to connect the SD pin to 3.3V ?
Or maybe you use an ESP32 Arduino core version that does not support theS3 properly: The actual version is 3.1.1.
You can check if you can reproduce the issue also with the Arduino ESP32 I2S API...