xxxxxxxxxx
88
var sound;
var popp;
var fft;
var r;
let framenew = [];
let c= (0,0,0);
function preload(){
sound = loadSound ('gallant.mp3');
popp = loadSound('pop.mp3');
}
function setup() {
createCanvas(windowWidth, windowHeight);
background(255);
angleMode(DEGREES);
amp = new p5.Amplitude();
sound.play();
frameRate(600);
//for (let i=0; i<=10; i++){
//let x=30+200*i;
//framenew[i]= new frame(x,100,200);
}
//function mousePressed() {
//popp.play();
// }
function draw() {
background(220);
let level = amp.getLevel();
let size = map(level, 0, 1, 0, 200);
for (let i=0; i<framenew.length; i++){
framenew[i].move();
framenew[i].show();
}
if (size>40){
let b= new frame (mouseX-75,mouseY-75,100);
framenew.push(b);
}
}
class frame{
constructor(x,y,r){
this.x=x;
this.y=y;
this.r=r;
}
move(){
this.x=this.x+random(-1,1);
this.y=this.y+random(-1,1);
}
show(){
strokeWeight(random(3,5));
noFill();
beginShape();
frameRate(2);
vertex(this.x+random(0,20), this.y+random(0,20));
vertex(this.x+random(130,150), this.y);
vertex(this.x+random(130,150), this.y+random(280,300));
vertex(this.x, this.y+random(280,300));
endShape(CLOSE);
fill(255);
ellipse(this.x,this.y,30);
}
}