How to play random files and folders on a YX-5300

this is not a question, but I don't see it as a beginners tutorial, so I put it where it's most needed.

the code to play a specific file on a YX-5300:

sendCommand(CMD_PLAY_FOLDER_FILE, 0X0F060D);
// Play sound 0D from folder 06

the code to select a random file from among the 26 in directory 6:

filesPerFolder = 26;
sendCommand(CMD_PLAY_FOLDER_FILE, 0X0F0600 + random(filesPerFolder));
// Play a random sound from the 26 files in folder 06

note that you must make the file number 00: 0X0F0600

the code to play a particular file number from a random directory:

numberOfDirectories= 12;
sendCommand(CMD_PLAY_FOLDER_FILE, 0X0F000F + (random(numberOfDirectories)*256));
// Play sound 0F from a random selection among 12 directories

multiplying by 256 shifts the random number to the high byte of that pair of numbers, where the YX-5300 is looking for the folder number. once again, set that number to 00: 0X0F000F

worked on this all day yesterday, to no effect. got it working before breakfast today.

next hurdle: automate the (filesPerFolder) and (numberOfDirectories) process