NAME

get_spray - retrieve an integer from a spray table


SYNOPSIS

integer_value = get_spray(spray_table_number)


DESCRIPTION

Call get_spray from a script to get a number from a spray table initialized by spray_init. The table contains integers from zero to one less than the table size. Repeatedly calling get_spray reads the table in a random order, but in such a way that no number appears twice before all the other numbers have appeared once.


ARGUMENTS
spray_table_number
The numeric ID for the spray table. You can have as many as 32 spray tables, numbered from 0 to 31.


EXAMPLES

This complete score plays two randomly generated twelve-tone rows, one after the other, in an appropriately irritating way. Each pitch appears exactly once during the first 12 notes, and once again during the second 12 notes.

   rtsetparams(44100, 1)
   load("WAVETABLE")

   amp = 20000
   ampenv = maketable("line", 1000, 0,0, 1,1, 10,0)

   /* make sawtooth wave */
   sawtable = maketable("wave", 1000, 1, 1/2, 1/3, 1/4, 1/5, 1/6, 1/7, 1/8, 1/9)

   seed = 0
   spray_init(0, 12, seed) /* make spray table 0 with 12 elements */

   for (i = 0; i < 24; i = i + 1) {
      val = get_spray(0)   /* access spray table 0 */
      pitch = 8 + (val * 0.01)  /* convert to oct.pc */
      st = i * 0.25
      WAVETABLE(st, dur = 0.25, amp*ampenv, pitch, 0, sawtable)
   }


This complete score shows how to make a sound pan randomly to specific locations (rather than to just any random location). The sound will pan to each location once, in a random order, then pan to each location once more, in a random order, etc., for 10 seconds. Note that this does not mean there will be no direct repetitions of a location, since this can occur when starting to read the table for a second time, for example. (The last value returned during the first read could be the value returned at the start of the second read.)
   rtsetparams(44100, 2)
   load("WAVETABLE")

   amp = 20000
   ampenv = maketable("curve", 1000, 0,0,0, 1,1,-5, 30,0)

   sawtable = maketable("wave", 1000, 1, .3, .1)  /* dull sawtooth */

   seed = 1
   spray_init(0, 3, seed) /* make spray table 0 with 3 elements */

   /* make array containing 3 pan locations */
   panarr = { 0.0, 0.5, 1.0 }

   dur = 0.2
   pitch = 8.00
   for (st = 0; st < 10; st = st + 0.25) {
      /* use spray value as index into the pan array */
      index = get_spray(0)       /* access spray table 0 */
      pan = panarr[index]
      WAVETABLE(st, dur, amp*ampenv, pitch, pan, sawtable)
   }


SEE ALSO

irand, pickrand, pickwrand, rand, random, spray_init, srand, irand