[Spectrogram] No member named 'draw' in 'ofxFft'

Hi, All.

I am trying to make spectrogram usimg ofxFFT.

I met this error

"No member named ‘draw’ in ‘ofxFft’ "

when run ofxFftTest example line

fft->draw(0, 0, fft->getSignalSize(), plotHeight);
in https://github.com/kylemcdonald/kyle/tree/master/openframeworks/addons/ofxFft/examples/ofxFftTest

Whats wrong to me?
Thanks.

That example seems to be 10 years old. But OF comes with examples/sound/soundPlayerFFTExample. Maybe that example can get you started?

1 Like

Hi, @hamoid.

Woops,
Example that you suggested, have no spectrogram fucntions.

Just thing that I want is not FFT but spectrtrogram code.

Sorry…

Hi @bemoregt ,

There seems to be a few draw functions in ofxProcessFFT.h (within ofxFft) -
check them out and see if they suit your needs.

Otherwise post some code, I’ll try running it on my side.

1 Like

In case you don’t need to do this in real time, when I need something like that I use https://www.sonicvisualiser.org/ which can give you a spectrogram (saved as an image) and lots of other data that can be extracted from audio files and saved as xml.
The underlying analysis software can be called from the command line and automated from scripts.

ps. Here’s a list with some of the features you can detect: https://www.vamp-plugins.org/download.html

1 Like

I’m not certain what fft.draw() would show, but if your goal is to display the spectrogram just comment it out. Most approaches to drawing spectrograms I’ve seen copy the content of the fft buffer to a column of an image’s pixel buffer.

This is what’s happening in the last block of audioReceived() in the code example you linked:

	fft->setSignal(audioInput);
	float* curFft = fft->getAmplitude();
	int spectrogramWidth = (int) spectrogram.getWidth();
	unsigned char* pixels = spectrogram.getPixels();
	for(int i = 0; i < fft->getBinSize(); i++)
		pixels[i * spectrogramWidth + spectrogramOffset] = (unsigned char) (255. * curFft[i]);
	spectrogramOffset = (spectrogramOffset + 1) % spectrogramWidth;
1 Like