Fastest way to draw spectrum analyser

Hello, I’m pretty new to JUCE but I’ve started to create simple FFT spectrum analyser with it.
What I do is get buffered samples through FFTW, put them in bins (with some average value calculation) and then pass bin values to the editor like that:

EqualizerAudioProcessorEditor* editor = static_cast <EqualizerAudioProcessorEditor*> (getActiveEditor());
if(editor != NULL)

First of all: Is it a good way of updating the visualization screen or is there any neater way of handling this?
Secondly, what’s the fastest way to draw those bins anyway. So far I do something like this:

        gridImage = Image(Image::RGB, windowWidth, windowHeight, true);
	Graphics g (gridImage);
        int x = 0;
	for(int i = 0; i < binsNum; i++)
		g.fillRect(x, windowHeight, binWidth, bins[i]);
		x += ioffset;


I suppose this isn’t good way of drawing anything (so many initializations and stuff) but could anyone please help with this issue?
Thanks in advance.

Calling fillRect many times is no problem, but why draw to an image? Best to just draw directly to your component.

And it’s not clear whether you’re attempting to do that drawing in your audio thread… If so, NOOOOO! Just make your audio thread save the minimum amount of data for your GUI code to draw from later.

Yes, i’m currently invoking the drawBins method from audio thread. So you advise me to put those bin float values into some public property (just as in your audio synth demo), right?
As it comes to the component: DrawableImage is a good component for this or you mean the component as a whole editor and draw bins in “paint(Graphics &g)” (basing on the values in public property)? It’s a tricky way to solve this as “paint” gets called each how many frames? Shall I use “repaint” or…?

Right about the float values. Then just make your editor a timer with a callback every, say, 30 ms or so, and call repaint from there. If possible, restrict the repaint to the necessary rectangle…