Need help, new to this!!

tlung12

Member
Hi all, im trying to make a audio guestbook for my wedding next week. I have everything wired up correctly in the phone, and am stuck on the coding part. Using teensy 4.0 and arduino 1.8
Here is my code followed by the errors:


Code:
void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}/**
 * Audio Guestbook, Copyright (c) 2022 Playful Technology
 * 
 * Tested using a Teensy 4.0 with Teensy Audio Shield, although should work 
 * with minor modifications on other similar hardware
 * 
 * When handset is lifted, a pre-recorded greeting message is played, followed by a tone.
 * Then, recording starts, and continues until the handset is replaced.
 * Playback button allows all messages currently saved on SD card through earpiece 
 * 
 * Files are saved on SD card as 44.1kHz, 16-bit, mono signed integer RAW audio format
 * These can be loaded directly into Audacity ([url]https://www.audacityteam.org/[/url]). Or else, converted to WAV/MP3 format using SOX ([url]https://sourceforge.net/projects/sox/[/url])
 * 
 **/

// INCLUDES
// The default "sketchbook" location in which Arduino IDE installs libraries is:
// C:\Users\alast\Documents\Arduino
// However, the TeensyDuino installer installs libraries in:
// C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries
// To ensure the correct libraries are used when targetting Teensy platform in Arduino IDE, go File->Preferences and change the sketchbook location to avoid conflicts with Arduino libraries.
// When targetting Arduino boards, change it back again to default
#include <Bounce.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <TimeLib.h>

// DEFINES
// Define pins used by Teensy Audio Shield
#define SDCARD_CS_PIN    10
#define SDCARD_MOSI_PIN  7
#define SDCARD_SCK_PIN   14
// And those used for inputs
#define HOOK_PIN 0
#define PLAYBACK_BUTTON_PIN 1

// GLOBALS
// Audio initialisation code can be generated using the GUI interface at [url]https://www.pjrc.com/teensy/gui/[/url]
// Inputs
AudioSynthWaveform      waveform1; // To create the "beep" sfx
AudioInputI2S           i2s2; // I2S input from microphone on audio shield
AudioPlaySdRaw          playRaw1; // Play .RAW audio files saved on SD card
AudioPlaySdWav          playWav1; // Play 44.1kHz 16-bit PCM greeting WAV file
// Outputs
AudioRecordQueue         queue1; // Creating an audio buffer in memory before saving to SD
AudioMixer4              mixer; // Allows merging several inputs to same output
AudioOutputI2S           i2s1; // I2S interface to Speaker/Line Out on Audio shield
// Connections
AudioConnection patchCord1(waveform1, 0, mixer, 0); // wave to mixer 
AudioConnection patchCord2(playRaw1, 0, mixer, 1); // raw audio to mixer
AudioConnection patchCord3(playWav1, 0, mixer, 2); // wav file playback mixer
AudioConnection patchCord4(mixer, 0, i2s1, 0); // mixer output to speaker (L)
AudioConnection patchCord5(i2s2, 0, queue1, 0); // mic input to queue (L)
AudioControlSGTL5000     sgtl5000_1;

// Filename to save audio recording on SD card
char filename[15];
// The file object itself
File frec;

// Use long 40ms debounce time on hook switch
Bounce buttonRecord = Bounce(HOOK_PIN, 40);
Bounce buttonPlay = Bounce(PLAYBACK_BUTTON_PIN, 8);

// Keep track of current state of the device
enum Mode {Initialising, Ready, Prompting, Recording, Playing};
Mode mode = Mode::Initialising;

void setup() {

  // Note that Serial.begin() is not required for Teensy - 
  // by default it initialises serial communication at full USB speed
  // See [url]https://www.pjrc.com/teensy/td_serial.html[/url]
  // Serial.begin()
  Serial.println(__FILE__ __DATE__);
  
  // Configure the input pins
  pinMode(HOOK_PIN, INPUT_PULLUP);
  pinMode(PLAYBACK_BUTTON_PIN, INPUT_PULLUP);

  // Audio connections require memory, and the record queue
  // uses this memory to buffer incoming audio.
  AudioMemory(60);

  // Enable the audio shield, select input, and enable output
  sgtl5000_1.enable();
  // Define which input on the audio shield to use (AUDIO_INPUT_LINEIN / AUDIO_INPUT_MIC)
  sgtl5000_1.inputSelect(AUDIO_INPUT_MIC);
  sgtl5000_1.volume(0.5);

  // Play a beep to indicate system is online
  waveform1.begin(WAVEFORM_SINE);
  waveform1.frequency(440);
  waveform1.amplitude(0.9);
  wait(250);
  waveform1.amplitude(0);
  delay(1000);

  // Initialize the SD card
  SPI.setMOSI(SDCARD_MOSI_PIN);
  SPI.setSCK(SDCARD_SCK_PIN);
  if (!(SD.begin(SDCARD_CS_PIN))) {
    // stop here if no SD card, but print a message
    while (1) {
      Serial.println("Unable to access the SD card");
      delay(500);
    }
  }

  // Value in dB
  sgtl5000_1.micGain(15);

  // Synchronise the Time object used in the program code with the RTC time provider.
  // See [url]https://github.com/PaulStoffregen/Time[/url]
  setSyncProvider(getTeensy3Time);
  
  // Define a callback that will assign the correct datetime for any file system operations
  // (i.e. saving a new audio recording onto the SD card)
  FsDateTime::setCallback(dateTime);

  mode = Mode::Ready;
}

void loop() {
  // First, read the buttons
  buttonRecord.update();
  buttonPlay.update();

  switch(mode){
    case Mode::Ready:
      // Rising edge occurs when the handset is lifted
      if (buttonRecord.risingEdge()) {
        Serial.println("Handset lifted");
        mode = Mode::Prompting;
      }
      else if(buttonPlay.fallingEdge()) {
        playAllRecordings();
      }
      break;

    case Mode::Prompting:
      // Wait a second for users to put the handset to their ear
      wait(1000);
      // Play the greeting inviting them to record their message
      playWav1.play("greeting.wav");    
      // Wait until the  message has finished playing
      while (playWav1.isPlaying()) {
        // Check whether the handset is replaced
        buttonRecord.update();
        // Handset is replaced
        if(buttonRecord.fallingEdge()) {
          playWav1.stop();
          mode = Mode::Ready;
          return;
        }
      }
      // Debug message
      Serial.println("Starting Recording");
      // Play the tone sound effect
      waveform1.frequency(440);
      waveform1.amplitude(0.9);
      wait(250);
      waveform1.amplitude(0);
      // Start the recording function
      startRecording();
      break;

    case Mode::Recording:
      // Handset is replaced
      if(buttonRecord.fallingEdge()){
        // Debug log
        Serial.println("Stopping Recording");
        // Stop recording
        stopRecording();
        // Play audio tone to confirm recording has ended
        waveform1.frequency(523.25);
        waveform1.amplitude(0.9);
        wait(50);
        waveform1.amplitude(0);
        wait(50);
        waveform1.amplitude(0.9);
        wait(50);
        waveform1.amplitude(0);
      }
      else {
        continueRecording();
      }
      break;

    case Mode::Playing:
      break;  
  }   
}

void startRecording() {
  // Find the first available file number
  for (uint8_t i=0; i<9999; i++) {
    // Format the counter as a five-digit number with leading zeroes, followed by file extension
    snprintf(filename, 11, " %05d.RAW", i);
    // Create if does not exist, do not open existing, write, sync after write
    if (!SD.exists(filename)) {
      break;
    }
  }
  frec = SD.open(filename, FILE_WRITE);
  if(frec) {
    Serial.print("Recording to ");
    Serial.println(filename);
    queue1.begin();
    mode = Mode::Recording;
  }
  else {
    Serial.println("Couldn't open file to record!");
  }
}

