Created
March 27, 2021 01:39
-
-
Save kasthor/096a6a3893b9bd653b3014822ba5d185 to your computer and use it in GitHub Desktop.
Paint with Music
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, minLevel, maxLevel; | |
function setupAudio(){ | |
userStartAudio(); | |
mic = new p5.AudioIn(); | |
mic.start(); | |
} | |
function setup() { | |
createCanvas(windowWidth, windowHeight); | |
timeline = []; | |
setupAudio(); | |
background(30); | |
minLevel = 0 | |
maxLevel = 0; | |
} | |
function draw(){ | |
colorMode(RGB) | |
background(30, 1); | |
noStroke(); | |
colorMode(HSB) | |
let micLevel = mic.getLevel(); | |
maxLevel = max(maxLevel, micLevel) | |
minLevel = min(minLevel, micLevel) | |
fill(map(micLevel, minLevel, maxLevel, 0, 100), 100,100) | |
circle(mouseX, mouseY, micLevel * height * 10) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment