Tuesday, March 8, 2011

Visualizing Music - Part 2

I've finally managed to fix the crash.It was quite an ugly race condition, the rendering thread wanted access to the same scene node as the music playback thread, it's not exactly clear where and why, it's hidden in the internals of Ogre, I guess.
Anyway, I've managed to fix it by locking on the same semaphore as used in the callback function in frameStarted() and unlocking it in frameEnded(). So it's finally working, thanks to my friend for pointing it out. Release comming soon.

Meanwhile, I've been experimenting a bit with perl, I rewrote the SDL Music Visualizer example to render a frequency spectrum (aka bars).
I found a nice module for doing the Fourier Transform, Math::FFT.

You can find the code here: https://github.com/balazsbela/Visualizer/blob/master/frequency.pl

And here's a screenshot:




All this in 210 lines of Perl. Perl is indeed awesome.

No comments: