Help getting things right #1004
-
Hi, I have a Lilygo T-Display (ESP32 S3 model with no DAC pins). I need to play audio externally (all audio files are converted to .h files) - audio files are simply voices to number (for example, one.h just says the word "one") so, no high quality needs. Based on several searches, it seems this product may enable my board to output audio - if you have other suggestions, they are welcomed! So far (before spending money in the DAC/amplifier module), I started writing some code based on this example. Is this the right sample for my needs? Also, how to set the MAX98357A I2S pins (they are not using the traditional pins 25/26)? Anything I miss that someone can point me in the right direction? Thank you all!
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
The Wiki documentation is quite complete: I suggest that you read the chapter about external DACs You can also try if the output via PWM is good enough for your purpose. If you want to speak out any numbers you can also have a look at https://github.com/pschatzmann/arduino-simple-tts |
Beta Was this translation helpful? Give feedback.
-
I read the chapter (thanks). So, I assume the MAX98357A can be set for my available pins. Regarding the best example to start my tests, is this the right one? https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-stream/streams-memory_raw-i2s/streams-memory_raw-i2s.ino |
Beta Was this translation helpful? Give feedback.
-
You can also try if the output via PWM is good enough for your purpose. If you want to speak out any numbers you can also have a look at https://github.com/pschatzmann/arduino-simple-tts or any other TTS library |
Beta Was this translation helpful? Give feedback.
-
I got both (Simple-TTS and Memory_Raw-i2s) samples to work. However, how could I play different audio files according to the number count in the example below? As of now, it only plays the "one.h" file.
|
Beta Was this translation helpful? Give feedback.
-
I suggest that you give variables unique names: this will prevent you from stumbling over your own feet!
ps. don't forget to call begin() on the MemoryStream after it has completed to rewind it to the beginning if you want to play it again. #include "AudioTools.h"
#include "one.h"
#include "two.h"
#define I2S_WS 17 //11,10
#define I2S_BCK 21 //12,11
#define I2S_DOUT 16 // 13,12
AudioInfo info(22050, 1, 16);
I2SStream i2s; // Output to I2S
MemoryStream music1(one_raw, one_raw_len);
MemoryStream music2(two_raw, two_raw_len);
StreamCopy copier(i2s, music1); // copies sound into i2s
void setup() {
Serial.begin(115200);
AudioLogger::instance().begin(Serial, AudioLogger::Info);
auto config = i2s.defaultConfig(TX_MODE);
config.copyFrom(info);
config.i2s_format = I2S_LSB_FORMAT;
config.pin_bck = I2S_BCK; //14
config.pin_ws = I2S_WS; //15
config.pin_data = I2S_DOUT; //22
i2s.begin(config);
}
void restartNext(){
// determine next file to play
auto &new_source = (copier.getFrom() == &music1) ? music2 : music1;
// rewind to play from start
new_source.begin();
// switch copy source
copier.begin(i2s, new_source);
}
void loop() {
if (copier.copy()==0){
restartNext();
}
} |
Beta Was this translation helpful? Give feedback.
The Wiki documentation is quite complete: I suggest that you read the chapter about external DACs
You can also try if the output via PWM is good enough for your purpose. If you want to speak out any numbers you can also have a look at https://github.com/pschatzmann/arduino-simple-tts