You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So far it has been easy to loop over memory based streams by just setting setLoop(true). For files, I am relying on the different file implementations that are provided by different libraries. Nevertheless, I decided to provide a new FileLoop or the more generic FileLoopT classes. These classes have quite a few options:
You can define the loop count
You can define the total size in bytes to be provided
You can request to be notified about each rewind
Here is the example sketch that is endlessly playing the same file:
#include<SPI.h> #include<SD.h> #include"AudioTools.h" #include"AudioLibs/AudioKit.h" #include"AudioLibs/FileLoop.h" #include"AudioCodecs/CodecMP3Helix.h"constint chipSelect=PIN_AUDIO_KIT_SD_CARD_CS; AudioKitStream i2s; // final output of decoded stream EncodedAudioStream decoder(&i2s, new MP3DecoderHelix()); // Decoding stream FileLoop loopingFile; StreamCopy copier(decoder, loopingFile); voidsetup(){ Serial.begin(115200); AudioLogger::instance().begin(Serial, AudioLogger::Info); // setup audiokit before SD!auto config = i2s.defaultConfig(TX_MODE); config.sd_active = true; i2s.begin(config); // setup file SD.begin(chipSelect); loopingFile.setFile(SD.open("/ZZ Top/Unknown Album/Lowrider.mp3")); //loopingFile.setLoopCount(-1); // define loop count//audioFile.setStartPos(44); // restart from pos 44 for wav files//if ((audioFile.size()-44) % 1024!=0) audioFile.setSize((((audioFile.size()-44)/1024)+1)*1024+44);// setup I2S based on sampling rate provided by decoder decoder.begin(); } voidloop(){ copier.copy(); }
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
So far it has been easy to loop over memory based streams by just setting setLoop(true). For files, I am relying on the different file implementations that are provided by different libraries. Nevertheless, I decided to provide a new FileLoop or the more generic FileLoopT classes. These classes have quite a few options:
Here is the example sketch that is endlessly playing the same file:
Beta Was this translation helpful? Give feedback.
All reactions