Skip to content

Instantly share code, notes, and snippets.

@kasthor
Created March 20, 2021 02:28
Show Gist options
  • Save kasthor/c34466c75ea5b7f53f3ab2e089ebac90 to your computer and use it in GitHub Desktop.
Save kasthor/c34466c75ea5b7f53f3ab2e089ebac90 to your computer and use it in GitHub Desktop.
let mic, timeline;
function setupAudio(){
userStartAudio();
mic = new p5.AudioIn();
mic.start();
}
function setup() {
createCanvas(windowWidth, windowHeight);
timeline = [];
setupAudio();
background(30);
}
function draw(){
background(30);
stroke(255);
noFill();
timeline.push(mic.getLevel())
console.log(timeline);
while(timeline.length > 100){
timeline.shift();
}
beginShape()
for(let i = 0; i < timeline.length; i++){
let x = map(i, 0, timeline.length, 0, width);
let y = map(timeline[i]*10, 0, 1, height/2, 0);
vertex(x, y)
}
endShape()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment