0
0

ok, the code from my previous post now works in VB 6.0,
so I imported it in VB.NET:
now the callback works fine on the first call to FSOUND_Update, but from the second call it throws a System.NullReference exception.

I read about another forum topic about this exception being thrown, and I know the solution in that case was using 32 bit integers, and not 64 bit long integers, but it’s not my case, since the Visual Studio Import procedure correctly translated all VB6 long inetgers to VB.NET short integers.

The import procedure did not provide declaring a delegate for the callback function, so I did it myself, and possibly the error is here:

these are the declarations:

Public Declare Function FSOUND_DSP_Create Lib "fmod.dll" Alias "_FSOUND_DSP_Create@12" ([color=red:3lzyfif2]ByVal Callback As DSPDelegate[/color:3lzyfif2], ByVal Priority As Integer, ByVal param As Integer) As Integer

Delegate Function DSPDelegate(ByVal originalbuffer As Integer, ByVal newbuffer As Integer, ByVal length As Integer, ByVal param As Integer) As Integer

and here’s the callback function (simplified at most, but still doesn’t work)

Public Function Callback(ByVal originalbuffer As Integer, ByVal newbuffer As Integer, ByVal length As Integer, ByVal param As Integer) As Integer
Debug.WriteLine(length)
Return newbuffer
End Function

the main code is:
(i removed full name qualifications here for readability)

FSOUND_SetMixer(FSOUND_MIXER_MONO)

FSOUND_SetOutput (FSOUND_OUTPUT_NOSOUND_NONREALTIME)
FSOUND_Init(44100, 32, 0)
hCbk = FMod.FSOUND_DSP_Create(AddressOf Callback, 303, 0)
FSOUND_DSP_SetActive(hCbk, True)
FSOUND_DSP_SetActive(FSOUND_DSP_GetClipAndCopyUnit, False)
FSOUND_Stream_SetBufferSize(250)

hFlussoDati = FSOUND_Stream_Open(NomeFile, FSOUND_NORMAL, 0, 0)
Duration = FSOUND_Stream_GetLengthMs(hFlussoDati)
FSOUND_Stream_Play(FSOUND_FREE, hFlussoDati)

Do
Try
FSOUND_Update()
Catch e As Exception
Debug.WriteLine(“FMOD Error: ” & FSOUND_GetError)
Debug.WriteLine(e.message)
End Try
Loop Until FSOUND_Stream_GetTime(hFlussoDati) >= 30000

the callback gets called only the first time, then FSOND_Update always throws an exception, output is:

1024
FMOD Error: 0
System.NullReferenceException: Object reference not set to an instance of an object.
FMOD Error: 0
System.NullReferenceException: Object reference not set to an instance of an object.
FMOD Error: 0
System.NullReferenceException: Object reference not set to an instance of an object.

Error occurs at the FSOUND_Update line, and before the callback gets executed

Hope someone can help, thanks :)

  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.