Download main manual

Transcript
Sequencer outputs during sampling
Vn
When a variable or table entry is used for a branch, the value is treated as a
32-bit unsigned number; 0 means a probability of zero and 4294967295 (the
largest 32-bit unsigned number) means a probability of 0.9999999998.
BRAND
LB,0.5
;branch with 50% probability
To produce a multiple way random branch you use more BRAND instructions. A three
way equal probability branch to LA, LB and LC can be coded:
LC:
BRAND
BRAND
...
LA,0.33333
LB,0.5
;Split the first route with p=1/3
;0.6667 to here * 0.5 is 0.3334 (1/3)
;If neither of the above, comes here
The following shows the sequence for a five-way branch with equal probabilities:
LC:
FX:
LE:
BRAND
BRAND
BRAND
...
BRAND
...
LA,0.2
FX,0.5
LB,0.5
LD,0.5
;5 way, LA probability is
;Probability to here=0.8,
;Probability to here=0.4,
;Probability to here=0.2
;Probability to here=0.4,
;Probability to here=0.2
0.2 (1/5)
so to FX=0.4
so to LB=0.2
so to LD=0.2
The best technique is to reduce the branches to a power of two as soon as possible. Case
1 of the five-way branch is split off (probability of 0.2), leaving 4 ways. The 4 ways are
split with a probability of 0.5 (0.4 for each division) then the last two routes are split,
again with a probability of 0.5 (0.2 for each division).
Poisson process
In a Poisson process, the probability of something happening per time interval is
constant. You can generate a delay with a Poisson statistic by:
POISSON: BRAND
POISSON,prob ; poisson delay
The probability is given by prob = 1.0 – 1.0/(mDelay*S(1)), where mDelay is
the mean delay required in seconds and S(1) is the built in function that tells us how
many steps there are per second. If you would rather express this in terms of a rate, then
prob = 1.0 – rate/S(1), where rate is the expected rate in Hz.
TENHZ:
BRAND
DIGOUT
DIGOUT
TENHZ,1.0-10/S(1) ;10 Hz mean rate
[.......1]
;set output high
[.......0],TENHZ ;set output low, goto TENHZ
This example generates a digital output that pulses to produce an approximation to a
Poisson distributed pulse train with a mean frequency of 10 Hz. The approximation
improves the shorter the step time. The mean interval between pulses is 100 milliseconds
plus the time for 2 steps and the shortest gap between pulses is 3 sequencer steps.
Scripts and variables
From a script you can set sequencer variables as 32-bit signed integers. For the range
2147483648 to 4294967295 we must use negative numbers. This script example shows
you how to convert a probability into a variable value and pass it to the sequencer:
Proc SetBrandVar(prob, v%) 'prob is probability, v% is variable
prob *= 4294967296.0;
'range 0-4294967296 is 0 to 1.0
if (prob > 4294967295.0 ) then prob := 4294967295.0 endif;
if prob > 2147483647 then prob -= 4294967296.0 endif;
if prob < -2147483647 then prob := -2147483647 endif;
SampleSeqVar(v%, prob);
end;
6-27