Created
March 20, 2021 02:28
-
-
Save kasthor/c34466c75ea5b7f53f3ab2e089ebac90 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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