Random Thresh

Trigger some noise when the probability is below some threshold

by Eve Weinberg

HTML

<script src="https://tonejs.github.io/CDN/r6/Tone.min.js"></script>

JavaScript

var delay = new Tone.FeedbackDelay(0.045, 0.8).toMaster();

var env = new Tone.AmplitudeEnvelope(0.001, 0.02, 0.0);

var noise = new Tone.Noise("pink").chain(env, delay).start(0);

//returns a num btwn 0 and 1
//schedules them all right away, then it uses the first parameter for timing

for (var i = 0; i < 200; i++){
	if (Math.random() < 0.1){
  	env.triggerAttack(i * 0.05);
  }
}
//or give it a 2nd parameter
//env.triggerAttack(x,Math.random()*0.5+0.5);
//start the noise right away and then the envelope is triggered