‘Warning: You should set the fft dsp to active before retreiving the spectrum
‘Also make sure the array you pass is dimensioned and ready to use
‘FSOUND_DSP_SetActive FSOUND_DSP_GetFFTUnit, 1
Public Function GetSpectrum(ByRef Spectrum() As Single)
Dim nrOfVals As Long, lpSpectrum As Long
Dim a As Long
If UBound(Spectrum) > 511 Then nrOfVals = 512 Else nrOfVals = UBound(Spectrum) + 1
lpSpectrum = FSOUND_DSP_GetSpectrum
CopyMemory Spectrum(0), ByVal lpSpectrum, nrOfVals * 4
So there is the problem the ByVal lpSpectrum in the CopyMemory statment DOES NOT work in VB.net which i use. I works perfectly in vb6 no problems. I am using 3.73 Fmod. VB.net no longer recognizes the syntax “ByVal lp Spectrum”, it give me the error “Expression expected.”
I have spent about 7 hours now trying to get this thing to work, you can’t simply declare the CopyMemory function …
“Private Declare Sub CopyMemory Lib “kernel32” Alias “RtlMoveMemory” (ByRef Destination As Single, [color=red:27tg2nef]ByVal[/color:27tg2nef] Source As Long, ByVal length As Integer)”
That causes the function to drop out of execution. I have tried using Marshal to no avail it simple drops out of the execution like it knows an exception will occour.
I have been trying to “port” the fmod.bas over to VB.net with some luck I have an fmod class with the simple functionality (like init, play pause echo etc). The class’s purpose is to handle the “grunt work” of the fmod system and allow full compatability for .net usage.
I need help, help me, this problem is making my hair turn white!!!!!
- Kurtnelle asked 13 years ago
You haven’t specified so here, but remember that all VB6 ‘Long’s need to be replaced by ‘Integer’s.
I think what should work is:
[code:162a1xp9]Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As Single, ByVal Source As Integer, ByVal length As Integer)[/code:162a1xp9]
Also make sure to replace the ‘Long’ lpSpectrum declaration to ‘Integer’
I don’t have .NET installed here, so I can’t try it out myself, but I think that should do it.
- Adion answered 13 years ago
Good show dude.
Private Declare Sub CopyMemory Lib “kernel32” Alias “RtlMoveMemory” (ByRef Destination As Single, ByVal Source As Integer, ByVal length As Integer)
with lpSpectrum as integer and nrOfVals as integer
Much respect, I knew that another programmers point of view would help me see the obvoius 😆
Guess what? It no longer works!
I was modyfing the code didn’t touch that part of it at all, now the fmod getspectrum doens’t return any data whatsoever, all I am getting in the debug is 512 0.0’s
When i put the “ByRef” (instead of byval) back into the copy memory declare it gives me back the same problem.
I dont know I think my PC is conspiring to drive me insane.
Is Fmod’s GetSpectrum function known to cause problems where it doesn’t return any data? (as in the data at the pointer location it returns has no data)
I know the FFTUnit is active Fmod GetActive(FFTUnit) returns true.
The problem is not in the GetSpectrum function it's in the declaration of the CopyMemory function,I'am using VB.NET and the spectrum works fine but only with the following code:
<Private Declare Sub CopyMemory Lib “kernel32” Alias “RtlMoveMemory” (ByRef Destination As Integer, ByVal Source As Integer, ByVal length As Integer>
if you use (Destination As Single) you will get an empty array,I don’t know why,i Tried Microsoft’s WebSite but No Help(As Usual).
Also note that you will have to do some math works on the returned values(You will notice what i mean) as this INTEGER thing seems to miss around some where in the fmod calculations.
- Anonymous answered 13 years ago
Please login first to submit.