xxxxxxxxxx
72
let l=[];
let sound, amplitude, cnv;
let img;
function preload(){
sound = loadSound('TIM.mp4');
//img = loadImage('Tears02.png');
img = loadImage('Tears04.png');
}
function setup() {
cnv=createCanvas(400,600);
l = new lines();
amplitude = new p5.Amplitude();
fft=new p5.FFT();
sound.amp(0.2);
}
function draw() {
background(0);
l.show();
tint(255,127,50,90);
imageMode(CENTER);
//image(img,464,269,1800,1200);
image(img,40,260,100,400);
//print(mouseX,mouseY);
}
function mousePressed() {
if (sound.isPlaying()) {
sound.stop();
} else {
sound.play();
}
}
class lines {
constructor(){
this.x= width;
this.y = 190;
this.c=0;
}
show () {
let bass = fft.analyze();
this.c = map(mouseX, 0, 600, 0, 255);
for (let i = 0; i < 90; i +=2) {
this.b=map(i,0,bass.length,0,this.x);
this.bh=-height+map(bass[i],0,255,height,0);stroke(this.c,89,148);
strokeWeight(2);
line(i*3,this.y,this.x-this.bh,i*9);
}
}
// eye(){
// let level = amplitude.getLevel();
// let size = map(level,0,1,0,400);
// noFill();
// stroke(226,136,26);
// ellipse(this.x/2, height/2, size, size);
// }
}
//line(this.prX,this.prY*this.bh,this.sx,this.sy-this.prY);
//line(this.prX,this.bh,this.prY,this.sy);