Hayo, people. I managed to make sort of web-audioplayer and everything is fine, unless one thing - this FFT function. I clearly understand how this function works with one exception - I have no idea what exactly does it output.
Here is my “visualisator”:
VisPanel.Paint = function (self,w,h) draw.RoundedBox (0,0,0,w,h,CDarkGray) stream:FFT (vis_magnitudes, FFT_8192) for i = 1, 50 do draw.RoundedBox (0,10+i*5,90-math.sqrt(vis_magnitudes[i*64])*200,4,1+math.sqrt(vis_magnitudes[i*64])*200,CWhite) end end
- Trouble is that vis_magnitudes contains numbers from 0 to 1 and I have no idea what does they mean.
- Also, this wiki page says that if I need sound volume in decibels, I should make something like
, but the values of this function are making me mad and they have no connection to the reality.
3. So how can I make visualizer with real magnitudes in decibels?
I’ve probably got to explain something, you can skip it without any worries:
CDarkGray = Color(50,50,50,255)
I use FFT_8192 because the larger this number is - the smoother is the movement of rectangles, although I don’t need all of them and that’s why I use only one value per 64.
The cycle is running for 1 to 50, because last 12-16 values are usually nearly equivalent, and this is not what visualizer need IMO.
No, there is no noticeable impact on performance while using this function.
P.S. Excuse me for any mistakes in my English and don’t hesitate to clarify anything!