function setup() {
  createCanvas(720, 400);
  synth = new p5.PolySynth();
  sloop = new p5.SoundLoop(soundLoop, 0.1); // Interval doesn't matter; it changes in each loop iteration
}
Using the SoundLoop to play back an array of notes with dynamic control.

The array of notes uses a note-on and note-off event representation;
this separation is necessary so that we can have polyphonic sound
and dynamic starting and stopping of notes during playback.