I have a problem with function GetSpectrum… On the first, it return values in single type – so that it was such as 1,002494E+09 .. So that, i change it to a Long type. Now is values such as 1024223857 .. But it is so large number… What can i do with this??
Is there some sample in Visual Basic?
PS: Sorry for my english
- Anonymous asked 13 years ago
I have the same problem i guess. What variable type should the spectrum values be read into? If I use Long, it gives me numbers from 0 to maybe like 400. I changed it to single, but the values are soooo small like 0.0000000000000000000000000000000000004325435 or such. Average user cant see that many percentages change in the graph really. If I power that with something to make it bigger, it looks only like meaningless jumping, not anything to do with music thats playing.
Btw I use vb6 enterprise edition, not .net.
This piece of code works fine
Public Sub Oscilater4()
Dim ix1, iy1, ix2, iy2
Dim Loopy As Long
If FSOUND_DSP_GetActive(FSOUND_DSP_GetFFTUnit) > 0 Then
Loopy = 0
ix1 = 0
ix2 = 0
iy1 = 0
iy2 = 0
Loopy = 0
Do While Loopy <> 256
iy1 = picSpectrum.ScaleHeight
iy2 = (SpectralData(Loopy) * (picSpectrum.ScaleHeight * (PicPosBottom)))
picSpectrum.Line (ix1, iy1)-(ix2, (picSpectrum.ScaleHeight – iy2)), RGB(0, 255, 0)
ix1 = ix1 + picSpectrum.ScaleWidth / 256
ix2 = ix1
Loopy = Loopy + 1
‘Enable it first
FSOUND_DSP_SetActive FSOUND_DSP_GetFFTUnit, 1
PicPosBottom is just an integer value to increase the spectrum when the volume is lowered, just set it to 1 using normal volume levels (128 – 255). I have it controlled on a slider set between 1 and 30.
Put the code into a timer or into a loop.
Dim SpectralData(256) As Single outside of the routine.
Hope it helps
- tbe answered 13 years ago
What version of VB do you use?,IF it’s VB.Net then those numbers are normal, That’s because under VB6 I could create a DSP FFT unit (Using FSOUND_Stream_CreateDSP) and activate it and that worked fine and returned a spectrum valus between (0 and 1) but under VB.Net i couldn’t get CallBacks to work correctly (Fmod problem ,not VB.Net) and i had to just retrieve the spectrum with out creating my own FFT Unit and returned numbers close to yours, but if you are good in math you can use them normally (You will end up with numbers between 9.2 and 10.2).
That’s may case of course, your problem maybe something else.
Please login first to submit.