xxxxxxxxxx
var mic;
let noiseScale = 0.02; //this is the noisescale, it scales the pitch, up and down, of the overall shape
let done = false;
let timer = 5;
function setup() {
createCanvas(windowWidth, windowHeight);
background(0);
colorMode(HSB, 255);
noFill();
noStroke();
mic = new p5.AudioIn();
// start the Audio Input.
// By default, it does not .connect() (to the computer speakers)
mic.start();
}
function draw() {
// Get the overall volume (between 0 and 1.0)
var vol = 0.5*(-cos(mic.getLevel()*6*PI)+1);
//print(vol);
var h = map(vol, 0, 1, 0, height);
var c = map(vol, 0, 1, 0, 255);
var wi = map(vol, 0, 1, 0, width);
var hi = map(vol, 0, 1, height, 0);
noiseScale = vol;
// if(noiseScale < 0.2 && frameCount % 10 == 0){
// background(0);
// }
// if(noiseScale > 0.2 && frameCount % 10 == 0){
if (frameCount % 5 == 0){
background(0);
let noiseVal = noise((h + random(width/15, width)) * noiseScale, h * noiseScale);
noStroke();
//fill(255, c);
fill(255);
//circle(wi + random (-width/20, width/20), hi + random (-height/20, height/20), h);
circle(wi * sin(random (-width/50, width/50)), hi * cos(random (-height/50, height/50)), h);
}
}