Interpolated Probability Drums

by yotammann

HTML

<script src="https://tonejs.github.io/build/Tone.js"></script>
<!-- <script src="https://tonejs.github.io/Logo/build/Waveform.js"></script> -->
<input id="playbackRate" type = "range" min="5" max="20">
<input id="tempo" type = "range" min="60" max="240">

JavaScript

var kit = new Tone.MultiPlayer({
	"kick" : "https://tonejs.github.io/examples/audio/505/kick.mp3",
	"snare" : "https://tonejs.github.io/examples/audio/505/snare.mp3",
  "hh" : "https://tonejs.github.io/examples/audio/505/hh.mp3"
}, function(){
	Tone.Transport.start()
}).toMaster()

var synth = new Tone.Synth().toMaster()

var drumPattern = new Tone.Pattern(function(time, note){
	kit.start(note, time)
}, ["kick", "hh", "snare", "hh"], 'up').start()

var synthPattern = new Tone.Pattern(function(time, note){
	synth.triggerAttackRelease(note, 0.1, time)
}, ["C4", "E4", "G4", "B4"], 'down').start()

document.querySelector('#playbackRate').addEventListener('input', function(e){
	var playbackRate = parseInt(e.target.value)
	drumPattern.playbackRate = playbackRate
})

document.querySelector('#tempo').addEventListener('input', function(e){
	var tempo = parseInt(e.target.value)
	Tone.Transport.bpm.value = tempo
})


//loop.probability = 0.5