0
0

Hi. I’m trying to use FMOD to play some music inside a VB.NET application for a college project. I used FMOD in the past with C++ in Windows and Linux with much success, but I am a complete n00b in VB. I followed the instructions in the help and included the file fmod.bas in my project. However, when I compile I get lots of errors:

[code:e69wen2j]C:\BaseDatosCompositores\fmod.bas(208) : error BC30802: Ya no se admiten las instrucciones ‘Type’; utilice las instrucciones ‘Structure’ en su lugar.
C:\BaseDatosCompositores\fmod.bas(210) : error BC30188: Se esperaba una declaración.
C:\BaseDatosCompositores\fmod.bas(211) : error BC30188: Se esperaba una declaración.
C:\BaseDatosCompositores\fmod.bas(212) : error BC30188: Se esperaba una declaración.
...
vbc : error BC30041: Se ha excedido el número máximo de errores.[/code:e69wen2j]
I’m don’t know what I might be doing wrong, and the example included seems to be VB6. I couldn’t find any VB.NET implementation of a working FMOD solution, so I don’t know what to try next.

Help please!

Thanks in advance.

  • You must to post comments
0
0

I’m glad it helped. :)

I’m getting that error, too. I’m trying to trace it, but it seems quite random. Please tell me if you manage to reproduce it.

Cheers.

Reminder to self: avoid VB.NET in the future 😕

  • You must to post comments
0
0

[quote="anacondo":7fnw1yxu]I’m glad it helped. :)

I’m getting that error, too. I’m trying to trace it, but it seems quite random. Please tell me if you manage to reproduce it.

Cheers.

Reminder to self: avoid VB.NET in the future :-?[/quote:7fnw1yxu]

Well it usually happens if/when I change the song position and it does it quite random as you said. The only thing I can come up with, is maybe all those variables aren’t required that you put? Or maybe if they are, FMod doesn’t always return the value for them, therefore throwing an ‘System.NullReferenceException’. Maybe one of the FMod guys can clue is in? Does the FSOUND_Stream_SetEndCallback always return it’s variables, or is the way we’re doing it incorrect?

  • You must to post comments
0
0

[quote="Pio":1o2kj57p]Well it usually happens if/when I change the song position and it does it quite random as you said. The only thing I can come up with, is maybe all those variables aren’t required that you put? Or maybe if they are, FMod doesn’t always return the value for them, therefore throwing an ‘System.NullReferenceException’. Maybe one of the FMod guys can clue is in? Does the FSOUND_Stream_SetEndCallback always return it’s variables, or is the way we’re doing it incorrect?[/quote:1o2kj57p]
I tried playing (removing/adding) with the FSOUND_Stream_SetEndCallback parameters and it seems to crash everytime a song ends. Using them all sometimes it crashes, sometimes not.

Anyways, right now I’m using a TrackBar and a Timer to control song position, with TrackBar.MaxValue = FSOUND_Stream_GetLengthMs(stream). If I check inside the timer if TrackBar.Value = MaxValue I know in a quite lame, unefficient and embarrassing way if a song has ended :oops:. But at least it doesn’t crash! :roll:

If you are controlling song position you can try something like this until someone else brings some light to the crashing issue or we find a better solution.

Good luck.

  • You must to post comments
0
0

VB6 and VB.NET are not the same. Meaning, some of the syntax has changed. You must “upgrade” your VB6 FMod Module (fmod.bas) to VB.NET compatible code. There should be a “upgrade wizard” in the Tools menu on VB.NET.

  • You must to post comments
0
0

I was using a routine like that before, worked perfectly, with no errors. I’d like to do it the proper way.

  • You must to post comments
0
0

Thanks, it seems to work now. 8)

Cheers.

  • You must to post comments
0
0

[code:2bzhaey6]
Public Shared Function Media_GetLengthBytes() As Integer
Return FSOUND_Stream_GetLength(streamHandle)
End Function

Public Shared Function Media_GetPositionBytes() As Integer
    Return FSOUND_Stream_GetPosition(streamHandle)
End Function

[/code:2bzhaey6]

I’m using this and checking it like so…

[code:2bzhaey6]
If mMedia.Media_GetPositionBytes >= mMedia.Media_GetLengthBytes Then
Call EndOfStream()
End If
[/code:2bzhaey6]

  • You must to post comments
0
0

FSOUND_Stream_SetEndCallback is not working for me in VB.NET:

[code:1ic14oh9]Public Function endStream(ByVal stream As Long, ByVal buff As Long, ByVal len As Long, ByVal param As Long) As Long
MsgBox("Se finí")
endStream = 1
End Function

