Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: SD card audio library to scan SD card for valid files and make a list?

  1. #1
    Junior Member
    Join Date
    Nov 2016
    Posts
    18

    SD card audio library to scan SD card for valid files and make a list?

    Hello,

    In my project, I'd like to play WAV files from the SD card, but first I would like to scan the SD card filesystem and find all the valid sound files on there and return a dynamically allocated list of strings with the valid file names, and then later on I might sort them alpha-numerically so i can play them in sequence based on name.

    Is this kind of functionality possible? I see from some older threads that it's not possible to use the audio SD lib at the same time without some modifications (which were never explicitly listed/mentioned, only vague indications of this issue).

    Is there an easier way to do what i'm trying to do?

    Thanks for any pointers..

    edit:
    If there's no easy way around this, i'll just have to get my users to hard-code their sound files more strictly, and i'll have to iterate through each potential named file (lets say, "SOUNDx.WAV" where x is 1->500) and make an array to indicate if that file is valid/present.

    Is there a way to check that a sound file exists without actually playing it directly?
    Last edited by kyranzor; 01-13-2019 at 06:48 PM.

  2. #2
    Senior Member
    Join Date
    Feb 2017
    Posts
    221
    Quote Originally Posted by kyranzor View Post
    Hello,
    Is there a way to check that a sound file exists without actually playing it directly?
    Take a look at the 'exists()' method in SD.h.

  3. #3
    Junior Member
    Join Date
    Nov 2016
    Posts
    18
    Oh it looks like the SD.h example library programs show how to print the contents of files/directories from Root of the SD card. that doesn't use the sdFat.h include? I am just about to test it, it seems like it should work. I'm already using SD.begin() and SD.exists() so I'm sure i can also look through the filesystem and find files with .WAV extension and add them to my list to play with the wavplayer object later on

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •