A large number and two pairs of timestamps denote a time bracket. The beginning and ending of each time bracket is chosen by picking a time value within the range denoted by each timestamp pair. The large number denotes a sound to be played once within the time bracket. One sound should be chosen for each unique large number and can be long or very short.
In generating the score, I first fill an array of integers 1-n inclusive, one for each sound. I then choose randomly from the array an integer to repeat, which is then pushed to the array. I then use the Fisher-Yates algorithm to shuffle this array. This results in the final ordering of the big numbers for each bracket. The duration array consists of four entries to every one of the entries in the sound array (four = two pairs of time stamps). These entries are integers corresponding to the eventual timestamps (m'ss") but in seconds. Before randomly generating the duration array's entries, I call a coin flip function to determine whether or not to start at 0'00" and whether to end at the maximum duration. This is overridden if the resulting length of the piece is smaller than the number of sounds multiplied by the number of repeated sounds. In the generation of the array, I make sure that each random integer is unique (there are no duplicates in the array). Obviously, this cannot hold if the previous statement about the length and the multiplied value is not true by the pigeonhole principle. In this case, I limit the number of tries of generating unique numbers to ten per number. After the array is generated, I use a quicksort algorithm to sort the array.
More information about me or my projects can be found at www.derekxkwan.com