Hello,
While doing some tests to play a wave file in a loop, I noticed that if I don't use a delay in my code it doesn't seem to work. Here the basic code that work:
Here's the code that work:
If I remove the delay(20) in loop() it stops working and I was wondering why... is it because it takes a while after the wav file has begun to play for isPlaying() to return true ?
While doing some tests to play a wave file in a loop, I noticed that if I don't use a delay in my code it doesn't seem to work. Here the basic code that work:
Here's the code that work:
Code:
#include <Audio.h>
#include <Wire.h>
#include <SD.h>
#include <SPI.h>
AudioPlaySdWav wav;
AudioOutputI2S dac;
AudioConnection c1(wav, 0, dac, 0);
AudioConnection c2(wav, 1, dac, 1);
AudioControlSGTL5000 audioShield;
void setup() {
AudioMemory(5);
audioShield.enable();
audioShield.volume(20);
SPI.setMOSI(7);
SPI.setSCK(14);
if (SD.begin(10)) {
wav.play("01_16M.WAV");
}
}
void loop() {
float vol = analogRead(15);
vol = vol / 10.24;
audioShield.volume(vol);
delay(20);
if (!wav.isPlaying())
{
wav.play("01_16M.WAV");
}
}
If I remove the delay(20) in loop() it stops working and I was wondering why... is it because it takes a while after the wav file has begun to play for isPlaying() to return true ?