Mp3 Shuffle Function

Hi.

Using DfPlayer mini and this library I've managed to make a basic MP3 player with an arduino communicating with it using serial.

The problem I have is that it doesn't have a shuffle function, it only has a random function which leads to frequent repeats and also doesn't contain itself to one folder. It "randoms" the entire sd card or nothing.

My idea so far:

– Get number of tracks in folder.
– Load array using for loop where 1st song is in index 0
– Shuffle array.
– Play array.

The way my code works is that I continuously check for input in the main loop and then handle that input using functions. So in order not to stop this, I need to have a step in the loop check if the shuffle the player is "set" to shuffle play, then play the next index of the array when it stops playing.

I did try to code this (IMO really garbage code that I have no idea if is even sensible) and find a array randomiser using google, but suffice to say it didn't work at all. I really don't like arrays and I am struggling with this, could someone help?

I'm obviously happy to use simpler methods, but whatever the solution it has to be handled on the Arduino and play the next song in the way I described above.

Hope I've added what is needed, but if not let me know.

Touch here for the full post on the Arduino Apprentices tumblr

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s