Make sound wave change color according to sound frequency from mic input (processing)

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 know a bout 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

import ddf.minim.*;
import ddf.minim.analysis.*;

Minim minim;
AudioInput in;
FFT         fft;

void setup()
  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

  // 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 );


The best advice I can give you is to break your problem down into smaller steps and take those steps on one at a time. You’ve got a small example sketch to get started, and that’s great. So now you have to continue working forward in small steps. In other words, only worry about one thing at a time.

I’d also recommend taking a step back and trying to be more specific about exactly what you want to do. I’m not a sound expert, so I’m not totally sure what you mean by sound frequency. When I run your sketch, I see a graph of the sound. Is this not the frequency you want to use? In other words, are you sure that in.left.get() and in.right.get() aren’t giving you the values you want to use? If not, why are they not correct? (Note that I’m genuinely asking, as I don’t really know much about audio processing.)

If you really do need to do some extra calculations to get the frequency of the audio, then I’d recommend a google search of something like “minim fft microphone” which returns a bunch of promising results. For example check out George’s answer here.

Get a sketch working that just outputs the frequency value to the console first. When you have that working, then you can think about how you want to use those values to calculate a color.

By the way, 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.