[CLAM] Real Time Plot

Miguel Ramírez mramirez at iua.upf.es
Wed Jul 21 01:45:07 PDT 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


| I'm developing a first simple application in order to
| test the features of CLAM. Is it possible display
| a real time plot of a spectrum with FLTK plot class?
|

Not with the SpectrumPlot - you must use the widget hidden within.

The simplest way of achieving what you want would be like this:

/// Code snippet begin
#include <FL/Fl.H>
#include "Fl_SMS_Spectrum.hxx"


int main( int argc, char** argv )
{
	Fl_Window* topLevel = new Fl_Window( 100, 100, 640, 480 );
	CLAMVM::Fl_SMS_Spectrum* specWidget =
		new Fl_SMS_Spectrum( 0,0,640,480 );
	topLevel->end();

	topLevel->show();

	CLAM::Spectrum theThing;

	while( thereIsData )
	{
		Compute( theThing );
		specWidget->SetSpectrum( theThing->GetMagBuffer(),
					 theThing->GetSpectralRange() );

		Fl::wait( 0.1 );
	}

	delete topLevel;

	return 0;
}

/// Code snippet end

Some notes on this code:

a) The Fl_SMS_Spectrum widget can only plot the spectrum power in dBs.
You must make sure that your spectrum has the MagBuffer dynamic
attribute and that its scale is CLAM::EScale::eLog.

b) In this sample dsp code and gui code share the same thread of
execution. The Fl::wait(...) call is a blocking one that executes
several steps in the FLTK event loop.

I suppose you will be wondering what the Plot stuff does. Basically it
handles the spectrum data format conversions transparently and insulates
your code from FLTK.

Miguel.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFA/i0TlsjEsEvuavcRAg4rAJ9HJ4Q94VwpaXOYAopI9QCunwcz0gCfZRp9
yCY1QsRwDMAYpV5ecd9czYE=
=tkSL
-----END PGP SIGNATURE-----




More information about the clam-users mailing list