I am trying to make a Vu-Meter for a simple demo that I am coding.
I am using the FSOUND_DSP_GetSpectrum() function but I did not need a 512 entries of resolution, as I’m trying to do a vu-meter like winamp one.
I think that I have to convert the 512 float array to a smaller one (20-32) by doing an average or something similar.
Is ok doing the average? or there is a better method?
Thanks in advance.
Best regards from spain (sorry for my english 😉 )
- mashupishu asked 17 years ago
Frequency band amplitude means that index 0 of array is the amplitude of first 43 Hz of the sound (from 0 Hz to 43 Hz, theoretically); index 1 of array means 43 Hz to 86 Hz), and so on…
Sound is composed of a lot of frequencies. For example, if u take a song there are basses and kick drums(they are in lower positions of array: 100-200 Hz), there may be voices (around 600-800 Hz) and there are hihats, various instruments like pianos (more than 2 kHz). So your piano will be represented on the upper level of array, voices in the middle part and basses in the lower part.
However basses are concentrated into 300 Hz of amplitude while trebles are spreaded into more than 16000 Hz! So your vu-level goes up only in the first part. It’s normal!
The step of 43 Hz derives from this formula:
This means that you r sampling at 44100 Hz, but for Nyquist theory we can heard only half the frequencies, so 44100 Hz / 2 = 22050 Hz.
Again, Fast Fourier Transformation (FFT) is 512 values wide, so 22050 Hz / 512 = 43 Hz per step!
I don’t directly the function GetFFT, but there is the possibility that lower 256 indexes of array represents the positive signal and latest 256 indexes represents the negative signal. If so, you will see two graphs instead of only one graph! (Means that there is, from middle to end of the graph, another repetition of first 256 entries). But I don’t think Brett impemented this because it isn’t so useful without an IFFT (Inverse Fourier Fast Transformation).
Thanks <b>blackshard</b> you opened my eyes :wink:, now I understand the GetSpectrum function at all.
From the tests that I am running, you are right thinking that the function is not repeated in the array (after the first 256 values) as the vu-meter has little or no movement in the right side of it.
Again thanks and now I must think how to reduce the information from GetSpectrum to a few moving bars (16-32).
Hello, I’m back again 😉
A few days ago I was seeing a piece of code from a winamp plugin that implements a spectrum analyzer.
In this plugin the mapping between the spectrum frequencies and the moving bars is done in a strange maner (they have two pointers to the spectrum data, like GetSpectrum, but for two channels): For the left bar (first one) only two entries are added and a log function applied to it later. For the next bar the following two entries are used but for the third three are used, 4 for the fourth, 7 for the fifth, 9 for the sixth the complete serie is this: 2 2 3 4 5 7 9 11 14 17 21 26 32 38 45 52
It looks like some exponential function.
This serie must be interpreted in the following way for example, the last value 52 says that for the right most bar you have to add the last 52 values together and later apply a log function to this value.
And my question is this, why? 😀 I know that the human ear responds in a logarithmic way but for what reason are this numbers taken, and no others?
<font size=-1>[ This Message was edited by: mashupishu on 2001-10-29 04:00 ]</font>
Sincerely, I don’t know. Those Fast Fourier Transformations are pretty interesting for me, but I don’t know the meaning of those numbers. I can hazard a hypotesis: they may be some kind of complementary values. Imagine that the first band is multiplied with 2, the second with 2, the third with 3… and so on… the last one is multiplied with 52. The result are bands with equal amplitudes…
Maybe I’m wrong, so if there is anyone who knows something about those magic numbers… please, illumate us!
Yes, I have noticed this, the right side of the vu-meter is nearly always at a lower value (near 0).
I think that my problem is that I don’t know what is the meaning of each entry of the array returned by GetSpectrum.
From the documentation:
“represent each frequency band’s amplitude”
frecuency band amplitude?? what is this?
(I am not a sound expert 😉 )
Please login first to submit.