AudioZero and SdFat

Does anyone have any examples of code where I can use SdFat to query the SD card and play one of the files on the card using an Arduino Zero? I'm using SdFat so I can get long filenames instead of 8.3 file names. The construct of a "File" is ambiguous when using SdFat so I'm not sure what to pass AudioZero.play() which requires a type "File".

Even understanding if its possible to use SdFat and SD at the same time would help my problem. If SdFat is in the equation File is ambiguous . And it looks like I need a type File to pass to AudioZero.play().

The construct of a "File" is ambiguous when using SdFat

Hmmm. No, it isn't. It is quite straightforward. If you have having problems, POST YOUR CODE!

#include <SD.h>
#include <AudioZero.h>

#include <LiquidCrystal_I2C.h>
#include<SPI.h>

#include <FreeStack.h>
#include <SdFat.h>
SdFat sdfat;
SdFile file;
SdFile dirFile;

// Number of files found.
uint16_t n = 0;

// Max of ten files since files are selected with a single digit.
const uint16_t nMax = 10;

// Position of file’s directory entry.
uint16_t dirIndex[nMax];
String fullnames[200];
String smallnames[200];
#define I2C_ADDR 0x3F
LiquidCrystal_I2C lcd(I2C_ADDR, 2, 1, 0, 4, 5, 6, 7);

//------------------------------------------------------------------------------
void setup() {
lcd.begin(16, 2);//16 columns 2 rows for 1602A
lcd.setBacklightPin(3, POSITIVE);
//lcd.setBacklight(HIGH); // NOTE: You can turn the backlight off by setting it to LOW instead of HIGH
lcd.setBacklight(HIGH);
lcd.clear(); // clean screen and sets cursor to (0,0)

Serial.begin(9600);
while (!Serial) {}
delay(1000);

if (!sdfat.begin(4, SD_SCK_HZ(F_CPU/3))) {
sdfat.initErrorHalt();
}

// List files in root directory.
if (!dirFile.open("/", O_READ)) {
sdfat.errorHalt(“open root failed”);
}
char fbuffer[13];
while (n < nMax && file.openNext(&dirFile, O_READ)) {

// Skip directories and hidden files.
if (!file.isSubDir() && !file.isHidden()) {

// Save dirIndex of file in directory.

dirIndex[n] = file.dirIndex();
String strName = getFilename(file);
fullnames[n] = strName;
n++;

}
file.close();

Serial.println(fullnames[0]);
Serial.println(fullnames[1]);
Serial.println(fullnames[2]);

// so AudioZero.Play is expecting a type File which fails while SdFat is loaded

AudioZero.begin(1*44100);
File myFile = SD.open(“s-basic.wav”);
AudioZero.play(myFile);

/*
What I’d like to do is pass in the Sdfat file filename to AudioZero.play() but how do I do that?

AudioZero.play(file.name()); ???

*/
lcd.setCursor(0, 0);
lcd.print(fullnames[1]);
lcd.setCursor(0, 1);
lcd.print(fullnames[1]);

}

What I'd like to do is pass in the Sdfat file filename to AudioZero.play() but how do I do that?

You made an array of all the names.

AudioZero.play(fullnames[7]); // Play the 8th file...

You cannot use AudioZero.play(fullnames[7]) because play() is expecting type "File" not type "String" hence my problem. This produces no matching function for call to 'AudioZeroClass::play(String&)'

      File fileEight = SD.open(fullnames[7].c_str());
      AudioZero.play(fileEight);

Nope, that's the other problem. If include Sdfat I cannot delcare a type File. I get an error saying File is ambiguous as per my original message at the beginning of this post.

You haven’t posted your compiler errors verbatim - that’s the first step.

The SdFat library doesn't have a File type. It has a FatFile type. You'd need to modify the AudioZero class to take a FatFile. That might be trivial, or it might not.

I think I have a plan... and I'm half way through it.. will share on github when finished.

So this is my cunning plan. I created an external library using SdFat to pass back the longnames to a String Array > Then in the main ino file I used SD.h to create an array of the 8.3 file names. So that means I have the fullname but can also declare a type File for AudioZero to use with the 8.3 names....booommmm..

So far I have both SdFat and SD.h creating those 2 arrays..

Years later and a little wiser I fixed this without having a convoluted method. I changed the AudioZero Library to support SdFat