an open-source digital signal processing and sound synthesis language
about · links · contact
spray_init - initialize a random integer spray can


spray_init(spray_table_number, spray_table_size, random_seed)


Call spray_init from a script to set up a random integer spray can. The idea is that you create a table of integers and then use get_spray to retrieve them. The table contains integers from zero to one less than the table size. (Another way to look at it is that each element takes its index as its value.) Repeatedly calling get_spray reads the table randomly, but in such a way that no number appears twice before all the other numbers have appeared once.


The numeric ID for the spray table. You can have as many as 32 tables, numbered from 0 to 31. Note that these are separate entities from tables created using the maketable scorefile command.

The table can have as many as 512 values.

An integer to seed the random number generator. Note that this re-seeds the same random number generator used by rand, random, irand, etc.


   seed = 78
   spray_init(3, 7, seed) // initialize table 3 with 7 elements

   for (i = 0; i < 21; i = i+1) {
      val = get_spray(3)

See Also

get_spray, irand, pickrand, pickwrand, rand, random, srand, irand