When using Input mixer, how do I ensure a looped sound continues after additional sounds are finished? #1500
-
I am using the input mixer function to mix 2 wav streams from an SD card, it works perfectly. However, one file is 2 seconds long and must loop indefinitely while another is about 30 secs long and only plays once. The problem I have is that, when the 30 second file is finished, the short file just stops. I want it to continue looping but cannot figure out how to do this. Any help would be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 14 replies
-
Just wrap the file in a FileLoop! |
Beta Was this translation helpful? Give feedback.
-
Thanks for the assist. I have used the FileLoop as suggested but it still isn't looping indefinitely. The problem appears to be that when the longer file finishes, the ESP32-S3 just hangs hence why it isn't continuing the looping. Because it hangs, I get no error message. Only a hard power cycle brings it to life again. This is the entire code in the sketch #include "AudioTools.h" //config for sd card reader File audioFile1; uint16_t sample_rate=44100; I2SStream i2s; // final output of decoded stream VolumeOutput out; void printMetaData(MetaDataType type, const char* str, int len){ FileLoop loopingFile; void setup() { Serial.begin(115200); AudioLogger::instance().begin(Serial, AudioLogger::Info); // setup output auto config = i2s.defaultConfig(TX_MODE); config.pin_ws = 14; SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI); SD.begin(SD_CS); vol.begin(config); // we need to provide the bits_per_sample and channels audioFile1 = SD.open("/audio/theme.wav"); loopingFile.setFile(SD.open("/audio/scanner.wav")); mixer.add(audioFile1,25); //theme } void loop() { } |
Beta Was this translation helpful? Give feedback.
-
Wouln't you need to wrap both files if you want to play endlessly ? |
Beta Was this translation helpful? Give feedback.
-
Good news; it fixed the hanging issue. The ESP32 no longer hangs. However, both audio streams stop when the longer one comes to an end. The looping one still doesn't continue to loop. |
Beta Was this translation helpful? Give feedback.
-
This is up to you now: You need to remove the ended input out of the mixer or just stop using the mixer if you want to continue with the output of the loop |
Beta Was this translation helpful? Give feedback.
Just wrap the file in a FileLoop!
and use the file loop as data source.