let particleFrequency = 0.1;
let particleSpeedFactor = 0.1;
background(255, 255, 255, 25);
let vol = mic.getLevel();
let n = map(vol, 0, 1, 0, 10);
for (let i = 0; i < n; i++) {
let shape = random() < 0.5 ? 'circle' : 'drop';
particles.push(new Particle(random(width), random(height), random(-2, 2), random(-2, 2), size, shape));
for (let i = particles.length - 1; i >= 0; i--) {
if (particles[i].isFinished()) {
constructor(x, y, dx, dy, size, shape) {
this.position = createVector(x, y);
this.velocity = createVector(dx, dy);
this.strokeWeight = random(0.5, 3);
this.color = color(random(255), random(255), random(255), this.lifespan);
this.velocity.add(createVector(random(-0.5, 0.5), random(-0.5, 0.5)));
this.position.add(this.velocity);
this.color.setAlpha(this.lifespan);
strokeWeight(this.strokeWeight);
if (this.shape === 'circle') {
ellipse(this.position.x, this.position.y, this.size, this.size);
} else if (this.shape === 'drop') {
ellipse(this.position.x, this.position.y, this.size / 2, this.size);
return this.lifespan < 0;