function setup() {
  createCanvas(720, 400);
  // Particles to visualize notes
  system = new ParticleSystem(createVector(width / 2, 50));
  // Create a synth to make sound with
  synth = new p5.PolySynth();
  // Create SoundLoop repeating every 0.3s
  sloop = new p5.SoundLoop(soundLoop, 0.3);
}
Example of dynamic note-scheduling using the p5.SoundLoop.

This example produces random sequences of notes drawn from a
minor pentatonic scale, but allow the user to interact with
the composition by moving the cursor to change the octave
of the note palette.