notea = loadSound("a.mp3");
noteb = loadSound("sunbells.mp3");
notec = loadSound("c.mp3");
noted = loadSound("d.mp3");
notee = loadSound("fluttering.mp3");
notef = loadSound("f.mp3");
noteg = loadSound("g.mp3");
arpeggio = loadSound("arpeggio.mp3");
createCanvas(windowWidth,windowHeight);
text("click the mouse to paint and play a sound", 50, 50);
fill(rValue,gValue,bValue);
text("press keys a, b, c, d, e, f & g to choose a sound and color", 50, 90);
text("press spacebar to throw an arpeggio", 50, 130);
delay.process(notea, .12, .7, 2300);
delay.process(noteb, .12, .7, 2300);
delay.process(notec, .12, .7, 2300);
delay.process(notef, .12, .7, 2300);
delay.process(noteg, .12, .7, 2300);
delay.setType('pingPong');
analyzer = new p5.Amplitude();
system = new ParticleSystem(createVector(width/2, 50));
for(var i=0;i< blobs.length; i = i+1){
disc.moveY = disc.moveY + gravity
fill(random(0,50),random(170,220),random(220,270),70);
rect(disc.x,disc.y,50,50);
disc.x = disc.x + disc.moveX;
disc.y = disc.y + disc.moveY;
disc.moveX = disc.moveX*-1;
disc.moveX = disc.moveX*-1;
disc.moveY = disc.moveY*-1;
disc.moveY = disc.moveY*-1;
fill(rValue,gValue,bValue);
text("click the mouse to paint and play a sound", 50, 50);
text("click the mouse to paint and play a sound", 50, 50);
function mousePressed() {
this.system = new ParticleSystem(createVector(mouseX, mouseY));
fill(rValue,gValue,bValue);
text("press keys a, b, c, d, e, f & g to choose a sound and color", 50, 90);
} else if (keyCode === 66) {
fill(rValue,gValue,bValue);
text("press keys a, b, c, d, e, f & g to choose a sound and color", 50, 90);
} else if (keyCode === 67) {
fill(rValue,gValue,bValue);
text("press keys a, b, c, d, e, f & g to choose a sound and color", 50, 90);
} else if (keyCode === 68) {
fill(rValue,gValue,bValue);
text("press keys a, b, c, d, e, f & g to choose a sound and color", 50, 90);
} else if (keyCode === 69) {
fill(rValue,gValue,bValue);
text("press keys a, b, c, d, e, f & g to choose a sound and color", 50, 90);
} else if (keyCode === 70) {
fill(rValue,gValue,bValue);
text("press keys a, b, c, d, e, f & g to choose a sound and color", 50, 90);
} else if (keyCode === 71){
fill(rValue,gValue,bValue);
text("press keys a, b, c, d, e, f & g to choose a sound and color", 50, 90);
} else if (keyCode === 32){
var newdisc = { x: mouseX,
text("press spacebar to throw an arpeggio", 50, 130);
var Particle = function(position) {
this.acceleration = createVector(0, 0.03);
this.velocity = createVector(random(-1, 1), random(-1, 0));
this.position = position.copy();
Particle.prototype.run = function() {
Particle.prototype.update = function(){
this.velocity.add(this.acceleration);
this.position.add(this.velocity);
Particle.prototype.display = function() {
stroke(0, this.lifespan);
fill(rValue,gValue,bValue,70, this.lifespan);
ellipse(this.position.x, this.position.y, 75, 75);
Particle.prototype.isDead = function(){
return this.lifespan < 0;
var ParticleSystem = function(position) {
this.origin = position.copy();
ParticleSystem.prototype.addParticle = function() {
this.particles.push(new Particle(this.origin));
ParticleSystem.prototype.run = function() {
for (var i = this.particles.length-1; i >= 0; i--) {
var p = this.particles[i];
this.particles.splice(i, 1);