xxxxxxxxxx
let sound;
let amplitude;
let index = 0;
let counter1=1;
let counter2=1;
function preload() {
sound = loadSound("Gnarls Barkley_crazy.m4a");
}
function setup() {
colorMode(HSB);
createCanvas(windowWidth, windowHeight);
amplitude = new p5.Amplitude();
sound.loop();
}
function draw() {
//if (sound.isPlaying()) {
let level = amplitude.getLevel();
let peak = map(level, 0, 1, 0, height);
let c = map(level, 0, 1, 0, 360);
/*
if(peak>=height/5.5)
background(peak/3,100,100,0.1);
else
background(0,0,0,0.1);
*/
//background(peak,100,100);
translate(width/2,height/2);
rotate(counter1/200);
//fill(c+index/10,100,100);
//stroke(255);
noStroke();
//ellipse(0, 0, index/2, peak*4);
ellipse(0, 0, peak*2, peak*4);
rectMode(CENTER);
if(peak>=height/5.5){
//background(c+index/10,10,100);
fill(c+index/6,100,20);
ellipse(0, 0, peak*2, peak*3);
}
else {
//background(c+index/10,10,100);
fill(c+index/5,100,100);
ellipse(0, 0, peak*2, peak*2);
}
if (index < width)
index += 2;
else
index = 0;
if (counter1>0)
counter1 ++;
if (counter2>0)
counter2 ++;
//}
}
/*
function mousePressed() {
sound.play();
}
*/