void continueRecording() {
  // Check if there is data in the queue
  if (queue1.available() >= 2) {
    byte buffer[512];
    // Fetch 2 blocks from the audio library and copy
    // into a 512 byte buffer.  The Arduino SD library
    // is most efficient when full 512 byte sector size
    // writes are used.
    memcpy(buffer, queue1.readBuffer(), 256);
    queue1.freeBuffer();
    memcpy(buffer+256, queue1.readBuffer(), 256);
    queue1.freeBuffer();
    // Write all 512 bytes to the SD card
    frec.write(buffer, 512);
  }
}

void stopRecording() {
  // Stop adding any new data to the queue
  queue1.end();
  // Flush all existing remaining data from the queue
  while (queue1.available() > 0) {
    // Save to open file
    frec.write((byte*)queue1.readBuffer(), 256);
    queue1.freeBuffer();
  }
  // Close the file
  frec.close();
  mode = Mode::Ready;
}


void playAllRecordings() {
  // Recording files are saved in the root directory
  File dir = SD.open("/");
  
  while (true) {
    File entry =  dir.openNextFile();
    if (!entry) {
      // no more files
      entry.close();
      break;
    }

    int8_t len = strlen(entry.name());
    if (strstr(strlwr(entry.name() + (len - 4)), ".raw")) {
      Serial.print("Now playing ");
      Serial.println(entry.name());
      // Play a short beep before each message
      waveform1.amplitude(0.5);
      wait(250);
      waveform1.amplitude(0);
      // Play the file
      playRaw1.play(entry.name());
      mode = Mode::Playing;
    }
    entry.close();

    while (playRaw1.isPlaying()) {
      buttonPlay.update();
      buttonRecord.update();
      // Button is pressed again
      if(buttonPlay.risingEdge() || buttonRecord.fallingEdge()) {
        playRaw1.stop();
        mode = Mode::Ready;
        return;
      }   
    }
  }
  // All files have been played
  mode = Mode::Ready;
}

// Retrieve the current time from Teensy built-in RTC
time_t getTeensy3Time(){
  return Teensy3Clock.get();
}

// Callback to assign timestamps for file system operations
void dateTime(uint16_t* date, uint16_t* time, uint8_t* ms10) {

  // Return date using FS_DATE macro to format fields.
  *date = FS_DATE(year(), month(), day());

  // Return time using FS_TIME macro to format fields.
  *time = FS_TIME(hour(), minute(), second());

  // Return low time bits in units of 10 ms.
  *ms10 = second() & 1 ? 100 : 0;
}

// Non-blocking delay, which pauses execution of main program logic,
// but while still listening for input 
void wait(unsigned int milliseconds) {
  elapsedMillis msec=0;

  while (msec <= milliseconds) {
    buttonRecord.update();
    buttonPlay.update();
    if (buttonRecord.fallingEdge()) Serial.println("Button (pin 0) Press");
    if (buttonPlay.fallingEdge()) Serial.println("Button (pin 1) Press");
    if (buttonRecord.risingEdge()) Serial.println("Button (pin 0) Release");
    if (buttonPlay.risingEdge()) Serial.println("Button (pin 1) Release");
  }
}



Here is the errors: Im completely lost on what to do. Please help!!!


Arduino: 1.8.19 (Windows 10), TD: 1.56, Board: "Teensy 4.0, Serial, 600 MHz, Faster, US English"





















Code:
C:\Users\t_lun\Desktop\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Users\t_lun\Desktop\Arduino\hardware -hardware C:\Users\t_lun\AppData\Local\Arduino15\packages -tools C:\Users\t_lun\Desktop\Arduino\tools-builder -tools C:\Users\t_lun\Desktop\Arduino\hardware\tools\avr -tools C:\Users\t_lun\AppData\Local\Arduino15\packages -built-in-libraries C:\Users\t_lun\Desktop\Arduino\libraries -libraries C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\libraries -fqbn=teensy:avr:teensy40:usb=serial,speed=600,opt=o2std,keys=en-us -ide-version=10819 -build-path C:\Users\t_lun\AppData\Local\Temp\arduino_build_912611 -warnings=none -build-cache C:\Users\t_lun\AppData\Local\Temp\arduino_cache_280408 -verbose C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\sketch_jun04a\sketch_jun04a.ino

C:\Users\t_lun\Desktop\Arduino\arduino-builder -compile -logger=machine -hardware C:\Users\t_lun\Desktop\Arduino\hardware -hardware C:\Users\t_lun\AppData\Local\Arduino15\packages -tools C:\Users\t_lun\Desktop\Arduino\tools-builder -tools C:\Users\t_lun\Desktop\Arduino\hardware\tools\avr -tools C:\Users\t_lun\AppData\Local\Arduino15\packages -built-in-libraries C:\Users\t_lun\Desktop\Arduino\libraries -libraries C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\libraries -fqbn=teensy:avr:teensy40:usb=serial,speed=600,opt=o2std,keys=en-us -ide-version=10819 -build-path C:\Users\t_lun\AppData\Local\Temp\arduino_build_912611 -warnings=none -build-cache C:\Users\t_lun\AppData\Local\Temp\arduino_cache_280408 -verbose C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\sketch_jun04a\sketch_jun04a.ino

Using board 'teensy40' from platform in folder: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr

Using core 'teensy4' from platform in folder: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr

Detecting libraries used...

"C:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=156 -DARDUINO=10819 -DARDUINO_TEENSY40 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "C:\\Users\\t_lun\\AppData\\Local\\Temp\\arduino_build_912611\\sketch\\sketch_jun04a.ino.cpp" -o nul

Alternatives for Bounce.h: [Bounce]

ResolveLibrary(Bounce.h)

  -> candidates: [Bounce]

"C:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=156 -DARDUINO=10819 -DARDUINO_TEENSY40 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Bounce" "C:\\Users\\t_lun\\AppData\\Local\\Temp\\arduino_build_912611\\sketch\\sketch_jun04a.ino.cpp" -o nul

Alternatives for Audio.h: [Audio@1.3]

ResolveLibrary(Audio.h)

  -> candidates: [Audio@1.3]

"C:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=156 -DARDUINO=10819 -DARDUINO_TEENSY40 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Bounce" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Audio" "C:\\Users\\t_lun\\AppData\\Local\\Temp\\arduino_build_912611\\sketch\\sketch_jun04a.ino.cpp" -o nul

Alternatives for SPI.h: [SPI@1.0]

ResolveLibrary(SPI.h)

  -> candidates: [SPI@1.0]

"C:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=156 -DARDUINO=10819 -DARDUINO_TEENSY40 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Bounce" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Audio" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\SPI" "C:\\Users\\t_lun\\AppData\\Local\\Temp\\arduino_build_912611\\sketch\\sketch_jun04a.ino.cpp" -o nul

Alternatives for SD.h: [SD@1.2.4 SD@2.0.0]

ResolveLibrary(SD.h)

  -> candidates: [SD@1.2.4 SD@2.0.0]

"C:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=156 -DARDUINO=10819 -DARDUINO_TEENSY40 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Bounce" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Audio" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\SPI" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\SD\\src" "C:\\Users\\t_lun\\AppData\\Local\\Temp\\arduino_build_912611\\sketch\\sketch_jun04a.ino.cpp" -o nul

Alternatives for SdFat.h: [SdFat@2.1.0]

ResolveLibrary(SdFat.h)

  -> candidates: [SdFat@2.1.0]

"C:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=156 -DARDUINO=10819 -DARDUINO_TEENSY40 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Bounce" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Audio" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\SPI" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\SD\\src" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\SdFat\\src" "C:\\Users\\t_lun\\AppData\\Local\\Temp\\arduino_build_912611\\sketch\\sketch_jun04a.ino.cpp" -o nul

Alternatives for SerialFlash.h: []In file included from C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\Audio/Audio.h:129:0,

                 from C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\sketch_jun04a\sketch_jun04a.ino:32:



ResolveLibrary(SerialFlash.h)C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\Audio/play_serialflash_raw.h:33:25: fatal error: SerialFlash.h: No such file or directory



  -> candidates: []compilation terminated.



Multiple libraries were found for "SD.h"

 Used: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\SD

 Not used: C:\Users\t_lun\Desktop\Arduino\libraries\SD

