get_spray - retrieve an integer from a spray table
integer_value = get_spray(spray_table_number)
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.
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) }
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) }
irand, pickrand, pickwrand, rand, random, spray_init, srand, irand