xxxxxxxxxx
37
let startButton;
let stopButton;
Tone.Transport.bpm.value = 120;
let noteText;
const seq = new Tone.Sequence((time, note) => {
sampler.triggerAttackRelease(note, "2n", time);
noteText = note;
}, ["C0", "C1", "C0", "C1", "C2", "C3"], "2n").start(0);
function setup() {
createCanvas(400, 400);
startButton = createButton("start transport");
stopButton = createButton("stop transport");
startButton.mousePressed(startTransport);
stopButton.mousePressed(stopTransport);
textSize(24);
}
function draw() {
background("goldenrod");
fill(0);
text(noteText, width / 2 - 10, height / 2);
}
function startTransport() {
Tone.start();
// start the transport
Tone.Transport.start();
}
function stopTransport() {
// stop the transport
Tone.Transport.stop();
}