How do I clear audio buffer?!?!

I can't figure out how to clear audio buffer. An i tried serial.flush it wont work.

Is there any other way?

Which "audio buffer" ?

I can't explain here is the begining of the code. I have more than one file that i want to play in seperate times. The first one plays fine, but the next ones, is slow and not smooth.

I think it's becous the buffer fills up. Or something like that.

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.");
  Audio.begin(88200, 100);

}
void loop() {
  show_tft();
  File audioFile = SD.open("zdravo.wav");
  while (audioFile.available()) {
    audioFile.read(buffer, sizeof(buffer));
    Audio.prepare(buffer, M, volume);
    Audio.write(buffer, M);

  }
  audioFile.close();

  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);
      File myFile = SD.open("P01TXT~2.TXT");
      if (myFile) {
        while (myFile.available()) {
          tft.write(myFile.read());
        }
      }
       
      audioFile.close();
 
      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();
      char y = ' ';
      while (y == ' ') {

        char customKey = customKeypad.getKey();
        if (customKey) {
          y = customKey;
          Serial.print(y);
          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);

            }
            
            goto bailout1;
          }
            Audio.begin(88200, 100);

          if (y == 'A') {
            myFile.close();
            tft.fillScreen(BLACK);
            tft.setCursor((tft.width() - 36) / 24, (tft.height() * 1) / 4);
            tft.println("Vas odgovor nije tacan");
            tft.println("");
            tft.println("Tacan odgovor je pod C");
           
            File audioFile = SD.open("FAIL.WAV");
            while (audioFile.available()) {
              Serial.print("Radi");
              audioFile.read(buffer, sizeof(buffer));
              Audio.prepare(buffer, M, volume);
              Audio.write(buffer, M);
            }

            audioFile.close();

            File audioFile2 = SD.open("podc.wav");
            while (audioFile2.available()) {
              Serial.print("Radi");
              audioFile2.read(buffer, sizeof(buffer));
              Audio.prepare(buffer, M, volume);
              Audio.write(buffer, M);

            }
            audioFile.close();

            NeTacniOdgovori = NeTacniOdgovori + 1;
          }
          if (y == 'B') {
            myFile.close();
            tft.fillScreen(BLACK);
            tft.setCursor((tft.width() - 36) / 24, (tft.height() * 1) / 4);
            tft.println("Vas odgovor nije tacan");
            tft.println("");
            tft.println("Tacan odgovor je pod C");

            File audioFile = SD.open("fail.wav");
            while (audioFile.available()) {
              Serial.print("Radi");
              audioFile.read(buffer, sizeof(buffer));
              Audio.prepare(buffer, M, volume);
              Audio.write(buffer, M);
            }
            audioFile.close();

            File audioFile2  = SD.open("podc.wav");
            while (audioFile2.available()) {
              Serial.print("Radi");
              audioFile2.read(buffer, sizeof(buffer));
              Audio.prepare(buffer, M, volume);
              Audio.write(buffer, M);

            }
            audioFile.close();
            NeTacniOdgovori = NeTacniOdgovori + 1;
          }
          if (y == 'C') {
            myFile.close();
            tft.fillScreen(BLACK);
            tft.setCursor((tft.width() - 36) / 24, (tft.height() * 1) / 4);
            tft.println("Vas odgovor je tacan");


            File audioFile = SD.open("tacno1.wav");
            while (audioFile.available()) {
              Serial.print("Radi");
              audioFile.read(buffer, sizeof(buffer));
              Audio.prepare(buffer, M, volume);
              Audio.write(buffer, M);

            }
          }


          File audioFile2 = SD.open("tacno.wav");
          while (audioFile2.available()) {
            Serial.print("Radi");
            audioFile2.read(buffer, sizeof(buffer));
            Audio.prepare(buffer, M, volume);
            Audio.write(buffer, M);

          }
          TacniOdgovori = TacniOdgovori + 1;
        }
        if (y == 'D') {
          myFile.close();
          tft.fillScreen(BLACK);
          tft.setCursor((tft.width() - 36) / 24, (tft.height() * 1) / 4);
          tft.println("Vas odgovor nije tacan");
          tft.println("");
          tft.println("Tacan odgovor je pod C");

          File audioFile = SD.open("fail.wav");
          while (audioFile.available()) {
            Serial.print("Radi");
            audioFile.read(buffer, sizeof(buffer));
            Audio.prepare(buffer, M, volume);
            Audio.write(buffer, M);
          }
          audioFile.close();
          File audioFile2  = SD.open("podc.wav");
          while (audioFile2.available()) {
            Serial.print("Radi");
            audioFile2.read(buffer, sizeof(buffer));
            Audio.prepare(buffer, M, volume);
            Audio.write(buffer, M);

          }
          audioFile.close();

          NeTacniOdgovori = NeTacniOdgovori + 1;
        }
      }
    }

What was wrong with your original thread on this subject?
Did you get too impatient waiting for an answer?

For anyone interested, the full code is attached in this thread:-
(All 112KB of it.)
Problem with paying multiple audio