Using library Bounce in folder: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\Bounce (legacy)

Using library Audio at version 1.3 in folder: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\Audio 

Using library SPI at version 1.0 in folder: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\SPI 

Using library SD at version 2.0.0 in folder: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\SD 

Using library SdFat at version 2.1.0 in folder: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\SdFat 

Error compiling for board Teensy 4.0.
 
Last edited by a moderator:
Capture.jpg Here is a picture of the error is that helps
 
Only this pops as an Error?

ResolveLibrary(SerialFlash.h)C:\Users\t_lun\Deskto p\Arduino\hardware\teensy\avr\libraries\Audio/play_serialflash_raw.h:33:25: fatal error: SerialFlash.h: No such file or directory

what build environment - what version of TeensyDuino?
 
Building that p#1 code in IDE here gives errors on BOUNCE and other?
Code:
Compiling sketch...
"C:\\T_Drive\\arduino-1.8.19\\hardware\\teensy/../tools/precompile_helper" "C:\\T_Drive\\arduino-1.8.19\\hardware\\teensy\\avr/cores/teensy4" "R:\\Temp\\arduino_build_439378" "C:\\T_Drive\\arduino-1.8.19\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -x c++-header -O2 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=157 -DARDUINO=10819 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\T_Drive\\arduino-1.8.19\\hardware\\teensy\\avr/cores/teensy4" "R:\\Temp\\arduino_build_439378/pch/Arduino.h" -o "R:\\Temp\\arduino_build_439378/pch/Arduino.h.gch"
Using previously compiled file: R:\Temp\arduino_build_439378\pch\Arduino.h.gch
"C:\\T_Drive\\arduino-1.8.19\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -c -O2 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=157 -DARDUINO=10819 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IR:\\Temp\\arduino_build_439378/pch" "-IC:\\T_Drive\\arduino-1.8.19\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\T_Drive\\arduino-1.8.19\\hardware\\teensy\\avr\\libraries\\Bounce" "-IC:\\T_Drive\\arduino-1.8.19\\hardware\\teensy\\avr\\libraries\\Audio" "-IC:\\T_Drive\\arduino-1.8.19\\hardware\\teensy\\avr\\libraries\\SPI" "-IC:\\T_Drive\\arduino-1.8.19\\hardware\\teensy\\avr\\libraries\\SD\\src" "-IC:\\T_Drive\\arduino-1.8.19\\hardware\\teensy\\avr\\libraries\\SdFat\\src" "-IC:\\T_Drive\\arduino-1.8.19\\hardware\\teensy\\avr\\libraries\\SerialFlash" "-IC:\\T_Drive\\arduino-1.8.19\\hardware\\teensy\\avr\\libraries\\Wire" "-IC:\\T_Drive\\tCode\\libraries\\Time" "R:\\Temp\\arduino_build_439378\\sketch\\sketch_jun04a.ino.cpp" -o "R:\\Temp\\arduino_build_439378\\sketch\\sketch_jun04a.ino.cpp.o"
sketch_jun04a:1: error: expected constructor, destructor, or type conversion before 'Guestbook'
  * Audio Guestbook, Copyright (c) 2022 Playful Technology
          ^
sketch_jun04a:63: error: 'Bounce' does not name a type
 Bounce buttonRecord = Bounce(HOOK_PIN, 40);
 ^
sketch_jun04a:64: error: 'Bounce' does not name a type
 Bounce buttonPlay = Bounce(PLAYBACK_BUTTON_PIN, 8);
 ^
sketch_jun04a: In function 'void loop()':
sketch_jun04a:127: error: 'buttonRecord' was not declared in this scope
   buttonRecord.update();
   ^
sketch_jun04a:128: error: 'buttonPlay' was not declared in this scope
   buttonPlay.update();
   ^
