Strange behavior

Hi all, I’m getting some odd behavior with TWChoose. The weights array is [0,1], so I think I should hear only noise. But, I’m hearing occasional fragments of a sine tone. Oddly, if I swap Dust for Impulse, it seems to work as expected. I’m on SC 3.11.0, macOS 10.14.6. Is this a bug, or am I doing something wrong?


) * 0.1!2;

There is a bug in TWIndex (which is used in TWChoose), which I only just noticed: a variable sum should be initialized to 0 once per trigger, but it’s initialized only once per control block. If there happens to be more than one trigger in a control block, the 2nd, 3rd etc triggers will go to index 0.

I think I can put in a fix later today.

The other potential issue is: if the random number generator produces exactly 0, then it would also go to the first index. But that should be exceedingly rare and almost unreproducible.


BTW this reproduces the bug:

a = {
	var trig = * 4),
	index =, [0, 1]); * (index <= 0), index, "failed");, 1,, doneAction: 2);

failed: 0
failed: 0
failed: 0

4 triggers should be generated. The second, third and fourth in the kr block calculate incorrectly.


Unfortunately, build requirements have become more complex lately, so it will take me some time to update my environment. So it’s definitely not going to happen today.