i have a Mic input from minim library, i want to know the value of the sound frequency and make the sound wave change color according to sound input.
i know about fft but all the examples I’ve seen had uploaded song not Mic input and i just don’t know how to apply it, also how am i gonna change the stroke color after i know the value?
if you can help that’d be great
this is the code i have for now
import ddf.minim.;
import ddf.minim.analysis.;
Minim minim;
AudioInput in;
FFT fft;
void setup()
{
size(1000,500);
minim = new Minim(this);
// use the getLineIn method of the Minim object to get an AudioInput
in = minim.getLineIn();
fft = new FFT( in.bufferSize(), in.sampleRate() );
}
void draw()
{
//wave color
stroke(0);
// draw the waveforms so we can see what we are monitoring
for(int i = 0; i < in.bufferSize() - 1; i++)
{
line( i, 50 + in.left.get(i)*50, i+1, 50 + in.left.get(i+1)*50 );
line( i, 150 + in.right.get(i)*50, i+1, 150 + in.right.get(i+1)*50 );
}
}
I see that you also posted this question here. When you post your question to multiple sites, please link between them so we know what help you’ve already received.
This is my first post, but I hope this is helpful. I spend a ton of my time working in processsing using the sound library and fft. I’ve been meaning to check out minim so this was a good chance for me to jump into it and compare it to the sound library. I modified the original code you posted to make a real simple fft visualization that changes from green to red when that frequency band is loud enough.
First, when using fft you must constantly monitor it, analyze() in processing.sound and it appears to be forward() in minim. Minim seems to be more flexible in that is not “attached” to the AudioInput object, unlike the processing sound library.
Second, in my experience using fft the higher indexes aren’t very useful in terms of musical analysis. In this example of breaking the audio signal into 1024 chunks, after about index 210 - 220 (roughly 9000Hz) the frequencies are so high pitch that they are either not in the musical spectrum and eventually out of the spectrum of human hearing.
I hope this helps and also gets you thinking of more ways to use audio to manipulate visuals.