let notePattern = [42,52,43,51,44,50,45,49,46,48,47];
let cnv = createCanvas(400, 400);
cnv.mousePressed(canvasPressed);
colorMode(HSB,360,210,150,1);
text('PRESS ME', 150, 200);
let intervalInSeconds = 0.4;
soundLoop = new p5.SoundLoop(onSoundLoop, intervalInSeconds);
synth = new p5.MonoSynth();
notePattern=[66,76,67,75,68,74,69,73,70,72,71]
colorMode(HSB,360,100,50,215)
notePattern=[90,100,91,99,92,98,93,97,94,96,95]
colorMode(HSB,360,300,100,1);
notePattern = [42,52,43,51,44,50,45,49,46,48,47];
colorMode(HSB,360,210,150,1)
function canvasPressed() {
if (soundLoop.isPlaying) {
function onSoundLoop(timeFromNow) {
let noteIndex = (soundLoop.iterations - 1) % notePattern.length;
let note = midiToFreq(notePattern[noteIndex]);
synth.play(note, 0.5, timeFromNow);
background(noteIndex * 360 / notePattern.length, 50, 100);