Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1635
    Anonymous
    Inactive

    So im trying to set the device up so that i can dump a ton of music on an sd, turn the arduino on and have everything work nicely.

    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???

    A much easier question, I want to create a txt (more precisely a .csv, comer separated volume) file that sits on the sd card and acts as a playlist, to start with i plan to dump all the (truncated)file names on the sd into the playlist. however i cant figure out how to get the file name. Ive been looking at the  opennext.ino and fgets.ino examples in the sdfat folder, but in one you know the file name and the other sends it straight to an output buffer. how can i get the unknown file name into a char*???
    (instead  of naming my files track001 etc i put a couple of test tracks into a character string array, then you can call the array number or the track name, not heaps of use, but then you know roughly what all the files are, tho this uses allot of memory if its stored on the flash with the program)

    #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.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.