Hi guys,
I have an amazing code that visualises every second of sound from an MP3 track that wonderful Chrisir helped me with.
But I need to change it so that it visualises every second of life sound instead of MP3 treck, I've found a code that use this life sound minim, then merged it to my code and.., it doesn't work.
I probably messed up the code, can anyone please help to fix so it works?
Looking forward for any piece of advice.
I have an amazing code that visualises every second of sound from an MP3 track that wonderful Chrisir helped me with.
But I need to change it so that it visualises every second of life sound instead of MP3 treck, I've found a code that use this life sound minim, then merged it to my code and.., it doesn't work.
I probably messed up the code, can anyone please help to fix so it works?
Looking forward for any piece of advice.
- // visualizes sound in 1-second-blocks
//
import ddf.minim.analysis.*;
import ddf.minim.*;
Minim minim;
AudioInput in;
FFT fft;
float x = 0;
float y = 0;
int lastTime=0;
float oldCol=0.0;
int count=0;
//
//
void setup()
{
size (78*9, 78*9); // (860, 700);
background(0);
noStroke();
minim = new Minim(this);
// setup audio input
in = minim.getLineIn(Minim.MONO, bufferSize, sampleRate);
fft = new FFT(in.bufferSize(), in.sampleRate());
// suppress windowing inside FFT - we'll do it ourselves
fft.window(FFT.NONE);
track.loop();
lastTime=millis();
}
//
void draw()
{
//
for (int i = 0; i < track.left.size(); i++)
{
// oldCol sums up the colors for one rect
oldCol=oldCol+map( abs(track.left.get(i)), 0, .2, 0, 255);
// "count" counts how many colors for one rect have been count
count++;
// the average of all count colors is the color
fill( oldCol/count );
rect(x, y, 8, 8);
// has 1 second passed?
if (1000 <= millis() - lastTime) {
// next rect
x+=9;
lastTime=millis();
// reset our colors
count=0;
oldCol=0;
} // if
//
if ( x >= width ) {
// start a new line on the left
y += 9;
x = 0;
} // if
} // for
} // func
//
//
void stop()
{
// always close Minim audio classes when you are done with them
track.close();
minim.stop();
super.stop();
} // for
//
1