xxxxxxxxxx
39
// Play a three-over-two polyrhythm
// Create a Players object and load the "kick.mp3" and "snare.mp3" files
var kit = new Tone.Players({
"kick": "samples/505/kick.mp3",
"snare":"samples/505/snare.mp3"
});
// Connect the player output to the computer's audio output
kit.toMaster();
// Set the tempo
Tone.Transport.bpm.value = 60;
// Create two loops for a three over two cross-rhythm
Tone.Transport.scheduleRepeat(playRhythm1, 1/3);
Tone.Transport.scheduleRepeat(playRhythm2, 1/2);
Tone.Transport.start();
function playRhythm1() {
if (kit.loaded) {
kit.get("kick").start();
}
}
function playRhythm2() {
if (kit.loaded) {
kit.get("snare").start();
}
}
function setup() {
}
function draw() {
}