Hi!!
I'm using this algorithm to shuffle an array of more than a 1000 int values, to create a random list of files to be played in an MP3 module. Each file number is a song, so I'd get everytime the module is powered a random list of files to be played.
Unfortunately my Attiny167 has little RAM, so the max array I can now use is 50 int values.
So is there a way to adapt this code to be able to get the max number of files in the sd card, let's say, 2500 files, and create an array with 50 random numbers from these 2.500?
When these 50 random songs were played, I can make it launch this function again and have 50 more random songs from the total amount.
Can it be done? Thanks!
void createRandomList() {
for (int v = 0; v < file_Count; v++) {
random_List[v] = v + 1;
}
for (int g = (file_Count - 1); g > 0; --g) {
int p = random(0, g + 1); // 0 ≤ p ≤ g
int t = random_List[g];
random_List[g] = random_List[p];
random_List[p] = t;
}
}