Created
June 29, 2017 13:05
-
-
Save kasperkamperman/6ec1be4ddd7c418b2ee29dd1a01f388f to your computer and use it in GitHub Desktop.
AudioVisualiseExample
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
import processing.sound.*; | |
Amplitude amp; | |
AudioIn in; | |
float previousVolume = 0.0; | |
void setup() { | |
size(640, 640); | |
background(255); | |
// Create an Input stream which is routed into the Amplitude analyzer | |
amp = new Amplitude(this); | |
in = new AudioIn(this, 0); | |
in.start(); | |
amp.input(in); | |
noFill(); | |
strokeWeight(5); | |
} | |
void draw() { | |
background(255); | |
println(amp.analyze()); | |
float audioVolume = map(amp.analyze(),0.0,1.0,0.2,0.6); | |
float newVolume = 0.9 * previousVolume + 0.1 * audioVolume; | |
previousVolume = audioVolume; | |
stroke(255,0,0); | |
ellipse(width/2,height/2,audioVolume*width, audioVolume*height); | |
stroke(0,255,0); | |
ellipse(width/2,height/2,newVolume*width, newVolume*height); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment