doSomething
class
by Wangshu Sun
HTML
<script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
<script src="https://tonejs.github.io/CDN/r6/Tone.min.js"></script>
JavaScript
var synth = new Tone.SimpleSynth().toMaster();
function doSomething(when) {
console.log("called at", synth.now());
synth.triggerAttackRelease("C4", "8n");
console.log("scheduled time", synth.now());
}
//Tone.Transport.schedule()
//doSomething(1);
//doSomething(2);
//setTimeout(doSomething, 1000);
/*
setTimeout(function thingy() {
doSomething(1);
}, 1000);
*/
Tone.Transport.schedule(doSomething, 1);
Tone.Transport.schedule(doSomething, 2);
var startTime = Tone.Transport.now();
console.log("start time", startTime);
Tone.Transport.start(1).stop(4).start(6);