Rotate audio visualizer in stage
in
Core Library Questions
•
4 months ago
How can I rotate this audiovisualizer from left to right, instead from the bottom to the middle?
class Timer {
int savedTime; // When Timer started
int totalTime; // How long Timer should last
Timer(int tempTotalTime) {
totalTime = tempTotalTime;
}
// Starting the timer
void start() {
// When the timer starts it stores the current time in milliseconds.
savedTime = millis();
}
// The function isFinished() returns true if 5,000 ms have passed.
// The work of the timer is farmed out to this method.
boolean isFinished() {
// Check how much time has passed
int passedTime = millis()- savedTime;
if (passedTime > totalTime) {
return true;
}
else {
return false;
}
}
}
Timer timer;
import ddf.minim.analysis.*;
import ddf.minim.*;
Minim minim;
AudioInput in;
FFT fft;
int w;
PImage fade;
int hVal;
float rWidth, rHeight;
boolean b = false;
void setup() {
background(#FFFFFF);
timer = new Timer(300);
timer.start();
size(1280, 720, P3D);
minim = new Minim(this);
in = minim.getLineIn(Minim.STEREO, 512);
fft = new FFT(in.bufferSize(), in.sampleRate());
fft.logAverages(5000, 50);
stroke(255);
w = width/fft.avgSize();
strokeWeight(w);
fade = get(0, 0, width, height);
rWidth = width * 0.99;
rHeight = height * 0.99;
hVal = 0;
}
void draw() {
if (timer.isFinished()) {
b = true;
timer.start();
}
if(b==true){
tint(255, 255, 255, 255 );
image(fade, (width - rWidth) /2, (height - rHeight) /4, rWidth, rHeight);
noTint();
fft.forward(in.mix);
colorMode(HSB);
stroke(hVal, 255, 255);
colorMode(RGB);
for(int i = 0; i < fft.avgSize(); i++){
line((i * w) + (w / 2), height, (i * w) + (w /2), height - fft.getAvg(i) * 4);
}
fade = get(0, 0, width, height);
pushMatrix();
rotate(radians(-45));
popMatrix();
translate(0, 0);
for(int i = 0; i < fft.avgSize(); i++){
line((i * w) + (w / 2), height, (i * w) + (w /2), height - fft.getAvg(i) * 4);
}
hVal += 2;
if( hVal > 255)
{
hVal = 0;
}
}
}
1