Public Sub ...
[...]
stream = FSOUND_Stream_Open(path, fmod.FSOUND_MODES.FSOUND_NORMAL, 0, 0)
canal = FSOUND_Stream_Play(fmod.FSOUND_CHANNELSAMPLEMODE.FSOUND_FREE, stream)
FSOUND_Stream_SetEndCallback(stream, AddressOf endStream, 0)
End Sub[/code:1ic14oh9]
The error returned is something like: An ‘AddressOf’ expression can’t be converted to ‘Integer’ because ‘Integer’ is not a delegate type.

I browsed the forums and this seems to be working with VB6. Do I need to change something else?

Thanks in advance.

  • You must to post comments
0
0

I think that I have fixed it. I’m still in the process of testing, but so far I’ve played 5 songs (with changing position and such) and it hasn’t errored once (yet).

[code:2l3qcpbb]
Public Declare Ansi Function FSOUND_Stream_SetEndCallback Lib "fmod.dll" Alias "_FSOUND_Stream_SetEndCallback@12" (ByVal stream As Integer, ByVal callback As endStreamDelegate, ByVal userdata As Integer) As Byte
[/code:2l3qcpbb]

[code:2l3qcpbb]
Public Delegate Function endStreamDelegate(ByVal stream As Integer, ByVal buff As Integer, ByVal len As Integer, ByVal param As Integer) As Integer
Public Shared da As endStreamDelegate
[/code:2l3qcpbb]

[code:2l3qcpbb]
Public Shared Function EOS(ByVal stream As Integer, ByVal buff As Integer, ByVal len As Integer, ByVal param As Integer) As Integer
Debug.WriteLine("eos->" & stream)
End Function
[/code:2l3qcpbb]

[code:2l3qcpbb]
streamHandle = FSOUND_Stream_Open(Path, FSOUND_MODES.FSOUND_NORMAL, 0, 0)
da = New endStreamDelegate(AddressOf EOS)
Call FSOUND_Stream_SetEndCallback(streamHandle, da, 0)
[/code:2l3qcpbb]

  • You must to post comments
0
0

Nevermind, I managed to solve it. :roll:

Cheers.

  • You must to post comments
0
0

Testing… works sweetly by now. 😀

Thanks a lot.

  • You must to post comments
0
0

I really wish you would post the code you used for your solution to that problem. Again, you should not be using Long’s inplace of Integers in Visual Basic .NET

VB6:
Integer = 16-bit
[b:wph4b7jd]Long = 32-bit[/b:wph4b7jd]

VB.NET:
Short = 16-Bit
[b:wph4b7jd]Integer = 32-Bit[/b:wph4b7jd]
Long = 64-bit

  • You must to post comments
0
0

Sure. Thanks for the long-integer tip, btw.

[b:273bi9ln]fmod.vb (converted from fmod.bas):[/b:273bi9ln]
[code:273bi9ln]Module fmod

+Delegate Function endStreamDelegate(ByVal stream As Integer, ByVal buff As Integer, ByVal len As Integer, ByVal param As Integer) As Integer

[...]

-Public Declare Function FSOUND_Stream_SetEndCallback Lib "fmod.dll" Alias "_FSOUND_Stream_SetEndCallback@12" (ByVal stream As Integer, ByVal callback As Integer, ByVal userdata As Integer) As Byte

+Public Declare Function FSOUND_Stream_SetEndCallback Lib "fmod.dll" Alias "_FSOUND_Stream_SetEndCallback@12" (ByVal stream As Integer, ByVal callback As endStreamDelegate, ByVal userdata As Integer) As Byte

[...]

End Module
[/code:273bi9ln]
[b:273bi9ln]My code[/b:273bi9ln]:
[code:273bi9ln]Public Class whatever

[...]

Public Function endStream(ByVal stream As Integer, ByVal buff As Integer, ByVal len As Integer, ByVal param As Integer) As Integer
[...]
End Function

stream = FSOUND_Stream_Open("datos\snd\" & lista.SelectedItems.Item(0).Text & ".dat", fmod.FSOUND_MODES.FSOUND_NORMAL, 0, 0)

canal = FSOUND_Stream_Play(fmod.FSOUND_CHANNELSAMPLEMODE.FSOUND_FREE, stream)

FSOUND_Stream_SetEndCallback(stream, AddressOf endStream, 0)

[...]

End Class[/code:273bi9ln]
Hope this helps. Too hard for me to explain this in english, something about delegate functions (google for AddressOf and delegate for a proper explanation).

Cheers.

  • You must to post comments
0
0

No problem at all. The code you provided worked like a charm, thank you very much.

  • You must to post comments
0
0

No problem at all. The code you provided worked like a charm, thank you very much.

edit: I do however come across some strange errors from time to time,:

An unhandled exception of type ‘System.NullReferenceException’ occurred in Unknown Module.

Additional information: Object reference not set to an instance of an object.

  • You must to post comments
Showing 15 results
Your Answer

Please first to submit.