I’m working on an application which incorporates a spectrogram for analyzing audio input. I’m
displaying the FFT (fast Fourier-Transform) data in the columns of my texture matrix (columns->time &
rows->freqeuncy). Everytime I recieve a new FFT frame of my audio input I move all columns but the
oldest (which is the last column) such that my new FFT frame can be inserted in the first column ; then
I can display my spectrogram.
My question is now:
Everytime I get a new FFT frame I move a lot of data around in my texture matrix which seems
like a redundant operation so does there exist a way of getting around this? I’ve been looking for a
method which overcomes this by adding an offset to the texture in the horizontal direction
(the time direction) and when the texture goes out of screen it should then appear in the opposite
side of the screen, but this method I have not stumbled upon - is this possible?
Hope to hear from you and that I made myself clear
Yes, that’s the best way to do it. Textures have clamping modes set to GL_REPEAT by default. Linear filtering between last and first texel also works if you need it.
You update texture row by row and each frame you add 1 texel offset to your texture coordinates.
Note that you should keep this offset in [0…1] range to avoid texture coordinate precision problems.
Ahhh, sorry that one should have been deleted. I’ve just been playing with the different rotations! It shouldn’t do much harm as it is now - or can it?