Random Number Generator
Geo
Posts: 6
I need to somehow come up with a random number generator for a non-malicious purpose. What I'm trying to do is have my program cause an Alcorn McBride 8-Traxx player to play tracks at random based on other input events. Basically, a button push would trigger a play command, but I want to randomly pick what track is to be played. It's not possible to randomly play the tracks on the 8-Traxx box itself...all I can do is send serial strings to tell it what track numbers to play. My only other alternative would be to just call the files in a seemingly random order and hope nobody notices the pattern, which is highly likely as these sound files are quite short and there are not that many of them, and I want it to be truly random anyway.
0
Comments
This from the help file.
Num = RANDOM_NUMBER(1000) // 0 <= Num < 1000
Then use any of the stock sorts to create a random/unique list of numbers and go from there.
Hope that helps
If you want to play all the tracks in your list randomly and not have any tracks repeat until all tracks are played once then you might find the following code useful.
Compile, download, and then watch nShuffledPlaylist in the debugger. Every time you push button 1 you?ll see the playlist get shuffled.
I?m sure there are different and better ways to shuffle but this is the approach I?ve used in the past.
HTH
Thanks guys...these did the trick.