[EDIT]Question about SpectrogramComponent in SimpleFFTExample

Hi, Jules and every one! I'm newby to develop GUI and Multi-Thread...

I want to create AudioVisualizer, so I'm trying to learn example codes.


Then I have a question about SpectrogramComponent. ( in SimpleFFTExample project )

I feel that SpectrogramComponent may drop audio data when pushNextSampleIntoFifo() is called from AudioThread.


Is this right...??

SpectrogramComponent.h  Line:72

void pushNextSampleIntoFifo (float sample) noexcept
    // if the fifo contains enough data, set a flag to say 
    // that the next line should now be rendered.. 
    if (fifoIndex == fftSize) 
        if (! nextFFTBlockReady) 
            zeromem (fftData, sizeof (fftData)); 
            memcpy (fftData, fifo, sizeof (fifo)); 
            nextFFTBlockReady = true; 
            //sometimes come here.
            //Does that mean this drop fifo AudioData because TimerThread is drawing???"

        fifoIndex = 0; 

    fifo[fifoIndex++] = sample; 

Please give me any suggestion & approach... : (


I believe that when nextFFTBlockReady is true it just means that the last block hasn't drawn yet. This will happen if your timer didn't fire often enough. However, in principle, it should be fine to call pushNextSampleIntoFifo from the audio thread.

note that SpectrogramComponent always scales its output to the FFT frame's min/max values; if you intend to display something less abstract like a stable freq EQ there is a *lot* more work involved. Ping me if you'd like more info.


-- p