I am new to OpenGL programming and have just learnt some basic stuff on drawing simple waveforms.
Some time ago I saw a great tool which includes a DPO (Digital Phosphor Oscilloscope). Take a look at the picture below with respect to the above waveform:
Notice the bright white lightning which separates the low frequency from the high frequency’s. When for example a sine wave of 1kHz is mixed with a lot of high frequency’s, the high frequency’s will be displayed green and the sine wave will be highlighted.
I have overlooked the picture over and over but did not find out how to do the same with OpenGL. Is there a simple trick which implements this feature? Or is it a custom algorithm?
You will have to use a high-pass or a low-pass filter. I’m not sure about OpenGL 4, but in the earlier versions there’s no special feature that does what you want to do, so you have to implement it yourself.
That is totally not what you need.
Instead, do that each frame :
-with substractive blending, draw a black quad, very transparent but not totally, to darken a bit previous stuff.
-with additive blending, draw current waveform
After several frames, you will have accumulated enough to make it look like above.
First use only front-buffer rendering, to test, then use an FBO instead for better robusteness.
Well, a black quad has RGB color (0, 0, 0, alpha), if you subtract 0 from something it remains such as it was. How will subtractive blending help? You probably mean a black rect, but not exactly black, i.e. gray.
This would work if the high frequency components were noisy and low frequency is really a sine wave. But what if both are noisy (say if the low-frequency signal were a speech signal)?
I don’t see what’s wrong with HP and LP filter idea? You take a sample period, filter, multiply with window, do the FFT and draw twice. It sounds reasonable to me.
Ok, I have setup a 3D buffer with x,y,z values. Each time a frame comes in I shift it into the 3D buffer. Each time a pixel is hit the Z value increases. A separated thread decreases the Z values so the waveform fades out. The Z value represents a 16 level deep intensity which varies from 0 to 255. Repetitive waveforms will highlight.
The only thing I have to do is write my own line function where I can set each pixel intensity myself instead of setting the line intensity.