Maximun Numbers of files on SD with Audio board??

charnjit

Well-known member
if we have Large numbers of files to access (.wav .txt .bmp .mid)
as i assign 256 for total num of files
Code:
const int MAX_FILES =  256;
  String  filenames[MAX_FILES]; // An array to hold up to ??? filenames
  String  Allfilenames[MAX_FILES];  // All Files (.wav/.txt/.mid/.jpeg)
what is maximum numbers of files T4 can access easily?? as it is good with 100 .wav file
what is maximum numbers of files names should be used in store in array?? as i write 256 in code
 
The array size doesn't really matter since String objects will use different amounts of memory depending on the length of their contents.
 
what is maximum numbers of files T4 can access easily?? as it is good with 100 .wav file
As far as I'm aware, there's no specific limit to the number of files you can put on your SD card, and no reason the Teensy would be unable to access any file. Obviously there are practical limits, depending on the likely file sizes, but you've said nothing about that so it's impossible to help there.
what is maximum numbers of files names should be used in store in array?? as i write 256 in code
That depends on what you're doing, and there's no "should" about that.

Say you're providing a huge number of WAV samples: typically you can't load very many at once even into PSRAM, though you could stream them from SD on demand. But that demand then comes (presumably) from a user. Are you going to present a list of 100,000 files to pick from? That would cause problems with RAM on the Teensy, but you surely wouldn't consider it as a sensible user interaction... You might put related files in folders, provide a way to navigate folders, and present only the files in the selected folder for selection. 47 folders, each with 47 sub-folders, each with 47 files, gives you 103,823 files.

Say further you're building a sampled drum machine. You might decide to have a kit of 32 sounds, each individually selected, so you only need to retain those 32 file names in RAM.

Personally, I would avoid having any rigid limit for ephemeral lists of file or folder names used only during user interaction. Using something like std::array, populated from a scan of the "current folder", is one approach, but you need to take care to ensure the array and file names are deleted when the user interaction is done, or you'll get a memory leak. As it is, you're likely to get a certain amount of heap fragmentation, which you'll need to keep an eye on.

Another approach would be to fix the number of filenames loaded (as you originally proposed), with the count decided by the use case, for example 20 file names because that's all that will fit on the screen at one time.

In one sketch I had 264 file names and part of their data filling most of the PSRAM - that was a 3-layer 88-note set of piano samples, which took 483MB of the SD card. The names only took up about 7kB of that space, though.
 
what is maximum numbers of files T4 can access easily??

Could you explain what you mean by "access easily"?

More context about your project would be good ideal. We can probably help much more if we're able to better understand what you're really wanting to accomplish.


As far as I'm aware, there's no specific limit to the number of files you can put on your SD card

With modern cards you're only limited by the total storage capacity.

But on small cards (usually 2GB or less) which use FAT16 format the root directory is allocated to a fixed set of sectors which imposes a limit to the number of files in the root directory. Those cards can still store an unlimited number of files (until all space is used) but only if stored in subdirectories.
 
Thank you ..

h4yn0nnym0u5e​

here no about loading files to ram .it is only about play a single .wav file at one time .
.
using TeensyVariablePlayback library , as i feel no latency between input & play .wav file. haviing 127 .wav files(each 1-2 second long)
1. will it be same for-
-- if i have 5000 mix of(.wav/.mid/.jpeg/.txt) on root of sd card.
or
(if near about 5000 files are divided into many folders , where each folder contain 16 .wav files) folders name[B01, B02, B03...... ,B150] file name in each folder [01.wav,02.wav,..........16.wav]
& will be used like
Code:
playSdWav1.play("B01/01.WAV");
?
2. may i write for sd card. to read & store All filenames to array ??
Code:
const int MAX_FILES =  5000;
  String  filenames[MAX_FILES]; // An array to hold up to ??? filenames
  String  Allfilenames[MAX_FILES];  // All Files (.wav/.txt/.mid/.jpeg)

" access easily " i means teensy play audio file as fast out of 5000 files on sd card, as fast i am getting 127 files on sd card.
 
Last edited:
OK, so your definition of “easily” here seems to mean “does the latency get worse as the number of files gets larger?”.

My recollection is that the answer is “yes”, which makes sense as the SdFat library has to do more work to find the file on the card. I think it was particularly noticeable for deeply nested sub-sub-folders. I can’t find the thread, and I don’t recall quantifying it properly, so you’ll have to do your own experiments to find out when the effect becomes unacceptable to you. If you do that, please report back, it’ll be helpful to many in the future.

Given your naming system, the character data alone is going to use 56,000 bytes, plus whatever the String overhead is for 5,000 objects, plus 20,000 bytes for the pointer array itself; and then, for some reason, you have two such arrays. That’s 152,000 bytes, which will indeed fit in the Teensy’s RAM but seems to me to be extremely wasteful, given the regular naming. But you may have very good reasons for doing it that way…
 
thank you ...h4yn0nnym0u5e.
tested files moves to folder... yes ,,, latency acceptable.. .... (seemed no changes in latency)
as you said ..
47 folders, each with 47 sub-folders, each with 47 files, gives you 103,823 files.
am happy to read 103,823 files. folder system will be better to manage files on sd card.
test for large number of files, i will test myself & report when i create files.
i will read deeply about array sizes.
thank you............. solved!
 
Back
Top