Tap for a new crab. Listen for changes to the filter. Press any key to save screenshot.
A fork of sound canvas CRABS working by Nandini
xxxxxxxxxx
let sound;
let bgcolor;
let filter;
function preload(){
sound = loadSound('./120_DiscoDrums_02_172_SP.wav');
filter = new p5.LowPass();
sound.disconnect();
sound.connect(filter);
}
function setup() {
createCanvas(windowWidth, windowHeight);
background(0);
}
function draw() {
if(sound.isPlaying()){
amp.setInput(sound);
let rms = amp.getLevel();
noStroke();
// strokeWeight(4);
//stroke(mouseX/2, mouseY/2, mouseY/2);
fill(random(255),random(255),random(255),100);
let diameter = map(rms, 0, 1, 0, width/2);
arc(mouseX, mouseY, 90, 90, HALF_PI, PI+HALF_PI,OPEN);
arc(mouseX+44,mouseY+45,90,90, PI,HALF_PI-QUARTER_PI-QUARTER_PI,OPEN);
arc(mouseX+88, mouseY, 90, 90, -HALF_PI, HALF_PI, OPEN);
ellipse(mouseX+32,mouseY-7,10,10);
ellipse(mouseX+55,mouseY-7,10,10);
ellipse(mouseX+10,mouseY+55,10,10);
ellipse(mouseX+76,mouseY+55,10,10);
let freq = map(mouseX, 0, width, 0, 7000);
let res = map(mouseY, 0, height, 40, 4);
filter.set(freq, res);
}
}
function mousePressed(){
sound.loop();
amp = new p5.Amplitude();
}