AudioThumbnail example


i can’t get any pciture out of this class

	fi = new FileInputSource (File (T("d:\\file.ogg")));

	thumbnail = new AudioThumbnail (128, *AudioFormatManager::getInstance(), cache);
	thumbnail->addChangeListener (this);
	thumbnail->setSource (fi);

and in my paint method

thumbnail->drawChannel (g, 16, 64, getWidth()-128, getHeight()-128, 0, thumbnail->getTotalLength(), thumbnail->getNumChannels(), 1.0f);

i get the callback info, but i don’t know how to set the AudioThmubnailCache, i initialize it with 512, and the AudioThumbnail with 128 and i tired more. and nothing paints itself.

does anyone have a working example of how to use this, i see that the cache is a TimeSliceThread, i don’t know if i have to start it myself?

i don’t want to post a third post (someone will hate me), i was wondering if anyone had any examples on how to write a frequency analyzer component, like in any audio player.


I do mine like this:

	// set up the format manager to read basic formats
	formatManager = new AudioFormatManager();
	// instansiate the cache and the thumbnail
	thumbnailCache = new AudioThumbnailCache(2);
	thumbnailViewLow = new AudioThumbnail(512, *formatManager, *thumbnailCache);

Then the drawing in the same way you have. Bare in mind that you have to draw each of the channels separately eg. channel 0 for left and 1 for right. If your using thumbnail->getNumChannels() it will return 2 (most probably) so you’re trying to draw a channel that doesn’t exist.


damn …

your right, rookie mistake.

it works now, thanks.