sketch_jun04a:130: warning: enumeration value 'Initialising' not handled in switch 
   switch(mode){
         ^
sketch_jun04a: In function 'void playAllRecordings()':
R:\Temp\arduino_modified_sketch_112013\sketch_jun04a.ino:263:36: warning: invalid conversion from 'const char*' to 'char*' [-fpermissive]
     if (strstr(strlwr(entry.name() + (len - 4)), ".raw")) {
                                    ^
In file included from c:\t_drive\arduino-1.8.19\hardware\tools\arm\arm-none-eabi\include\stdlib.h:11:0,
                 from C:\T_Drive\arduino-1.8.19\hardware\teensy\avr\cores\teensy4/WProgram.h:34,
                 from R:\Temp\arduino_build_439378\pch\Arduino.h:6:
c:\t_drive\arduino-1.8.19\hardware\tools\arm\arm-none-eabi\include\string.h:150:7: note:   initializing argument 1 of 'char* strlwr(char*)'
 char *_EXFUN(strlwr,(char *));
       ^
sketch_jun04a:277: error: 'buttonPlay' was not declared in this scope
       buttonPlay.update();
       ^
sketch_jun04a:278: error: 'buttonRecord' was not declared in this scope
       buttonRecord.update();
       ^
sketch_jun04a: In function 'void wait(unsigned int)':
sketch_jun04a:315: error: 'buttonRecord' was not declared in this scope
     buttonRecord.update();
     ^
sketch_jun04a:316: error: 'buttonPlay' was not declared in this scope
     buttonPlay.update();
     ^
Multiple libraries were found for "TimeLib.h"
 Used: C:\T_Drive\tCode\libraries\Time
 Not used: C:\T_Drive\arduino-1.8.19\hardware\teensy\avr\libraries\Time
Multiple libraries were found for "SD.h"
 Used: C:\T_Drive\arduino-1.8.19\hardware\teensy\avr\libraries\SD
 Not used: C:\T_Drive\arduino-1.8.19\libraries\SD
Using library Bounce in folder: C:\T_Drive\arduino-1.8.19\hardware\teensy\avr\libraries\Bounce (legacy)
Using library Audio at version 1.3 in folder: C:\T_Drive\arduino-1.8.19\hardware\teensy\avr\libraries\Audio 
Using library SPI at version 1.0 in folder: C:\T_Drive\arduino-1.8.19\hardware\teensy\avr\libraries\SPI 
Using library SD at version 2.0.0 in folder: C:\T_Drive\arduino-1.8.19\hardware\teensy\avr\libraries\SD 
Using library SdFat at version 2.1.2 in folder: C:\T_Drive\arduino-1.8.19\hardware\teensy\avr\libraries\SdFat 
Using library SerialFlash at version 0.5 in folder: C:\T_Drive\arduino-1.8.19\hardware\teensy\avr\libraries\SerialFlash 
Using library Wire at version 1.0 in folder: C:\T_Drive\arduino-1.8.19\hardware\teensy\avr\libraries\Wire 
Using library Time at version 1.6.1 in folder: C:\T_Drive\tCode\libraries\Time 
expected constructor, destructor, or type conversion before 'Guestbook'
 
Building that p#1 code in IDE here gives errors on BOUNCE and other?
Code:
Compiling sketch...
"C:\\T_Drive\\arduino-1.8.19\\hardware\\teensy/../tools/precompile_helper" "C:\\T_Drive\\arduino-1.8.19\\hardware\\teensy\\avr/cores/teensy4" "R:\\Temp\\arduino_build_439378" "C:\\T_Drive\\arduino-1.8.19\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -x c++-header -O2 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=157 -DARDUINO=10819 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\T_Drive\\arduino-1.8.19\\hardware\\teensy\\avr/cores/teensy4" "R:\\Temp\\arduino_build_439378/pch/Arduino.h" -o "R:\\Temp\\arduino_build_439378/pch/Arduino.h.gch"
Using previously compiled file: R:\Temp\arduino_build_439378\pch\Arduino.h.gch
"C:\\T_Drive\\arduino-1.8.19\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -c -O2 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=157 -DARDUINO=10819 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IR:\\Temp\\arduino_build_439378/pch" "-IC:\\T_Drive\\arduino-1.8.19\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\T_Drive\\arduino-1.8.19\\hardware\\teensy\\avr\\libraries\\Bounce" "-IC:\\T_Drive\\arduino-1.8.19\\hardware\\teensy\\avr\\libraries\\Audio" "-IC:\\T_Drive\\arduino-1.8.19\\hardware\\teensy\\avr\\libraries\\SPI" "-IC:\\T_Drive\\arduino-1.8.19\\hardware\\teensy\\avr\\libraries\\SD\\src" "-IC:\\T_Drive\\arduino-1.8.19\\hardware\\teensy\\avr\\libraries\\SdFat\\src" "-IC:\\T_Drive\\arduino-1.8.19\\hardware\\teensy\\avr\\libraries\\SerialFlash" "-IC:\\T_Drive\\arduino-1.8.19\\hardware\\teensy\\avr\\libraries\\Wire" "-IC:\\T_Drive\\tCode\\libraries\\Time" "R:\\Temp\\arduino_build_439378\\sketch\\sketch_jun04a.ino.cpp" -o "R:\\Temp\\arduino_build_439378\\sketch\\sketch_jun04a.ino.cpp.o"
sketch_jun04a:1: error: expected constructor, destructor, or type conversion before 'Guestbook'
  * Audio Guestbook, Copyright (c) 2022 Playful Technology
          ^
sketch_jun04a:63: error: 'Bounce' does not name a type
 Bounce buttonRecord = Bounce(HOOK_PIN, 40);
 ^
sketch_jun04a:64: error: 'Bounce' does not name a type
 Bounce buttonPlay = Bounce(PLAYBACK_BUTTON_PIN, 8);
 ^
sketch_jun04a: In function 'void loop()':
sketch_jun04a:127: error: 'buttonRecord' was not declared in this scope
   buttonRecord.update();
   ^
sketch_jun04a:128: error: 'buttonPlay' was not declared in this scope
   buttonPlay.update();
   ^
sketch_jun04a:130: warning: enumeration value 'Initialising' not handled in switch 
   switch(mode){
         ^
sketch_jun04a: In function 'void playAllRecordings()':
R:\Temp\arduino_modified_sketch_112013\sketch_jun04a.ino:263:36: warning: invalid conversion from 'const char*' to 'char*' [-fpermissive]
     if (strstr(strlwr(entry.name() + (len - 4)), ".raw")) {
                                    ^
In file included from c:\t_drive\arduino-1.8.19\hardware\tools\arm\arm-none-eabi\include\stdlib.h:11:0,
                 from C:\T_Drive\arduino-1.8.19\hardware\teensy\avr\cores\teensy4/WProgram.h:34,
                 from R:\Temp\arduino_build_439378\pch\Arduino.h:6:
c:\t_drive\arduino-1.8.19\hardware\tools\arm\arm-none-eabi\include\string.h:150:7: note:   initializing argument 1 of 'char* strlwr(char*)'
 char *_EXFUN(strlwr,(char *));
       ^
sketch_jun04a:277: error: 'buttonPlay' was not declared in this scope
       buttonPlay.update();
       ^
sketch_jun04a:278: error: 'buttonRecord' was not declared in this scope
       buttonRecord.update();
       ^
sketch_jun04a: In function 'void wait(unsigned int)':
sketch_jun04a:315: error: 'buttonRecord' was not declared in this scope
     buttonRecord.update();
     ^
sketch_jun04a:316: error: 'buttonPlay' was not declared in this scope
     buttonPlay.update();
     ^
Multiple libraries were found for "TimeLib.h"
 Used: C:\T_Drive\tCode\libraries\Time
 Not used: C:\T_Drive\arduino-1.8.19\hardware\teensy\avr\libraries\Time
Multiple libraries were found for "SD.h"
 Used: C:\T_Drive\arduino-1.8.19\hardware\teensy\avr\libraries\SD
 Not used: C:\T_Drive\arduino-1.8.19\libraries\SD
Using library Bounce in folder: C:\T_Drive\arduino-1.8.19\hardware\teensy\avr\libraries\Bounce (legacy)
Using library Audio at version 1.3 in folder: C:\T_Drive\arduino-1.8.19\hardware\teensy\avr\libraries\Audio 
Using library SPI at version 1.0 in folder: C:\T_Drive\arduino-1.8.19\hardware\teensy\avr\libraries\SPI 
Using library SD at version 2.0.0 in folder: C:\T_Drive\arduino-1.8.19\hardware\teensy\avr\libraries\SD 
Using library SdFat at version 2.1.2 in folder: C:\T_Drive\arduino-1.8.19\hardware\teensy\avr\libraries\SdFat 
Using library SerialFlash at version 0.5 in folder: C:\T_Drive\arduino-1.8.19\hardware\teensy\avr\libraries\SerialFlash 
Using library Wire at version 1.0 in folder: C:\T_Drive\arduino-1.8.19\hardware\teensy\avr\libraries\Wire 
Using library Time at version 1.6.1 in folder: C:\T_Drive\tCode\libraries\Time 
expected constructor, destructor, or type conversion before 'Guestbook'

yes sir it does. im lost to what im doing wrong
 
Posted p#1 code had this extraneous duplicate content - in removing it the errors in p#5 were created.

When I got back to the sketch hitting "Ctrl+T" the "Auto Format" pointed out the problem in formatting leading to the missing "/*"

Code:
void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}[B][COLOR="#FF0000"]/**[/COLOR][/B]

Correcting that the posted code compiled here - for a T_4.1:

This is what is in the IDE sketch:
Code:
/* * Audio Guestbook, Copyright (c) 2022 Playful Technology

  Tested using a Teensy 4.0 with Teensy Audio Shield, although should work
  with minor modifications on other similar hardware

  When handset is lifted, a pre - recorded greeting message is played, followed by a tone.
  Then, recording starts, and continues until the handset is replaced.
  Playback button allows all messages currently saved on SD card through earpiece

  Files are saved on SD card as 44.1kHz, 16 - bit, mono signed integer RAW audio format
  These can be loaded directly into Audacity (https://www.audacityteam.org/). Or else, converted to WAV/MP3 format using SOX (https://sourceforge.net/projects/sox/)

    * */

// INCLUDES
// The default "sketchbook" location in which Arduino IDE installs libraries is:
// C:\Users\alast\Documents\Arduino
// However, the TeensyDuino installer installs libraries in:
// C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries
// To ensure the correct libraries are used when targetting Teensy platform in Arduino IDE, go File->Preferences and change the sketchbook location to avoid conflicts with Arduino libraries.
// When targetting Arduino boards, change it back again to default
#include <Bounce.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <TimeLib.h>

// DEFINES
// Define pins used by Teensy Audio Shield
#define SDCARD_CS_PIN    10
#define SDCARD_MOSI_PIN  7
#define SDCARD_SCK_PIN   14
// And those used for inputs
#define HOOK_PIN 0
#define PLAYBACK_BUTTON_PIN 1

// GLOBALS
// Audio initialisation code can be generated using the GUI interface at https://www.pjrc.com/teensy/gui/
// Inputs
AudioSynthWaveform      waveform1; // To create the "beep" sfx
AudioInputI2S           i2s2; // I2S input from microphone on audio shield
AudioPlaySdRaw          playRaw1; // Play .RAW audio files saved on SD card
AudioPlaySdWav          playWav1; // Play 44.1kHz 16-bit PCM greeting WAV file
// Outputs
AudioRecordQueue         queue1; // Creating an audio buffer in memory before saving to SD
AudioMixer4              mixer; // Allows merging several inputs to same output
AudioOutputI2S           i2s1; // I2S interface to Speaker/Line Out on Audio shield
// Connections
AudioConnection patchCord1(waveform1, 0, mixer, 0); // wave to mixer
AudioConnection patchCord2(playRaw1, 0, mixer, 1); // raw audio to mixer
AudioConnection patchCord3(playWav1, 0, mixer, 2); // wav file playback mixer
AudioConnection patchCord4(mixer, 0, i2s1, 0); // mixer output to speaker (L)
AudioConnection patchCord5(i2s2, 0, queue1, 0); // mic input to queue (L)
AudioControlSGTL5000     sgtl5000_1;

// Filename to save audio recording on SD card
char filename[15];
// The file object itself
File frec;

// Use long 40ms debounce time on hook switch
Bounce buttonRecord = Bounce(HOOK_PIN, 40);
Bounce buttonPlay = Bounce(PLAYBACK_BUTTON_PIN, 8);

// Keep track of current state of the device
enum Mode {Initialising, Ready, Prompting, Recording, Playing};
Mode mode = Mode::Initialising;

void setup() {

  // Note that Serial.begin() is not required for Teensy -
  // by default it initialises serial communication at full USB speed
  // See https://www.pjrc.com/teensy/td_serial.html
  // Serial.begin()
  Serial.println(__FILE__ __DATE__);

  // Configure the input pins
  pinMode(HOOK_PIN, INPUT_PULLUP);
  pinMode(PLAYBACK_BUTTON_PIN, INPUT_PULLUP);

  // Audio connections require memory, and the record queue
  // uses this memory to buffer incoming audio.
  AudioMemory(60);

  // Enable the audio shield, select input, and enable output
  sgtl5000_1.enable();
  // Define which input on the audio shield to use (AUDIO_INPUT_LINEIN / AUDIO_INPUT_MIC)
  sgtl5000_1.inputSelect(AUDIO_INPUT_MIC);
  sgtl5000_1.volume(0.5);

  // Play a beep to indicate system is online
  waveform1.begin(WAVEFORM_SINE);
  waveform1.frequency(440);
  waveform1.amplitude(0.9);
  wait(250);
  waveform1.amplitude(0);
  delay(1000);

  // Initialize the SD card
  SPI.setMOSI(SDCARD_MOSI_PIN);
  SPI.setSCK(SDCARD_SCK_PIN);
  if (!(SD.begin(SDCARD_CS_PIN))) {
    // stop here if no SD card, but print a message
    while (1) {
      Serial.println("Unable to access the SD card");
      delay(500);
    }
  }

  // Value in dB
  sgtl5000_1.micGain(15);

  // Synchronise the Time object used in the program code with the RTC time provider.
  // See https://github.com/PaulStoffregen/Time
  setSyncProvider(getTeensy3Time);

  // Define a callback that will assign the correct datetime for any file system operations
  // (i.e. saving a new audio recording onto the SD card)
  FsDateTime::setCallback(dateTime);

  mode = Mode::Ready;
}

void loop() {
  // First, read the buttons
  buttonRecord.update();
  buttonPlay.update();

  switch (mode) {
    case Mode::Ready:
      // Rising edge occurs when the handset is lifted
      if (buttonRecord.risingEdge()) {
        Serial.println("Handset lifted");
        mode = Mode::Prompting;
      }
      else if (buttonPlay.fallingEdge()) {
        playAllRecordings();
      }
      break;

    case Mode::Prompting:
      // Wait a second for users to put the handset to their ear
      wait(1000);
      // Play the greeting inviting them to record their message
      playWav1.play("greeting.wav");
      // Wait until the  message has finished playing
      while (playWav1.isPlaying()) {
        // Check whether the handset is replaced
        buttonRecord.update();
        // Handset is replaced
        if (buttonRecord.fallingEdge()) {
          playWav1.stop();
          mode = Mode::Ready;
          return;
        }
      }
      // Debug message
      Serial.println("Starting Recording");
      // Play the tone sound effect
      waveform1.frequency(440);
      waveform1.amplitude(0.9);
      wait(250);
      waveform1.amplitude(0);
      // Start the recording function
      startRecording();
      break;

    case Mode::Recording:
      // Handset is replaced
      if (buttonRecord.fallingEdge()) {
        // Debug log
        Serial.println("Stopping Recording");
        // Stop recording
        stopRecording();
        // Play audio tone to confirm recording has ended
        waveform1.frequency(523.25);
        waveform1.amplitude(0.9);
        wait(50);
        waveform1.amplitude(0);
        wait(50);
        waveform1.amplitude(0.9);
        wait(50);
        waveform1.amplitude(0);
      }
      else {
        continueRecording();
      }
      break;

    case Mode::Playing:
      break;
  }
}

void startRecording() {
  // Find the first available file number
  for (uint8_t i = 0; i < 9999; i++) {
    // Format the counter as a five-digit number with leading zeroes, followed by file extension
    snprintf(filename, 11, " %05d.RAW", i);
    // Create if does not exist, do not open existing, write, sync after write
    if (!SD.exists(filename)) {
      break;
    }
  }
  frec = SD.open(filename, FILE_WRITE);
  if (frec) {
    Serial.print("Recording to ");
    Serial.println(filename);
    queue1.begin();
    mode = Mode::Recording;
  }
  else {
    Serial.println("Couldn't open file to record!");
  }
}

void continueRecording() {
  // Check if there is data in the queue
  if (queue1.available() >= 2) {
    byte buffer[512];
    // Fetch 2 blocks from the audio library and copy
    // into a 512 byte buffer.  The Arduino SD library
    // is most efficient when full 512 byte sector size
    // writes are used.
    memcpy(buffer, queue1.readBuffer(), 256);
    queue1.freeBuffer();
    memcpy(buffer + 256, queue1.readBuffer(), 256);
    queue1.freeBuffer();
    // Write all 512 bytes to the SD card
    frec.write(buffer, 512);
  }
}

void stopRecording() {
  // Stop adding any new data to the queue
  queue1.end();
  // Flush all existing remaining data from the queue
  while (queue1.available() > 0) {
    // Save to open file
    frec.write((byte*)queue1.readBuffer(), 256);
    queue1.freeBuffer();
  }
  // Close the file
  frec.close();
  mode = Mode::Ready;
}


void playAllRecordings() {
  // Recording files are saved in the root directory
  File dir = SD.open("/");

  while (true) {
    File entry =  dir.openNextFile();
    if (!entry) {
      // no more files
      entry.close();
      break;
    }

    int8_t len = strlen(entry.name());
    if (strstr(strlwr(entry.name() + (len - 4)), ".raw")) {
      Serial.print("Now playing ");
      Serial.println(entry.name());
      // Play a short beep before each message
      waveform1.amplitude(0.5);
      wait(250);
      waveform1.amplitude(0);
      // Play the file
      playRaw1.play(entry.name());
      mode = Mode::Playing;
    }
    entry.close();

    while (playRaw1.isPlaying()) {
      buttonPlay.update();
      buttonRecord.update();
      // Button is pressed again
      if (buttonPlay.risingEdge() || buttonRecord.fallingEdge()) {
        playRaw1.stop();
        mode = Mode::Ready;
        return;
      }
    }
  }
  // All files have been played
  mode = Mode::Ready;
}

// Retrieve the current time from Teensy built-in RTC
time_t getTeensy3Time() {
  return Teensy3Clock.get();
}

// Callback to assign timestamps for file system operations
void dateTime(uint16_t* date, uint16_t* time, uint8_t* ms10) {

  // Return date using FS_DATE macro to format fields.
  date = FS_DATE(year(), month(), day());

  // Return time using FS_TIME macro to format fields.
  time = FS_TIME(hour(), minute(), second());

  // Return low time bits in units of 10 ms.
  ms10 = second() & 1 ? 100 : 0;
}

// Non-blocking delay, which pauses execution of main program logic,
// but while still listening for input
void wait(unsigned int milliseconds) {
  elapsedMillis msec = 0;

  while (msec <= milliseconds) {
    buttonRecord.update();
    buttonPlay.update();
    if (buttonRecord.fallingEdge()) Serial.println("Button (pin 0) Press");
    if (buttonPlay.fallingEdge()) Serial.println("Button (pin 1) Press");
    if (buttonRecord.risingEdge()) Serial.println("Button (pin 0) Release");
    if (buttonPlay.risingEdge()) Serial.println("Button (pin 1) Release");
  }
}
 
Posted p#1 code had this extraneous duplicate content - in removing it the errors in p#5 were created.

When I got back to the sketch hitting "Ctrl+T" the "Auto Format" pointed out the problem in formatting leading to the missing "/*"

Code:
void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}[B][COLOR="#FF0000"]/**[/COLOR][/B]

Correcting that the posted code compiled here - for a T_4.1:

This is what is in the IDE sketch:
Code:
/* * Audio Guestbook, Copyright (c) 2022 Playful Technology

  Tested using a Teensy 4.0 with Teensy Audio Shield, although should work
  with minor modifications on other similar hardware

  When handset is lifted, a pre - recorded greeting message is played, followed by a tone.
  Then, recording starts, and continues until the handset is replaced.
  Playback button allows all messages currently saved on SD card through earpiece

  Files are saved on SD card as 44.1kHz, 16 - bit, mono signed integer RAW audio format
  These can be loaded directly into Audacity (https://www.audacityteam.org/). Or else, converted to WAV/MP3 format using SOX (https://sourceforge.net/projects/sox/)

    * */

// INCLUDES
// The default "sketchbook" location in which Arduino IDE installs libraries is:
// C:\Users\alast\Documents\Arduino
// However, the TeensyDuino installer installs libraries in:
// C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries
// To ensure the correct libraries are used when targetting Teensy platform in Arduino IDE, go File->Preferences and change the sketchbook location to avoid conflicts with Arduino libraries.
// When targetting Arduino boards, change it back again to default
#include <Bounce.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <TimeLib.h>

// DEFINES
// Define pins used by Teensy Audio Shield
#define SDCARD_CS_PIN    10
#define SDCARD_MOSI_PIN  7
#define SDCARD_SCK_PIN   14
// And those used for inputs
#define HOOK_PIN 0
#define PLAYBACK_BUTTON_PIN 1

// GLOBALS
// Audio initialisation code can be generated using the GUI interface at https://www.pjrc.com/teensy/gui/
// Inputs
AudioSynthWaveform      waveform1; // To create the "beep" sfx
AudioInputI2S           i2s2; // I2S input from microphone on audio shield
AudioPlaySdRaw          playRaw1; // Play .RAW audio files saved on SD card
AudioPlaySdWav          playWav1; // Play 44.1kHz 16-bit PCM greeting WAV file
// Outputs
AudioRecordQueue         queue1; // Creating an audio buffer in memory before saving to SD
AudioMixer4              mixer; // Allows merging several inputs to same output
AudioOutputI2S           i2s1; // I2S interface to Speaker/Line Out on Audio shield
// Connections
AudioConnection patchCord1(waveform1, 0, mixer, 0); // wave to mixer
AudioConnection patchCord2(playRaw1, 0, mixer, 1); // raw audio to mixer
AudioConnection patchCord3(playWav1, 0, mixer, 2); // wav file playback mixer
AudioConnection patchCord4(mixer, 0, i2s1, 0); // mixer output to speaker (L)
AudioConnection patchCord5(i2s2, 0, queue1, 0); // mic input to queue (L)
AudioControlSGTL5000     sgtl5000_1;

// Filename to save audio recording on SD card
char filename[15];
// The file object itself
File frec;

// Use long 40ms debounce time on hook switch
Bounce buttonRecord = Bounce(HOOK_PIN, 40);
Bounce buttonPlay = Bounce(PLAYBACK_BUTTON_PIN, 8);

// Keep track of current state of the device
enum Mode {Initialising, Ready, Prompting, Recording, Playing};
Mode mode = Mode::Initialising;

void setup() {

  // Note that Serial.begin() is not required for Teensy -
  // by default it initialises serial communication at full USB speed
  // See https://www.pjrc.com/teensy/td_serial.html
  // Serial.begin()
  Serial.println(__FILE__ __DATE__);

  // Configure the input pins
  pinMode(HOOK_PIN, INPUT_PULLUP);
  pinMode(PLAYBACK_BUTTON_PIN, INPUT_PULLUP);

  // Audio connections require memory, and the record queue
  // uses this memory to buffer incoming audio.
  AudioMemory(60);

  // Enable the audio shield, select input, and enable output
  sgtl5000_1.enable();
  // Define which input on the audio shield to use (AUDIO_INPUT_LINEIN / AUDIO_INPUT_MIC)
  sgtl5000_1.inputSelect(AUDIO_INPUT_MIC);
  sgtl5000_1.volume(0.5);

  // Play a beep to indicate system is online
  waveform1.begin(WAVEFORM_SINE);
  waveform1.frequency(440);
  waveform1.amplitude(0.9);
  wait(250);
  waveform1.amplitude(0);
  delay(1000);

  // Initialize the SD card
  SPI.setMOSI(SDCARD_MOSI_PIN);
  SPI.setSCK(SDCARD_SCK_PIN);
  if (!(SD.begin(SDCARD_CS_PIN))) {
    // stop here if no SD card, but print a message
    while (1) {
      Serial.println("Unable to access the SD card");
      delay(500);
    }
  }

  // Value in dB
  sgtl5000_1.micGain(15);

  // Synchronise the Time object used in the program code with the RTC time provider.
  // See https://github.com/PaulStoffregen/Time
  setSyncProvider(getTeensy3Time);

  // Define a callback that will assign the correct datetime for any file system operations
  // (i.e. saving a new audio recording onto the SD card)
  FsDateTime::setCallback(dateTime);

  mode = Mode::Ready;
}

void loop() {
  // First, read the buttons
  buttonRecord.update();
  buttonPlay.update();

  switch (mode) {
    case Mode::Ready:
      // Rising edge occurs when the handset is lifted
      if (buttonRecord.risingEdge()) {
        Serial.println("Handset lifted");
        mode = Mode::Prompting;
      }
      else if (buttonPlay.fallingEdge()) {
        playAllRecordings();
      }
      break;

    case Mode::Prompting:
      // Wait a second for users to put the handset to their ear
      wait(1000);
      // Play the greeting inviting them to record their message
      playWav1.play("greeting.wav");
      // Wait until the  message has finished playing
      while (playWav1.isPlaying()) {
        // Check whether the handset is replaced
        buttonRecord.update();
        // Handset is replaced
        if (buttonRecord.fallingEdge()) {
          playWav1.stop();
          mode = Mode::Ready;
          return;
        }
      }
      // Debug message
      Serial.println("Starting Recording");
      // Play the tone sound effect
      waveform1.frequency(440);
      waveform1.amplitude(0.9);
      wait(250);
      waveform1.amplitude(0);
      // Start the recording function
      startRecording();
      break;

    case Mode::Recording:
      // Handset is replaced
      if (buttonRecord.fallingEdge()) {
        // Debug log
        Serial.println("Stopping Recording");
        // Stop recording
        stopRecording();
        // Play audio tone to confirm recording has ended
        waveform1.frequency(523.25);
        waveform1.amplitude(0.9);
        wait(50);
        waveform1.amplitude(0);
        wait(50);
        waveform1.amplitude(0.9);
        wait(50);
        waveform1.amplitude(0);
      }
      else {
        continueRecording();
      }
      break;

    case Mode::Playing:
      break;
  }
}

void startRecording() {
  // Find the first available file number
  for (uint8_t i = 0; i < 9999; i++) {
    // Format the counter as a five-digit number with leading zeroes, followed by file extension
    snprintf(filename, 11, " %05d.RAW", i);
    // Create if does not exist, do not open existing, write, sync after write
    if (!SD.exists(filename)) {
      break;
    }
  }
  frec = SD.open(filename, FILE_WRITE);
  if (frec) {
    Serial.print("Recording to ");
    Serial.println(filename);
    queue1.begin();
    mode = Mode::Recording;
  }
  else {
    Serial.println("Couldn't open file to record!");
  }
}

void continueRecording() {
  // Check if there is data in the queue
  if (queue1.available() >= 2) {
    byte buffer[512];
    // Fetch 2 blocks from the audio library and copy
    // into a 512 byte buffer.  The Arduino SD library
    // is most efficient when full 512 byte sector size
    // writes are used.
    memcpy(buffer, queue1.readBuffer(), 256);
    queue1.freeBuffer();
    memcpy(buffer + 256, queue1.readBuffer(), 256);
    queue1.freeBuffer();
    // Write all 512 bytes to the SD card
    frec.write(buffer, 512);
  }
}

void stopRecording() {
  // Stop adding any new data to the queue
  queue1.end();
  // Flush all existing remaining data from the queue
  while (queue1.available() > 0) {
    // Save to open file
    frec.write((byte*)queue1.readBuffer(), 256);
    queue1.freeBuffer();
  }
  // Close the file
  frec.close();
  mode = Mode::Ready;
}


void playAllRecordings() {
  // Recording files are saved in the root directory
  File dir = SD.open("/");

  while (true) {
    File entry =  dir.openNextFile();
    if (!entry) {
      // no more files
      entry.close();
      break;
    }

    int8_t len = strlen(entry.name());
    if (strstr(strlwr(entry.name() + (len - 4)), ".raw")) {
      Serial.print("Now playing ");
      Serial.println(entry.name());
      // Play a short beep before each message
      waveform1.amplitude(0.5);
      wait(250);
      waveform1.amplitude(0);
      // Play the file
      playRaw1.play(entry.name());
      mode = Mode::Playing;
    }
    entry.close();

    while (playRaw1.isPlaying()) {
      buttonPlay.update();
      buttonRecord.update();
      // Button is pressed again
      if (buttonPlay.risingEdge() || buttonRecord.fallingEdge()) {
        playRaw1.stop();
        mode = Mode::Ready;
        return;
      }
    }
  }
  // All files have been played
  mode = Mode::Ready;
}

// Retrieve the current time from Teensy built-in RTC
time_t getTeensy3Time() {
  return Teensy3Clock.get();
}

// Callback to assign timestamps for file system operations
void dateTime(uint16_t* date, uint16_t* time, uint8_t* ms10) {

  // Return date using FS_DATE macro to format fields.
  date = FS_DATE(year(), month(), day());

  // Return time using FS_TIME macro to format fields.
  time = FS_TIME(hour(), minute(), second());

  // Return low time bits in units of 10 ms.
  ms10 = second() & 1 ? 100 : 0;
}

// Non-blocking delay, which pauses execution of main program logic,
// but while still listening for input
void wait(unsigned int milliseconds) {
  elapsedMillis msec = 0;

  while (msec <= milliseconds) {
    buttonRecord.update();
    buttonPlay.update();
    if (buttonRecord.fallingEdge()) Serial.println("Button (pin 0) Press");
    if (buttonPlay.fallingEdge()) Serial.println("Button (pin 1) Press");
    if (buttonRecord.risingEdge()) Serial.println("Button (pin 0) Release");
    if (buttonPlay.risingEdge()) Serial.println("Button (pin 1) Release");
  }
}

Just copied and pasted that and tried to run it. Gave me the error code:


C:\Users\t_lun\Desktop\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Users\t_lun\Desktop\Arduino\hardware -hardware C:\Users\t_lun\AppData\Local\Arduino15\packages -tools C:\Users\t_lun\Desktop\Arduino\tools-builder -tools C:\Users\t_lun\Desktop\Arduino\hardware\tools\avr -tools C:\Users\t_lun\AppData\Local\Arduino15\packages -built-in-libraries C:\Users\t_lun\Desktop\Arduino\libraries -libraries C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\libraries -fqbn=teensy:avr:teensy40:usb=serial,speed=600,opt=o2std,keys=en-us -ide-version=10819 -build-path C:\Users\t_lun\AppData\Local\Temp\arduino_build_912611 -warnings=none -build-cache C:\Users\t_lun\AppData\Local\Temp\arduino_cache_280408 -verbose C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\sketch_jun04a\sketch_jun04a.ino
C:\Users\t_lun\Desktop\Arduino\arduino-builder -compile -logger=machine -hardware C:\Users\t_lun\Desktop\Arduino\hardware -hardware C:\Users\t_lun\AppData\Local\Arduino15\packages -tools C:\Users\t_lun\Desktop\Arduino\tools-builder -tools C:\Users\t_lun\Desktop\Arduino\hardware\tools\avr -tools C:\Users\t_lun\AppData\Local\Arduino15\packages -built-in-libraries C:\Users\t_lun\Desktop\Arduino\libraries -libraries C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\libraries -fqbn=teensy:avr:teensy40:usb=serial,speed=600,opt=o2std,keys=en-us -ide-version=10819 -build-path C:\Users\t_lun\AppData\Local\Temp\arduino_build_912611 -warnings=none -build-cache C:\Users\t_lun\AppData\Local\Temp\arduino_cache_280408 -verbose C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\sketch_jun04a\sketch_jun04a.ino
Using board 'teensy40' from platform in folder: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr
Using core 'teensy4' from platform in folder: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr
Detecting libraries used...
"C:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=156 -DARDUINO=10819 -DARDUINO_TEENSY40 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "C:\\Users\\t_lun\\AppData\\Local\\Temp\\arduino_build_912611\\sketch\\sketch_jun04a.ino.cpp" -o nul
Alternatives for Bounce.h: [Bounce]
ResolveLibrary(Bounce.h)
-> candidates: [Bounce]
"C:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=156 -DARDUINO=10819 -DARDUINO_TEENSY40 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Bounce" "C:\\Users\\t_lun\\AppData\\Local\\Temp\\arduino_build_912611\\sketch\\sketch_jun04a.ino.cpp" -o nul
Alternatives for Audio.h: [Audio@1.3]
ResolveLibrary(Audio.h)
-> candidates: [Audio@1.3]
"C:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=156 -DARDUINO=10819 -DARDUINO_TEENSY40 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Bounce" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Audio" "C:\\Users\\t_lun\\AppData\\Local\\Temp\\arduino_build_912611\\sketch\\sketch_jun04a.ino.cpp" -o nul
Alternatives for SPI.h: [SPI@1.0]
ResolveLibrary(SPI.h)
-> candidates: [SPI@1.0]
"C:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=156 -DARDUINO=10819 -DARDUINO_TEENSY40 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Bounce" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Audio" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\SPI" "C:\\Users\\t_lun\\AppData\\Local\\Temp\\arduino_build_912611\\sketch\\sketch_jun04a.ino.cpp" -o nul
Alternatives for SD.h: [SD@1.2.4 SD@2.0.0]
ResolveLibrary(SD.h)
-> candidates: [SD@1.2.4 SD@2.0.0]
"C:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=156 -DARDUINO=10819 -DARDUINO_TEENSY40 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Bounce" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Audio" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\SPI" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\SD\\src" "C:\\Users\\t_lun\\AppData\\Local\\Temp\\arduino_build_912611\\sketch\\sketch_jun04a.ino.cpp" -o nul
Alternatives for SdFat.h: [SdFat@2.1.0]
ResolveLibrary(SdFat.h)
-> candidates: [SdFat@2.1.0]
"C:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=156 -DARDUINO=10819 -DARDUINO_TEENSY40 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Bounce" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Audio" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\SPI" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\SD\\src" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\SdFat\\src" "C:\\Users\\t_lun\\AppData\\Local\\Temp\\arduino_build_912611\\sketch\\sketch_jun04a.ino.cpp" -o nul
Alternatives for SerialFlash.h: []
In file included from C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\Audio/Audio.h:129:0,
ResolveLibrary(SerialFlash.h)
-> candidates: [] from C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\sketch_jun04a\sketch_jun04a.ino:23:

Multiple libraries were found for "SD.h"
Used: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\SD
C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\Audio/play_serialflash_raw.h:33:25: fatal error: SerialFlash.h: No such file or directory
Not used: C:\Users\t_lun\Desktop\Arduino\libraries\SD
compilation terminated.
Using library Bounce in folder: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\Bounce (legacy)
Using library Audio at version 1.3 in folder: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\Audio
Using library SPI at version 1.0 in folder: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\SPI
Using library SD at version 2.0.0 in folder: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\SD
Using library SdFat at version 2.1.0 in folder: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\SdFat
Error compiling for board Teensy 4.0.
Capture.jpg
 
That shows the same error initially reported that did not show here:
Code:
Multiple libraries were found for "SD.h"
Used: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr \libraries\SD
C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr \libraries\Audio/play_serialflash_raw.h:33:25: fatal error: SerialFlash.h: No such file or directory
Not used: C:\Users\t_lun\Desktop\Arduino\libraries\SD
compilation terminated.

System here has that file no problem: "...\arduino-1.8.19\hardware\teensy\avr\libraries\SerialFlash\SerialFlash.h"

Seems something wrong with the install there to not have/find that file
 
That shows the same error initially reported that did not show here:
Code:
Multiple libraries were found for "SD.h"
Used: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr \libraries\SD
C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr \libraries\Audio/play_serialflash_raw.h:33:25: fatal error: SerialFlash.h: No such file or directory
Not used: C:\Users\t_lun\Desktop\Arduino\libraries\SD
compilation terminated.

System here has that file no problem: "...\arduino-1.8.19\hardware\teensy\avr\libraries\SerialFlash\SerialFlash.h"

Seems something wrong with the install there to not have/find that file

So what can i do to resolve it?
 
That shows the same error initially reported that did not show here:
Code:
Multiple libraries were found for "SD.h"
Used: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr \libraries\SD
C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr \libraries\Audio/play_serialflash_raw.h:33:25: fatal error: SerialFlash.h: No such file or directory
Not used: C:\Users\t_lun\Desktop\Arduino\libraries\SD
compilation terminated.

System here has that file no problem: "...\arduino-1.8.19\hardware\teensy\avr\libraries\SerialFlash\SerialFlash.h"

Seems something wrong with the install there to not have/find that file

Says this when I try to upload that:

Arduino: 1.8.19 (Windows 10), TD: 1.56, Board: "Teensy 4.0, Serial, 600 MHz, Faster, US English"

C:\Users\t_lun\Desktop\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Users\t_lun\Desktop\Arduino\hardware -hardware C:\Users\t_lun\AppData\Local\Arduino15\packages -tools C:\Users\t_lun\Desktop\Arduino\tools-builder -tools C:\Users\t_lun\Desktop\Arduino\hardware\tools\avr -tools C:\Users\t_lun\AppData\Local\Arduino15\packages -built-in-libraries C:\Users\t_lun\Desktop\Arduino\libraries -libraries C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\libraries -fqbn=teensy:avr:teensy40:usb=serial,speed=600,opt=o2std,keys=en-us -ide-version=10819 -build-path C:\Users\t_lun\AppData\Local\Temp\arduino_build_912611 -warnings=none -build-cache C:\Users\t_lun\AppData\Local\Temp\arduino_cache_280408 -verbose C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\sketch_jun04a\sketch_jun04a.ino

C:\Users\t_lun\Desktop\Arduino\arduino-builder -compile -logger=machine -hardware C:\Users\t_lun\Desktop\Arduino\hardware -hardware C:\Users\t_lun\AppData\Local\Arduino15\packages -tools C:\Users\t_lun\Desktop\Arduino\tools-builder -tools C:\Users\t_lun\Desktop\Arduino\hardware\tools\avr -tools C:\Users\t_lun\AppData\Local\Arduino15\packages -built-in-libraries C:\Users\t_lun\Desktop\Arduino\libraries -libraries C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\libraries -fqbn=teensy:avr:teensy40:usb=serial,speed=600,opt=o2std,keys=en-us -ide-version=10819 -build-path C:\Users\t_lun\AppData\Local\Temp\arduino_build_912611 -warnings=none -build-cache C:\Users\t_lun\AppData\Local\Temp\arduino_cache_280408 -verbose C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\sketch_jun04a\sketch_jun04a.ino

Using board 'teensy40' from platform in folder: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr

Using core 'teensy4' from platform in folder: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr

Detecting libraries used...

"C:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=156 -DARDUINO=10819 -DARDUINO_TEENSY40 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "C:\\Users\\t_lun\\AppData\\Local\\Temp\\arduino_build_912611\\sketch\\sketch_jun04a.ino.cpp" -o nul

Alternatives for Bounce.h: [Bounce]

ResolveLibrary(Bounce.h)

-> candidates: [Bounce]

"C:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=156 -DARDUINO=10819 -DARDUINO_TEENSY40 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Bounce" "C:\\Users\\t_lun\\AppData\\Local\\Temp\\arduino_build_912611\\sketch\\sketch_jun04a.ino.cpp" -o nul

Alternatives for Audio.h: [Audio@1.3]

ResolveLibrary(Audio.h)

-> candidates: [Audio@1.3]

"C:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=156 -DARDUINO=10819 -DARDUINO_TEENSY40 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Bounce" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Audio" "C:\\Users\\t_lun\\AppData\\Local\\Temp\\arduino_build_912611\\sketch\\sketch_jun04a.ino.cpp" -o nul

Alternatives for SPI.h: [SPI@1.0]

ResolveLibrary(SPI.h)

-> candidates: [SPI@1.0]

"C:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=156 -DARDUINO=10819 -DARDUINO_TEENSY40 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Bounce" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Audio" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\SPI" "C:\\Users\\t_lun\\AppData\\Local\\Temp\\arduino_build_912611\\sketch\\sketch_jun04a.ino.cpp" -o nul

Alternatives for SD.h: [SD@1.2.4 SD@2.0.0]

ResolveLibrary(SD.h)

-> candidates: [SD@1.2.4 SD@2.0.0]

"C:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=156 -DARDUINO=10819 -DARDUINO_TEENSY40 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Bounce" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Audio" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\SPI" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\SD\\src" "C:\\Users\\t_lun\\AppData\\Local\\Temp\\arduino_build_912611\\sketch\\sketch_jun04a.ino.cpp" -o nul

Alternatives for SdFat.h: [SdFat@2.1.0]

ResolveLibrary(SdFat.h)

-> candidates: [SdFat@2.1.0]

"C:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=156 -DARDUINO=10819 -DARDUINO_TEENSY40 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Bounce" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\Audio" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\SPI" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\SD\\src" "-IC:\\Users\\t_lun\\Desktop\\Arduino\\hardware\\teensy\\avr\\libraries\\SdFat\\src" "C:\\Users\\t_lun\\AppData\\Local\\Temp\\arduino_build_912611\\sketch\\sketch_jun04a.ino.cpp" -o nul

Alternatives for SerialFlash.h: []In file included from C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\Audio/Audio.h:129:0,



ResolveLibrary(SerialFlash.h) from C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\sketch_jun04a\sketch_jun04a.ino:23:



-> candidates: []

C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\Audio/play_serialflash_raw.h:33:25: fatal error: SerialFlash.h: No such file or directory

compilation terminated.

Multiple libraries were found for "SD.h"

Used: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\SD

Not used: C:\Users\t_lun\Desktop\Arduino\libraries\SD

Using library Bounce in folder: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\Bounce (legacy)

Using library Audio at version 1.3 in folder: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\Audio

Using library SPI at version 1.0 in folder: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\SPI

Using library SD at version 2.0.0 in folder: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\SD

Using library SdFat at version 2.1.0 in folder: C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\SdFat

Error compiling for board Teensy 4.0.

Invalid library found in C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\libraries: no headers files (.h) found in C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\libraries

Invalid library found in C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\sketch_jun04a: no headers files (.h) found in C:\Users\t_lun\Desktop\Arduino\hardware\teensy\avr\libraries\sketch_jun04a
 

What OS are you using means are you developing on Windows, Mac, Linux?? It's unlikely that anyone is going to watch a youtube video to figure out what went wrong. Suggest you uninstall everything and start over. Install Arduino 1.8.19, then install TeensyDuino. When installing TeensyDuino, install all of the libraries. After install is complete, build and run the blink example, then move on to more complex examples such as audio.
 
In case anyone reads through this thread and wants to know how to make this project work, I made this same project following the linked Youtube video above but found that the code was buggy, particularly around the switch/case statement. With help from others on this forum, I fixed the code and made it work reliably, my thread (read through it and you'll find the full (updated) code listing in one of my posts) is here https://forum.pjrc.com/threads/70553-Teensy-4-0-based-Audio-Guestbook
 
Back
Top