Thanks to Alex Blanc today – he worked through a lot of binary based maths with me to help answer a fairly challenging question… how to set up a user selected playlist so that it plays back in a random order.
The issue is actually very complex. Last year we developed a user selected playlist allowing the viewer to choose up to nine clips from a total of 24 on offer. If you consider that each viewer will make their own choice this is in itself a random playback engine. However, what if the viewer wants to select the first nine clips and then play those back randomly without repeating any clips? This is the challenge!
It turns out to be possible, but all of the available memory slots in DVDSP are used at some point in the scripting. We adapted the Jukebox scripts as our starting point and used the same basic script structure – i.e. a selection script, a playback control script, a pre- playback script to clear some of the registers, a script to clear all registers and a script with all of the ‘jump’ statements in it.
Alex’s mastery of the coding environment meant that no script was over long, and he also introduced me to the ‘XOR’ function… if you have never used any binary maths functions then this is a tricky one to explain. It basically looks at two given memory slots and compares the entries in them. If both are the same it evaluates to ‘true’ otherwise it gives a ‘false’ response. Quite why we used XOR is more obvious when you look at the scripts themselves.
They are not fully finished yet – some fine tuning to do and so on, but you can get to them by going here:
and looking for the item called Jukebox_randomiser.sit. You will also see the original jukebox files there, too.
The basic mechanics of the scripting is that the user chooses a clip to play. The value of the button they select is then lodged into a five bit long section within a 16 bit register (there are eight of these at our disposal). The script then adds one to a counter and sends you back to the menu for the next choice if the counter is less than 9. Once the ninth choice has been made the script sends you to a menu to play the choices back. To do this it first generates a random number between 0 and 9 and uses this to look within one of three memory slots where the choices are stored. It then masks off the two sets of five bits that it isn’t using and works with the five bits it needs. These are then blanked to be zeros so that when it next looks it knows whether or not the choice has been played. By repeating this process the script tracks what has been played. If the random number generator picks the same number a second time the script subtracts one from it to attempt to find a new number not yet chosen…
I told you it was complex!
In time I will tidy this set of scripts up and sort out the remaining ‘end jumps’ for the tracks that use the scripts, then build a disc image for folks to download and try out. Currently there is also a section within two of the scripts which should be tidied up as it is very long winded (we couldn’t think of the shorter way to do it…sigh), but otherwise it all works as it should. I will eventually add comments to the scripts as well so as to keep track of what is going on should anyone else want to use them.