Go Down

Topic: Problem with paying multiple audio (Read 320 times) previous topic - next topic

broda

May 06, 2016, 10:43 am Last Edit: May 06, 2016, 10:58 am by Broda
I have about 25 audi files. I only opet one at a time. When the first one opens it's fine it goes smoothly, but when the second opens the sound is not smooth It's like stoping ever half seconds. I don't know how to explain it better.

I'm running it on arduino due, my code is a bit long, becaus it's not only audio, but the audio is at the begining ithe first 100 lines. I'll upload it as a sketch.

Here are the problematic lines:

Code: [Select]
int volume = 1024;
const int M = 1024;
short buffer[M];
              
const int chipSelect = 52;
File myFile;
int TacniOdgovori = 0;
int NeTacniOdgovori = 0;
int x = 1;
File audioFile;
 File audioFile2;

void show_tft(void)
{
  tft.begin(identifier);
  tft.setRotation(3);
  tft.setCursor((tft.width() - 36) / 24, (tft.height() * 1) / 4);
  tft.setTextSize(2);
  tft.fillScreen(BLACK);
  tft.setTextColor(CYAN);
  tft.println("Zdravo ja sam Limeni.");
  tft.println("");
  tft.println("Ako zelite da zapocnete kviz pritisnite '#'");
  tft.println("");
  tft.println("Ako zelite da zpocnet anketu pritisnite '*'");
}

void setup() {
  Serial.begin(9600);

  Serial.print("Initializing SD card...");
  pinMode(SS, OUTPUT);

  if (!SD.begin(chipSelect)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
 char y = ' ';
  Audio.begin(88200, 100);
  
  }
void loop() {
  show_tft();
  File audioFile = SD.open("zdravo.wav");
      while (audioFile.available()) {
        Serial.print("Radi");
         audioFile.read(buffer, sizeof(buffer));
          Audio.prepare(buffer, M, volume);
     Audio.write(buffer, M);

        }  
        audioFile.close();
        buffer[M];  
        volume = 1024;
        delay(100);
  char y = ' ';
  while (y == ' ') {
        char customKey = customKeypad.getKey();
        if (customKey) {
          y = customKey;
          if (y == '#'){}
          if (y == '*'){
            goto bailoutB1;
          }
          
}
}
  bailoutQ:
   NeTacniOdgovori = 0;
   TacniOdgovori = 0;
  x = 1;
  for (int x = 1; x < 17; x = x + 1) {
    tft.setCursor((tft.width() - 36) / 24, (tft.height() * 1) / 4);
    tft.setTextSize(2);
    tft.fillScreen(BLACK);
    tft.setTextColor(CYAN);
    pinMode(SS, OUTPUT);
  
    if (x == 1) {
      bailout1:
      tft.setTextColor(CYAN);
    tft.setCursor((tft.width() - 36) / 24, (tft.height() * 1) / 4);
    tft.fillScreen(BLACK);
    char y = ' ';
      File myFile = SD.open("P01TXT~2.TXT");
      if (myFile) {
        while (myFile.available()) {
          tft.write(myFile.read());
        }
      }
    
    
      File audioFile = SD.open("jedan.wav");
      while (audioFile.available()) {
         audioFile.read(buffer, sizeof(buffer));
          Audio.prepare(buffer, M, volume);
     Audio.write(buffer, M);

        }
      
      audioFile.close();
      while (y == ' ') {
        char customKey = customKeypad.getKey();
        if (customKey) {
          y = customKey;
        if ( (y != 'A') && (y != 'B') && (y != 'C') && (y != 'D')){
          tft.fillScreen(BLACK);
          tft.setCursor((tft.width() - 36) / 24, (tft.height() * 1) / 4);
          tft.println("Pritisnuli ste pogresan taster!");
          tft.println("");
          tft.println(" Za unos odgovora koristite  'A' , 'B', 'C' ili 'D'");
        
      File audioFile = SD.open("pogresan.wav");
      while (audioFile.available()) {
        Serial.print("Radi");
         audioFile.read(buffer, sizeof(buffer));
          Audio.prepare(buffer, M, volume);
     Audio.write(buffer, M);

        }

AWOL

Code: [Select]
            }}}
        }}}

Don't you just hate it when that happens?

Please, reformat your code using the auto-format tool in the IDE and reattach it.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

broda

Code: [Select]
           }}}
        }}}

Don't you just hate it when that happens?

Please, reformat your code using the auto-format tool in the IDE and reattach it.
Actualy It's somehow easier for when it's like that. :)
Here I'll attach the formated.

broda


Go Up