Hi there,
I have an audio sketch perfectly playing 4 wav files to mix them but when I'm doing files edition on the SD the player does nothing, then, after a while, is only able to play one file at once.
I think the SD card is busy but I don't figure out how to make it free for multiple audio files reading. I thought it was enough to close the file opened by SD.open.
In the sketch below, everything is doing fine until I uncomment the SD.open line in the loop section.
Thanks for your help !
I have an audio sketch perfectly playing 4 wav files to mix them but when I'm doing files edition on the SD the player does nothing, then, after a while, is only able to play one file at once.
I think the SD card is busy but I don't figure out how to make it free for multiple audio files reading. I thought it was enough to close the file opened by SD.open.
In the sketch below, everything is doing fine until I uncomment the SD.open line in the loop section.
Thanks for your help !
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioPlaySdWav playSdWav4; //xy=82,315
AudioPlaySdWav playSdWav3; //xy=86,232
AudioPlaySdWav playSdWav2; //xy=112,151
AudioPlaySdWav playSdWav1; //xy=140,79
AudioMixer4 mixer2; //xy=296,267
AudioMixer4 mixer1; //xy=312,153
AudioInputI2S i2s2; //xy=353,355
AudioMixer4 mixer3; //xy=490,220
AudioAnalyzePeak peak1; //xy=567,355
AudioOutputI2S i2s1; //xy=672,218
AudioConnection patchCord1(playSdWav4, 0, mixer2, 2);
AudioConnection patchCord2(playSdWav4, 1, mixer2, 3);
AudioConnection patchCord3(playSdWav3, 0, mixer2, 0);
AudioConnection patchCord4(playSdWav3, 1, mixer2, 1);
AudioConnection patchCord5(playSdWav2, 0, mixer1, 2);
AudioConnection patchCord6(playSdWav2, 1, mixer1, 3);
AudioConnection patchCord7(playSdWav1, 0, mixer1, 0);
AudioConnection patchCord8(playSdWav1, 1, mixer1, 1);
AudioConnection patchCord9(mixer2, 0, mixer3, 1);
AudioConnection patchCord10(mixer1, 0, mixer3, 0);
AudioConnection patchCord11(i2s2, 0, mixer3, 2);
AudioConnection patchCord12(i2s2, 0, peak1, 0);
AudioConnection patchCord13(mixer3, 0, i2s1, 0);
AudioConnection patchCord14(mixer3, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=226,461
// GUItool: end automatically generated code
const int chipSelect = 10;
int points = 0;
File fichier;
void setup() {
Serial.begin(9600);
AudioMemory(32);
sgtl5000_1.enable();
sgtl5000_1.volume(1);
sgtl5000_1.inputSelect(AUDIO_INPUT_MIC);
sgtl5000_1.micGain(0);
SD.begin(chipSelect);
if (!(SD.begin(chipSelect))) {
while (1) {
Serial.println("Unable to access the SD card");
delay(500);
}
}
mixer3.gain(0, 1);
mixer3.gain(1, 1);
mixer3.gain(2, 0);
mixer3.gain(3, 0);
delay(1000);
}
void joueTout() {
mixOFF();
if (playSdWav1.isPlaying() == false) {
playSdWav1.play("PIST1ET2.WAV");
delay(10); // wait for library to parse WAV info
}
if (playSdWav2.isPlaying() == false) {
playSdWav2.play("PIST3ET4.WAV");
delay(10); // wait for library to parse WAV info
}
if (playSdWav3.isPlaying() == false) {
playSdWav3.play("PIST5ET6.WAV");
delay(10); // wait for library to parse WAV info
}
if (playSdWav4.isPlaying() == false) {
playSdWav4.play("PIST7ET8.WAV");
delay(10); // wait for library to parse WAV info
}
}
void mixON() {
float volMix = 0.5;
mixer1.gain(0, volMix);
mixer1.gain(1, volMix);
mixer1.gain(2, volMix);
mixer1.gain(3, volMix);
mixer2.gain(0, volMix);
mixer2.gain(1, volMix);
mixer2.gain(2, volMix);
mixer2.gain(3, volMix);
}
void mixOFF() {
mixer1.gain(0, 0);
mixer1.gain(1, 0);
mixer1.gain(2, 0);
mixer1.gain(3, 0);
mixer2.gain(0, 0);
mixer2.gain(1, 0);
mixer2.gain(2, 0);
mixer2.gain(3, 0);
}
void loop() {
// fichier = SD.open("points.txt", FILE_WRITE); if (fichier) {fichier.println(points); fichier.close();}
joueTout(); mixON();
delay(35000);
}