Home Forums Sparkfun MP3 Shield Library Support Forum SD file questions Reply To: SD file questions

#1645
Bill
Member

Firstly, the SD and SdFat libraries only deal with 8.3 length file names, my understanding is that this means i cannot truncate the file names down to this using the arduino because they cannot read them correctly. Is there a way around this???

Not that I know of, but that’s a better question for someone in the SDFatLib developer group.

however i cant figure out how to get the file name.

Ok, there’s a lot to this. First create an array to hold the filename:

char playNext[] = “trackxxx.mp3”

A file on the SD card is just a long array of bytes to an Arduino. Your CSV file is no exception. It will look something like:

track001.mp3,track002.mp3,track003.mp3

and so on. Each song filename takes up 13 bytes of the file.  So if you want to play song 3 on your list you would have to open the CSV file and move the read index to 3×13 position in the file. (there’s a seekSet function on the sdfatlib that does this) This should set the index position at the letter ‘t’ of track003.mp3. Then you need to read in the 12 bytes of the song filename stored at that index. Like this:

track.read(playNext, 12);

Then playNext should have the full filename from that position in the CSV file.