0
0

Instructions for using FMOD with VB.NET (easily)

I have built a DLL from the C# interface, it is here : [url:2zx0rm50]http://www.megaupload.com/fr/?d=I41271ZF[/url:2zx0rm50]

In case the Megaupload link goes down, you can rebuild the DLL by yourself, explained at bottom.

TYPICAL USAGE FOR USING THE DLL WITH VB:

Step 1

  • Download and install the FMOD SDK.

Step 2

  • Create a new VB project (say name is "FMODTEST")

  • On Project menu, select "FMODTEST properties"

  • On tab "References", click "Add", select "Browse" tab and point to FMOD.DLL
    (This DLL is the file produced from the C# interface, explained at bottom. Alternatively, you may have downloaded it from the Megaupload link)

Step 3

  • Project menu -> "Add existing item", point now to "fmodex.dll"
    (Normally "C:\Program Files\FMOD SoundSystem\FMOD Programmers API Win32\api")

Step 4

  • On Solution Explorer (Ctrl+Alt+L), click "Show all files"

  • Copy the "fmodex.dll" to "bin\Debug" folder,
    so when you test your program, VB will find the DLL along the .EXE of your app.

  • On your code, type "Imports FMOD"

The syntax will be a little bit different, though …


Here is an example for VB.NET (ASIO)

Imports FMOD

Public Class Form1

Region "Declarations"

Region "Variables"

Dim pitch As Double = 1.0
Dim vol As Double = 1.0

End Region

Region "Constants"

Private Shared Fresult As New FMOD.RESULT
Private Shared Fsystem As New FMOD.System
Private Shared groupA, groupB, groupC, masterGroup As New FMOD.ChannelGroup
Const DefaultVolume As Single = 1.0
Const DefaultPitch As Single = 1.0

End Region

End Region

Region "Init & De-Init"

Public Sub New()

    ' This call is required by the Windows Form Designer.
    InitializeComponent()

    ' Add any initialization after the InitializeComponent() call.

    FMOD_Initialize()

End Sub

Private Sub FMOD_Initialize()

    Fresult = FMOD.Factory.System_Create(Fsystem)
    ERRCHECK(Fresult)

    Dim msgres As MsgBoxResult '= MsgBox("asio : yes, normal : no", MsgBoxStyle.YesNo)
    msgres = MsgBoxResult.Yes

    Select Case msgres
        Case MsgBoxResult.Yes
            Fresult = Fsystem.setOutput(OUTPUTTYPE.ASIO)
            ERRCHECK(Fresult)
        Case MsgBoxResult.No

    End Select

    Fresult = Fsystem.init(100, FMOD.INITFLAG.NORMAL, Nothing)
    ERRCHECK(Fresult)

    Channels()

End Sub

Private Sub Channels()

    Fresult = Fsystem.createChannelGroup("A", groupA)
    ERRCHECK(Fresult)

    Fresult = Fsystem.createChannelGroup("B", groupB)
    ERRCHECK(Fresult)

    Fresult = Fsystem.createChannelGroup("C", groupC)
    ERRCHECK(Fresult)

    Fresult = Fsystem.getMasterChannelGroup(masterGroup)
    ERRCHECK(Fresult)

    Fresult = masterGroup.addGroup(groupA)
    ERRCHECK(Fresult)

    Fresult = masterGroup.addGroup(groupB)
    ERRCHECK(Fresult)

End Sub

Private Sub FMOD_DeInitialize()

    Fresult = Fsystem.close
    ERRCHECK(Fresult)

End Sub

Private Sub ERRCHECK(ByVal Fresult As FMOD.RESULT)

    If Fresult <> FMOD.RESULT.OK Then
        MsgBox("FMOD error ! " & Fresult & "-" & FMOD.Error.String(Fresult), MsgBoxStyle.Critical)
        Application.Exit()

    End If

End Sub

End Region

Private Sub PlaySound()

    Dim OpenFileDialog1 As New OpenFileDialog
    OpenFileDialog1.ShowDialog()

    Dim selectedsound As String = OpenFileDialog1.FileName
    Dim sound As New FMOD.Sound

    Fresult = Fsystem.createStream(selectedsound, FMOD.MODE.HARDWARE, sound)
    ERRCHECK(Fresult)

    Reset(AudioReset.PitchAndVolume)

    Dim channel As New FMOD.Channel

    Fresult = Fsystem.playSound(FMOD.CHANNELINDEX.FREE, sound, False, channel)
    ERRCHECK(Fresult)

End Sub

End Class


Alternatively, you can also recompile the FMOD C# interface when a new version is out :

  • Create a new C# Class Library project, say you name it "FMOD".

  • Change its namespace to FMOD, (In project menu, "FMOD properties", "Application" tab, "Namespace".

  • Add the files "fmod.cs", "fmod_dsp.cs", "fmod_errors.cs" to your project,

  • Build it,

  • And voila, you have an up to date FMOD dll in your "bin\Release" folder :-)

  • You must to post comments
0
0

[quote="aybe":1hzwtxwr]Instructions for using FMOD with VB.NET (easily)

I have built a DLL from the C# interface, it is here : [url:1hzwtxwr]http://www.megaupload.com/fr/?d=I41271ZF[/url:1hzwtxwr]

In case the Megaupload link goes down, you can rebuild the DLL by yourself, explained at bottom.

[/quote:1hzwtxwr]

Nice post aybe! I might reformat this and place it in the FMOD wiki, if that is OK with you?

cheers,
Templar

  • You must to post comments
0
0

I’m happy to help, actually FMOD helped me a lot so …

Yes no problem, put it on the Wiki.

Cheers 😀

  • You must to post comments
0
0

[quote="Templar":35cvxvxk][quote="aybe":35cvxvxk]Instructions for using FMOD with VB.NET (easily)

I have built a DLL from the C# interface, it is here : [url:35cvxvxk]http://www.megaupload.com/fr/?d=I41271ZF[/url:35cvxvxk]

In case the Megaupload link goes down, you can rebuild the DLL by yourself, explained at bottom.

[/quote:35cvxvxk]

Nice post aybe! I might reformat this and place it in the FMOD wiki, if that is OK with you?

cheers,
Templar[/quote:35cvxvxk]

Hi again,

I have updated a little bit the procedure, to be more understandable :

On the part for creating the DLL from the C# interface,
– Create a new C# Class Library named "FMOD"

On the top, when using FMOD.DLL, to specify that this DLL is the one produced from the C# interface, hence not present in the original SDK.

Okay, well i have just updated the text so you can update the Wiki as well,

Thank you.

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.