I would like to know if there is any support (existing or planned) for .NET.
I intend to use FMOD with Visual C# or if necessary with VB .NET.
I got a sample-program to run under Visual C#, but I had to migrate everything by hand.
Thanks for any information. Prem.

  • You must to post comments

I cannot see Brett wanting to go to that effort for the 3.xx series since all his efforts are on FMOD4 for the foreseeable future. So, if we want .NET usability for the 3.xx series, then we will have to go with the PInvoke approach and have the two DLLs. That’s a small price to pay for being able to easily use FMOD in any .NET language.

  • You must to post comments

[quote:3t8fmme9]Are you using the stdcall version of FMOD? That is a requirement since .NET does not how to handle cdecl functions. As for the error when returning from the callback, yes we are all getting that. Not sure how to handle that one. But we will keep trying.[/quote:3t8fmme9]
I thought I had tried both DLL versions, but I’m not sure as I am still not 100% with .NET 2003. I will go over this again later and be sure. I’ve got the feeling that both DLL versions manage to play files, set/receive callbacks and then crash when leaving the callback.

To get me going for now I am just ignoring the error in a Try block. I’m sure you all have tried this, did you get a long delay before the system came back every time the callback fired?

[quote:3t8fmme9]Chua Wen Ching
Actually i not sure that delegates can be used to replace callback? Is it wrong?

I’m not sure what you mean, the delegate does work to the point of firing the callback (the difficult bit!), it’s just when the callback returns that a problem occurs.

Brett, any ideas?

  • You must to post comments

FMOD is not a COM component. To use FMOD from a .NET language, you must use the PInvoke mechanism (System.Runtime.InteropServices) to call unmanaged functions in DLLs from managed code. I have started wrapping the FMOD 3.63 functions into an assembly that can be used from any .NET language. It is nowhere near complete yet though.

  • You must to post comments

Just to help everyone out, I found this c# wrapper for FMOD while on the net one day, but I can’t remember where I found it (I thought I found it here!). Anyways, I can’t take any credit for it as it’s not my work, but unfortunately, the author left no hint of who he was in the source code.

Since it was freely downloadable when I got it, I wouldn’t imagine there would be any problem with me posting a link to it on my webserver. If you are the author and happen to see this and want me to take it down though, I will.

You can get it here:

  • You must to post comments

The code for Delphi for .NET is very similar to C#. The DllImport directive is exactly the same bar the double quotes. The only thing different is the function declaration.[code:1gtbv4dn][DllImport(’fmod.dll’, EntryPoint = ‘_FSOUND_Init@12’)]
function FSOUND_Init(mixrate, maxsoftwarechannels: Integer; flags: Cardinal); external;[/code:1gtbv4dn]FMOD would be considered unsafe code due to the use of pointers. Managed code does not allow the use of pointers so that the CLR (Common Language Runtime) can perform garbage collection and keep everything nice and orderly.

  • You must to post comments

Take a look at some of the FMOD samples and the documentation for more information on callbacks. You can do most things without using callbacks, but for some special effects or functionality you do need to use callbacks.

  • You must to post comments

[quote="djerik":bb2z39zu]Theres been a lot of postings about the “FMOD .NET” and the FMOD4, but I can’t find any releases regarding these?

Is the .NET wrapper developed? When will it be released?
And how about FMOD4? When? Can it also be easy integrated into .NET without PInvoke?[/quote:bb2z39zu]

Well, it’s been a few months, and I’d like to know the answers to these questions, too.

So… bump

  • You must to post comments

Well, you might be right … I sent him a very small/limited/hacked together sample of how I would do it yesterday evening (the wrapper in Managed C++ and the test-sample in C#). The effort is really not that much more. Even if it is not done for the 3.xx series, he should consider it for FMOD 4. It is much cleaner, IMHO. I guess, this decision is really governed by other factors. How long will it be until version 4 comes around? Does he still want to have version 3.xx floating around?

Everybody using C# should be able to write their own P/Invoke wrapper anyways. Using P/Invoke you should be able to wrap FMOD in its entirety over a weekend. I haven’t looked much into the DSP stuff, but that should also be possible, having FMOD callback C# or VB.NET code … although this requires the FMOD version, which uses stdcall for callbacks.


  • You must to post comments

Thanks a lot…

Oh is return back the values having problem.. hmm!

Is there any complete website out there that compare C++ and C# entirely.. based on features…


use Callback in C++ and use Delegates in C#

even compare functions, etc!

I am having much problem understanding c++.. never intend to learn c++

Chua Wen Ching :p

  • You must to post comments

Okay.. affirmative!

Chua Wen Ching :p

  • You must to post comments

Is there any news on the Microsoft .NET Interface Brett? Also what happened to the link above, it doesn’t seem to work anymore!

  • You must to post comments

i tried already once to post this, but it seems it didn’t work.
i had no problem to migrate fmod.bas to C# and VB.NET. and it works fine. only callbacks i could not get to work. and that’s the most important part for me, because i want the program to react immediately when a piece is finished.

ps: i do have a problem playing very short mp3-pieces. they have a strong noise when they start playing.

  • You must to post comments

I will look into the docs and samples!


Chua Wen Ching :p

  • You must to post comments

I’ve been developing a media player in VB.NET 2003 for about a month or so, I use it everyday with no problem, meaning, I never get any errors generated by FMod.

I have had some strange errors with the newer version of FMod though, I use instead of the newer release, because, it generates some error while playing certain WMA files.

Hopefully you guys come out with a .NET friendly dll soon :)

  • You must to post comments

I just tried to do a small test in C#. I got a small assembly going with init and close working, but got stuck at trying to pass a String to a function that expects a char *.

Not that I’m really serious about using C#. To me it still feels like too much work to do the simplest thing.

  • You must to post comments

I don’t know of any site that compares the two languages.

There are loads of useful resources though, try:


C++ is much more difficult to program in Microsoft Windows than other operating systems as you need to know so much about the OS.

  • You must to post comments


Hmm, I have a similar problem with callbacks. It occurs when I use Row or Order callbacks in conjunction with the DSP unit:

[code:1qinnal9]using System;
using FmodNet;

namespace fmodtest
class MainClass
static bool bStop = false;

    public static void RowCallback(FMUSIC.MODULE mod, byte param)

    public static void OrderCallback(FMUSIC.MODULE mod, byte param)

    static void Main(string[] args)
        Console.WriteLine ("FmodNet Demo\n");
        Console.WriteLine ("Using FMOD Version: {0}", FSOUND.GetVersion());

        FSOUND.Init(44100, 32, 0);

        FMUSIC.MODULE mod = FMUSIC.LoadSong("test2.xm");

        // set callbacks
        FMUSIC.SetRowCallback(mod, new FMUSIC.CALLBACK(RowCallback), 1);
        FMUSIC.SetOrderCallback(mod, new FMUSIC.CALLBACK(OrderCallback), 1);


        FSOUND.DSP_SetActive(fftDSP, true);

        float[] spectrum = FSOUND.DSP_GetSpectrum();
        int c = 0;
        while (!FMUSIC.IsFinished(mod))
            spectrum = FSOUND.DSP_GetSpectrum();




Playback just hangs. I don’t know whether this is a problem with the way I wrapped things, or a general issue with the CLR and multithreading. Strangely enough, if I just use the DSP unit or the callbacks it works. Also, on another strange note. Your example works fine for me. I’m almost done with my wrapper. I plan on releasing a useable version this weekend or sometime next week. BTW, I like how you have everything nested. I also wanted to do that, but it’s just too much typing for now :)

I’ll switch over to VS.NET 2003 soonish … maybe that fixes it. I don’t see what I could be doing wrong here. Other than that, I only have a few more functions to go (mostly reverb, some 3D sound functions, dsp mixing, and loading from memory). It’s definitely good enough to start working with FMOD using .NET.


  • You must to post comments

If you could bug Microsoft that would be great if as I’m now having some issues with my VB.net implementation of a multiple soundcard example

I noticed that you say that Version 3.70 now uses stdCall which i believe now means that us VB people dont need the dirty hack of fmod1.dll, fmod2.dll, fmod1.bas, fmod2.bas etc. to run two sounds at once on two different soundcards – right!?

You see the problem i get is that when i call the New constructor on a second instance of my fmod class, the fSound_SetOutput call (see below) returns false. And when I examine the error message using fsound_geterrorstring it says

Cannot call this command after fsound_init. Call Fsound_close first

Which would suggest to me that even though i have a new instance of my class (which i have proved upon examining other properties in my class) it is still referencing the same instance of the fmod.dll

I was wondering if anyone has succesfully managed to get either C# or VB to load 2 separate instances of the fmod.dll (version 3.70)?

I’ve included a basic implementation of my class with its constructor where the problem is located
(To anyone who can fix this for me – I owe you a drink!) 😀

By the way – I forgot to mention, I have tried using FSOUND_OUTPUT_WINMM and that made no difference!



Public Class Zone

'An instance of the fmodnet.fsound class (A converted fmod.bas module done by the .net upgrade wizard)
Private mFmodController As New Fmodnet.FSOUND()    
Public Sub New(ByVal strName As String, ByVal intOutputDevice As Integer)

    Dim blnSuccess As Boolean

    'Set the preffered output method for FMOD (Always Direct X)
    blnSuccess = CBool(mFmodController.FSOUND_SetOutput(FSOUND_OUTPUTTYPES.FSOUND_OUTPUT_DSOUND))

    If Not blnSuccess Then
        'Setting the desired output driver (DirectSound) didnt work so throw an exception
        Throw New System.Exception( _
        "FSOUND_SetOutput:" & _

    End If

    'Set the preffered soundcard for this zone
    blnSuccess = CBool(mFmodController.FSOUND_SetDriver(intOutputDevice))

    If Not blnSuccess Then
        'Setting the soundcard for this zone didnt work so throw an exception
        Throw New System.Exception( _
        "FSOUND_SetDriver:" & _

    End If

    'Create a new instance of the fmod.dll through the assembly
    blnSuccess = CBool(mFmodController.FSOUND_Init(44100, 32, FSOUND_INITMODES.FSOUND_INIT_GLOBALFOCUS))

    If Not blnSuccess Then
        'If the intialisation of FMOD didn't work throw an exception
        Throw New System.Exception( _
            "FSOUND_Init:" & _
    End If

    'If we get here then everything is ready to go, so update the class properties
    'with the values passed in
    Me.Name = strName                   'The name of the zone
    Me.OutputDevice = intOutputDevice   'The soundcard device it uses

End Sub

End Class

And i’m sorry about all this code but here’s the declaration of the functions in the dll (as i mentioned in the comment above it is simply an upgraded fmod.bas file with everything taken out in this example to save on reading. Its just there to give you an idea how im declaring the api in VB.net

Namespace Fmodnet

'FMOD VB6 Module

Public Class FSOUND

    Public Const FMOD_VERSION As Double = 3.7

    '* Enums

    ' On failure of commands in FMOD, use FSOUND_GetError to attain what happened.
    Public Enum FMOD_ERRORS
        FMOD_ERR_NONE ' No errors
        FMOD_ERR_BUSY ' Cannot call this command after FSOUND_Init.  Call FSOUND_Close first.
        FMOD_ERR_UNINITIALIZED ' This command failed because FSOUND_Init was not called
        FMOD_ERR_INIT ' Error initializing output device.
        FMOD_ERR_ALLOCATED ' Error initializing output device, but more specifically, the output device is already in use and cannot be reused.
        FMOD_ERR_PLAY ' Playing the sound failed.
        FMOD_ERR_OUTPUT_FORMAT ' Soundcard does not support the features needed for this soundsystem (16bit stereo output)
        FMOD_ERR_COOPERATIVELEVEL ' Error setting cooperative level for hardware.
        FMOD_ERR_CREATEBUFFER ' Error creating hardware sound buffer.
        FMOD_ERR_FILE_NOTFOUND ' File not found
        FMOD_ERR_FILE_FORMAT ' Unknown file format
        FMOD_ERR_FILE_BAD ' Error loading file
        FMOD_ERR_MEMORY ' Not enough memory
        FMOD_ERR_VERSION ' The version number of this file format is not supported
        FMOD_ERR_INVALID_PARAM ' An invalid parameter was passed to this function
        FMOD_ERR_NO_EAX ' Tried to use an EAX command on a non EAX enabled channel or output.
        FMOD_ERR_CHANNEL_ALLOC ' Failed to allocate a new channel
        FMOD_ERR_RECORD ' Recording is not supported on this machine
        FMOD_ERR_MEDIAPLAYER ' Windows Media Player not installed so cannot play wma or use internet streaming.
        FMOD_ERR_CDDEVICE ' An error occured trying to open the specified CD device
    End Enum

    ' These output types are used with FSOUND_SetOutput, to choose which output driver to use.
    ' FSOUND_OUTPUT_DSOUND will not support hardware 3d acceleration if the sound card driver
    ' does not support DirectX 6 Voice Manager Extensions.
    ' FSOUND_OUTPUT_WINMM is recommended for NT and CE.
        FSOUND_OUTPUT_NOSOUND ' NoSound driver, all calls to this succeed but do nothing.
        FSOUND_OUTPUT_WINMM ' Windows Multimedia driver.
        FSOUND_OUTPUT_DSOUND ' DirectSound driver.  You need this to get EAX2 or EAX3 support, or FX api support.
        FSOUND_OUTPUT_A3D ' A3D driver.
        FSOUND_OUTPUT_OSS ' Linux/Unix OSS (Open Sound System) driver, i.e. the kernel sound drivers.
        FSOUND_OUTPUT_ESD ' Linux/Unix ESD (Enlightment Sound Daemon) driver.
        FSOUND_OUTPUT_ALSA ' Linux Alsa driver.
        FSOUND_OUTPUT_ASIO ' Low latency ASIO driver
        FSOUND_OUTPUT_XBOX ' Xbox driver
        FSOUND_OUTPUT_PS2 ' PlayStation 2 driver
        FSOUND_OUTPUT_MAC ' Mac SoundManager driver
        FSOUND_OUTPUT_GC ' Gamecube driver
        FSOUND_OUTPUT_NOSOUND_NONREALTIME ' This is the same as nosound, but the sound generation is driven by FSOUND_Update
    End Enum

    ' These mixer types are used with FSOUND_SetMixer, to choose which mixer to use, or to act
    ' upon for other reasons using FSOUND_GetMixer.
    ' It is not nescessary to set the mixer.  FMOD will autodetect the best mixer for you.
        FSOUND_MIXER_AUTODETECT ' CE/PS2 Only - Non interpolating/low quality mixer
        FSOUND_MIXER_BLENDMODE ' removed / obsolete.
        FSOUND_MIXER_MMXP5 ' removed / obsolete.
        FSOUND_MIXER_MMXP6 ' removed / obsolete.
        FSOUND_MIXER_QUALITY_AUTODETECT ' All platforms - Autodetect the fastest quality mixer based on your cpu.
        FSOUND_MIXER_QUALITY_FPU ' Win32/Linux only - Interpolating/volume ramping FPU mixer.
        FSOUND_MIXER_QUALITY_MMXP5 ' Win32/Linux only - Interpolating/volume ramping FPU mixer.
        FSOUND_MIXER_QUALITY_MMXP6 ' Win32/Linux only - Interpolating/volume ramping ppro+ MMX mixer.
        FSOUND_MIXER_MONO ' CE/PS2 only - MONO non interpolating/low quality mixer. For speed
        FSOUND_MIXER_QUALITY_MONO ' CE/PS2 only - MONO Interpolating mixer.  For speed
    End Enum

    ' These definitions describe the type of song being played.
    ' See FMUSIC_GetType
    Public Enum FMUSIC_TYPES
        FMUSIC_TYPE_MOD 'Protracker / Fasttracker
        FMUSIC_TYPE_S3M 'ScreamTracker 3
        FMUSIC_TYPE_XM 'FastTracker 2
        FMUSIC_TYPE_IT 'Impulse Tracker.
        FMUSIC_TYPE_FSB 'FMOD Sample Bank file
    End Enum

    ' These default priorities are used by FMOD internal system DSP units.  They describe the
    ' position of the DSP chain, and the order of how audio processing is executed.
    ' You can actually through the use of FSOUND_DSP_GetxxxUnit (where xxx is the name of the DSP
    ' unit), disable or even change the priority of a DSP unit.
        FSOUND_DSP_DEFAULTPRIORITY_SFXUNIT = 100 'DSP SFX unit - done second
        FSOUND_DSP_DEFAULTPRIORITY_USER = 300 'User priority, use this as reference for your own dsp units
        FSOUND_DSP_DEFAULTPRIORITY_FFTUNIT = 900 'This reads data for FSOUND_DSP_GetSpectrum, so it comes after user units
    End Enum

    ' Driver description bitfields.  Use FSOUND_Driver_GetCaps to determine if a driver enumerated
    ' has the settings you are after.  The enumerated driver depends on the output mode, see
    Public Enum FSOUND_CAPS
        FSOUND_CAPS_HARDWARE = &H1S ' This driver supports hardware accelerated 3d sound.
        FSOUND_CAPS_EAX2 = &H2S ' This driver supports EAX 2 reverb
        FSOUND_CAPS_EAX3 = &H10S ' This driver supports EAX 3 reverb
    End Enum

    ' Sample description bitfields, OR them together for loading and describing samples.
    ' NOTE.  If the file format being loaded already has a defined format, such as WAV or MP3, then
    ' trying to override the pre-defined format with a new set of format flags will not work.  For
    ' example, an 8 bit WAV file will not load as 16bit if you specify FSOUND_16BITS.  It will just
    ' ignore the flag and go ahead loading it as 8bits.  For these type of formats the only flags
    ' you can specify that will really alter the behaviour of how it is loaded, are the following.
    ' FSOUND_2D
    ' See flag descriptions for what these do.
    Public Enum FSOUND_MODES
        FSOUND_LOOP_OFF = &H1S ' For non looping samples.
        FSOUND_LOOP_NORMAL = &H2S ' For forward looping samples.
        FSOUND_LOOP_BIDI = &H4S ' For bidirectional looping samples.  (no effect if in hardware).
        FSOUND_8BITS = &H8S ' For 8 bit samples.
        FSOUND_16BITS = &H10S ' For 16 bit samples.
        FSOUND_MONO = &H20S ' For mono samples.
        FSOUND_STEREO = &H40S ' For stereo samples.
        FSOUND_UNSIGNED = &H80S ' For source data containing unsigned samples.
        FSOUND_SIGNED = &H100S ' For source data containing signed data.
        FSOUND_DELTA = &H200S ' For source data stored as delta values.
        FSOUND_IT214 = &H400S ' For source data stored using IT214 compression.
        FSOUND_IT215 = &H800S ' For source data stored using IT215 compression.
        FSOUND_HW3D = &H1000S ' Attempts to make samples use 3d hardware acceleration. (if the card supports it)
        FSOUND_2D = &H2000S ' Ignores any 3d processing.  overrides FSOUND_HW3D.  Located in software.
        FSOUND_STREAMABLE = &H4000S ' For realtime streamable samples.  If you dont supply this sound may come out corrupted.
        FSOUND_LOADMEMORY = &H8000S ' For FSOUND_Sample_Load - name will be interpreted as a pointer to data
        FSOUND_LOADRAW = &H10000 ' For FSOUND_Sample_Load/FSOUND_Stream_Open - will ignore file format and treat as raw pcm.
        FSOUND_MPEGACCURATE = &H20000 ' For FSOUND_Stream_Open - scans MP2/MP3 (VBR also) for accurate FSOUND_Stream_GetLengthMs/FSOUND_Stream_SetTime.
        FSOUND_FORCEMONO = &H40000 ' For forcing stereo streams and samples to be mono - needed with FSOUND_HW3D - incurs speed hit
        FSOUND_HW2D = &H80000 ' 2d hardware sounds.  allows hardware specific effects
        FSOUND_ENABLEFX = &H100000 ' Allows DX8 FX to be played back on a sound.  Requires DirectX 8 - Note these sounds cant be played more than once, or have a changing frequency
        FSOUND_MPEGHALFRATE = &H200000 ' For FMODCE only - decodes mpeg streams using a lower quality decode, but faster execution
        FSOUND_XADPCM = &H400000 ' For XBOX only - Describes a user sample that its contents are compressed as XADPCM
        FSOUND_VAG = &H800000 ' For PS2 only - Describes a user sample that its contents are compressed as Sony VAG format.
        FSOUND_NONBLOCKING = &H1000000 ' For FSOUND_Stream_Open - Causes stream to open in the background and not block the foreground app - stream plays only when ready.
        FSOUND_GCADPCM = &H2000000 ' For Gamecube only - Contents are compressed as Gamecube DSP-ADPCM format
        FSOUND_MULTICHANNEL = &H4000000 ' For PS2 only - Contents are interleaved into a multi-channel (more than stereo) format
        FSOUND_USECORE0 = &H8000000 ' For PS2 only - Sample/Stream is forced to use hardware voices 00-23
        FSOUND_USECORE1 = &H10000000 ' For PS2 only - Sample/Stream is forced to use hardware voices 24-47
        FSOUND_LOADMEMORYIOP = &H20000000 ' For PS2 only - "name" will be interpreted as a pointer to data for streaming and samples.  The address provided will be an IOP address
        FSOUND_STREAM_NET = &H80000000 ' Specifies an internet stream
    End Enum

    ' Playback method for a CD Audio track, with FSOUND_CD_SetPlayMode
        FSOUND_CD_PLAYCONTINUOUS 'Starts from the current track and plays to end of CD.
        FSOUND_CD_PLAYONCE 'Plays the specified track then stops.
        FSOUND_CD_PLAYLOOPED 'Plays the specified track looped, forever until stopped manually.
        FSOUND_CD_PLAYRANDOM 'Plays tracks in random order
    End Enum

    ' Miscellaneous values for FMOD functions.
    ' FSOUND_PlaySound, FSOUND_PlaySoundEx, FSOUND_Sample_Alloc, FSOUND_Sample_Load, FSOUND_SetPan
        FSOUND_FREE = -1 ' definition for dynamically allocated channel or sample
        FSOUND_UNMANAGED = -2 ' definition for allocating a sample that is NOT managed by fsound
        FSOUND_ALL = -3 ' for a channel index or sample index, this flag affects ALL channels or samples available!  Not supported by all functions.
        FSOUND_STEREOPAN = -1 ' definition for full middle stereo volume on both channels
        FSOUND_SYSTEMCHANNEL = -1000 ' special channel ID for channel based functions that want to alter the global FSOUND software mixing output channel
        FSOUND_SYSTEMSAMPLE = -1000 ' special sample ID for all sample based functions that want to alter the global FSOUND software mixing output sample
    End Enum

    ' FSOUND_Reverb_SetProperties, FSOUND_Reverb_GetProperties, FSOUND_REVERB_PROPERTYFLAGS
        Dim Environment As Integer ' 0       25     0       sets all listener properties
        Dim EnvSize As Single ' 1.0     100.0  7.5     environment size in meters
        Dim EnvDiffusion As Single ' 0.0     1.0    1.0     environment diffusion
        Dim Room As Integer ' -10000  0      -1000   room effect level (at mid frequencies)
        Dim RoomHF As Integer ' -10000  0      -100    relative room effect level at high frequencies
        Dim RoomLF As Integer ' -10000  0      0       relative room effect level at low frequencies
        Dim DecayTime As Single ' 0.1     20.0   1.49    reverberation decay time at mid frequencies
        Dim DecayHFRatio As Single ' 0.1     2.0    0.83    high-frequency to mid-frequency decay time ratio
        Dim DecayLFRatio As Single ' 0.1     2.0    1.0     low-frequency to mid-frequency decay time ratio
        Dim Reflections As Integer ' -10000  1000   -2602   early reflections level relative to room effect
        Dim ReflectionsDelay As Single ' 0.0     0.3    0.007   initial reflection delay time
        <VBFixedArray(3)> Dim ReflectionsPan() As Single '                0,0,0   early reflections panning vector
        Dim Reverb As Integer ' -1000   2000   200     late reverberation level relative to room effect
        Dim ReverbDelay As Single ' 0.0     0.1    0.011   late reverberation delay time relative to initial reflection
        <VBFixedArray(3)> Dim ReverbPan() As Single '                0,0,0   late reverberation panning vector
        Dim EchoTime As Single ' .075    0.25   0.25    echo time
        Dim EchoDepth As Single ' 0.0     1.0    0.0     echo depth
        Dim ModulationTime As Single ' 0.04    4.0    0.25    modulation time
        Dim ModulationDepth As Single ' 0.0     1.0    0.0     modulation depth
        Dim AirAbsorptionHF As Single ' -100    0.0    -5.0    change in level per meter at high frequencies
        Dim HFReference As Single ' 1000.0  20000  5000.0  reference high frequency (hz)
        Dim LFReference As Single ' 20.0    1000.0 250.0   reference low frequency (hz)
        Dim RoomRolloffFactor As Single ' 0.0     10.0   0.0     like FSOUND_3D_SetRolloffFactor but for room effect
        Dim Diffusion As Single ' 0.0     100.0  100.0   Value that controls the echo density in the late reverberation decay. (xbox only)
        Dim Density As Single ' 0.0     100.0  100.0   Value that controls the modal density in the late reverberation decay (xbox only)
        Dim flags As Integer '                        modifies the behavior of above properties

        'UPGRADE_TODO: "Initialize" must be called to initialize instances of this structure. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1026"'
        Public Sub Initialize()
            ReDim ReflectionsPan(3)
            ReDim ReverbPan(3)
        End Sub
    End Structure

    ' Values for the Flags member of the FSOUND_REVERB_PROPERTIES structure.
        FSOUND_REVERBFLAGS_DECAYTIMESCALE = &H1S ' EnvironmentSize affects reverberation decay time
        FSOUND_REVERBFLAGS_REFLECTIONSSCALE = &H2S ' EnvironmentSize affects reflection level
        FSOUND_REVERBFLAGS_REFLECTIONSDELAYSCALE = &H4S ' EnvironmentSize affects initial reflection delay time
        FSOUND_REVERBFLAGS_REVERBSCALE = &H8S ' EnvironmentSize affects reflections level
        FSOUND_REVERBFLAGS_REVERBDELAYSCALE = &H10S ' EnvironmentSize affects late reverberation delay time
        FSOUND_REVERBFLAGS_DECAYHFLIMIT = &H20S ' AirAbsorptionHF affects DecayHFRatio
        FSOUND_REVERBFLAGS_ECHOTIMESCALE = &H40S ' EnvironmentSize affects echo time
        FSOUND_REVERBFLAGS_MODULATIONTIMESCALE = &H80S ' EnvironmentSize affects modulation time
        FSOUND_REVERB_FLAGS_CORE0 = &H100S ' PS2 Only - Reverb is applied to CORE0 (hw voices 0-23)
        FSOUND_REVERB_FLAGS_CORE1 = &H200S ' PS2 Only - Reverb is applied to CORE1 (hw voices 24-47)
    End Enum

    ' Structure defining the properties for a reverb source, related to a FSOUND channel.
    ' FSOUND_Reverb_SetEnvironment, FSOUND_Reverb_SetEnvironmentAdvanced
        Dim Direct As Integer ' direct path level (at low and mid frequencies)
        Dim DirectHF As Integer ' relative direct path level at high frequencies
        Dim Room As Integer ' room effect level (at low and mid frequencies)
        Dim RoomHF As Integer ' relative room effect level at high frequencies
        Dim Obstruction As Integer ' main obstruction control (attenuation at high frequencies)
        Dim ObstructionLFRatio As Single ' obstruction low-frequency level re. main control
        Dim Occlusion As Integer ' main occlusion control (attenuation at high frequencies)
        Dim OcclustionLFRatio As Single ' occlusion low-frequency level re. main control
        Dim OcclusionRoomRatio As Single ' relative occlusion control for room effect
        Dim OcclusionDirectRatio As Single ' relative occlusion control for direct path
        Dim Exclusion As Integer ' main exlusion control (attenuation at high frequencies)
        Dim ExclusionLFRatio As Single ' exclusion low-frequency level re. main control
        Dim OutsideVolumeHF As Integer ' outside sound cone level at high frequencies
        Dim DopplerFactor As Single ' like DS3D flDopplerFactor but per source
        Dim RolloffFactor As Single ' like DS3D flRolloffFactor but per source
        Dim RoomRolloffFactor As Single ' like DS3D flRolloffFactor but for room effect
        Dim AirAbsorptionFactor As Single ' multiplies AirAbsorptionHF member of FSOUND_REVERB_PROPERTIES
        Dim flags As Integer ' modifies the behavior of properties
    End Structure

    ' Values for the Flags member of the FSOUND_REVERB_CHANNELPROPERTIES structure.
        FSOUND_REVERB_CHANNELFLAGS_DIRECTHFAUTO = &H1S ' Automatic setting of Direct due to distance from listener
        FSOUND_REVERB_CHANNELFLAGS_ROOMAUTO = &H2S ' Automatic setting of Room due to distance from listener
        FSOUND_REVERB_CHANNELFLAGS_ROOMHFAUTO = &H4S ' Automatic setting of RoomHF due to distance from listener
    End Enum

    ' These values are used with FSOUND_FX_Enable to enable DirectX 8 FX for a channel.
    Public Enum FSOUND_FX_MODES
    End Enum

    'These are speaker types defined for use with the FSOUND_SetSpeakerMode command.
    'Note - Only reliably works with FSOUND_OUTPUT_DSOUND or FSOUND_OUTPUT_XBOX output modes.  Other output modes will only
    'interpret FSOUND_SPEAKERMODE_MONO and set everything else to be stereo.
    'Using either DolbyDigital or DTS will use whatever 5.1 digital mode is available if destination hardware is unsure.
        FSOUND_SPEAKERMODE_DOLBYDIGITAL ' The audio is played through a speaker arrangement of surround speakers with a subwoofer.
        FSOUND_SPEAKERMODE_HEADPHONE ' The speakers are headphones.
        FSOUND_SPEAKERMODE_MONO ' The speakers are monaural.
        FSOUND_SPEAKERMODE_QUAD ' The speakers are quadraphonic.
        FSOUND_SPEAKERMODE_STEREO ' The speakers are stereo (default value).
        FSOUND_SPEAKERMODE_SURROUND ' The speakers are surround sound.
        FSOUND_SPEAKERMODE_DTS ' The audio is played through a speaker arrangement of surround speakers with a subwoofer.
        FSOUND_SPEAKERMODE_PROLOGIC2 ' Dolby Prologic 2.  Playstation 2 and Gamecube only
    End Enum

    ' Initialization flags.  Use them with FSOUND_Init in the flags parameter to change various behaviour.
    ' FSOUND_INIT_ENABLEOUTPUTFX Is an init mode which enables the FSOUND mixer buffer to be affected by DirectX 8 effects.
    ' Note that due to limitations of DirectSound, FSOUND_Init may fail if this is enabled because the buffersize is too small.
    ' This can be fixed with FSOUND_SetBufferSize.  Increase the BufferSize until it works.
    ' When it is enabled you can use the FSOUND_FX api, and use FSOUND_SYSTEMCHANNEL as the channel id when setting parameters.
        FSOUND_INIT_USEDEFAULTMIDISYNTH = &H1S 'Causes MIDI playback to force software decoding.
        FSOUND_INIT_GLOBALFOCUS = &H2S 'For DirectSound output - sound is not muted when window is out of focus.
        FSOUND_INIT_ENABLEOUTPUTFX = &H4S 'For DirectSound output - Allows FSOUND_FX api to be used on global software mixer output!
        FSOUND_INIT_ACCURATEVULEVELS = &H8S 'This latency adjusts FSOUND_GetCurrentLevels, but incurs a small cpu and memory hit
        FSOUND_INIT_PS2_DISABLECORE0REVERB = &H10S 'PS2 only - Disable reverb on CORE 0 to regain SRAM
        FSOUND_INIT_PS2_DISABLECORE1REVERB = &H20S 'PS2 only - Disable reverb on CORE 1 to regain SRAM
        FSOUND_INIT_PS2_SWAPDMACORES = &H40S 'PS2 only - By default FMOD uses DMA CH0 for mixing, CH1 for uploads, this flag swaps them around
        FSOUND_INIT_DONTLATENCYADJUST = &H80S 'Callbacks are not latency adjusted, and are called at mix time.  Also information functions are immediate
        FSOUND_INIT_GC_INITLIBS = &H100S 'Gamecube only - Initializes GC audio libraries
        FSOUND_INIT_STREAM_FROM_MAIN_THREAD = &H200S 'Turns off fmod streamer thread, and makes streaming update from FSOUND_Update called by the user
    End Enum

    ' Status values for internet streams. Use FSOUND_Stream_Net_GetStatus to get the current status of an internet stream.
        FSOUND_STREAM_NET_NOTCONNECTED ' Stream hasn't connected yet
        FSOUND_STREAM_NET_CONNECTING ' Stream is connecting to remote host
        FSOUND_STREAM_NET_BUFFERING ' Stream is buffering data
        FSOUND_STREAM_NET_READY ' Stream is ready to play
        FSOUND_STREAM_NET_ERROR ' Stream has suffered a fatal error
    End Enum

    ' Describes the type of a particular tag field.
    ' See FSOUND_Stream_GetNumTagFields, FSOUND_Stream_GetTagField, FSOUND_Stream_FindTagField
        FSOUND_TAGFIELD_VORBISCOMMENT = 0 ' A vorbis comment
        FSOUND_TAGFIELD_ID3V1 ' Part of an ID3v1 tag
        FSOUND_TAGFIELD_ID3V2 ' An ID3v2 frame
        FSOUND_TAGFIELD_SHOUTCAST ' A SHOUTcast header line
        FSOUND_TAGFIELD_ICECAST ' An Icecast header line
        FSOUND_TAGFIELD_ASF ' An Advanced Streaming Format header line
    End Enum

    ' These values describe the protocol and format of an internet stream. Use FSOUND_Stream_Net_GetStatus to retrieve this information for an open internet stream.
        FSOUND_FORMAT_MPEG = &H10000
    End Enum

    '/* ================================== */
    '/* Callbacks */
    '/* ================================== */

    Public Delegate Sub STREAMCALLBACK(ByRef stream As IntPtr, ByRef buff As IntPtr, ByVal len As Integer, ByVal param As Integer)

    '/* ================================== */
    '/* Initialization / Global functions. */
    '/* ================================== */

    ' PRE - FSOUND_Init functions. These cant be called after FSOUND_Init is
    ' called (they will fail). They set up FMOD system functionality.

    'UPGRADE_WARNING: Structure FSOUND_OUTPUTTYPES may require marshalling attributes to be passed as an argument in this Declare statement. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1050"'
    Public Declare Function FSOUND_SetOutput Lib "fmod.dll" Alias "_FSOUND_SetOutput@4" (ByVal outputtype As FSOUND_OUTPUTTYPES) As Byte
    Public Declare Function FSOUND_SetDriver Lib "fmod.dll" Alias "_FSOUND_SetDriver@4" (ByVal driver As Integer) As Byte
    'UPGRADE_WARNING: Structure FSOUND_MIXERTYPES may require marshalling attributes to be passed as an argument in this Declare statement. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1050"'
    Public Declare Function FSOUND_SetMixer Lib "fmod.dll" Alias "_FSOUND_SetMixer@4" (ByVal mixer As FSOUND_MIXERTYPES) As Byte
    Public Declare Function FSOUND_SetBufferSize Lib "fmod.dll" Alias "_FSOUND_SetBufferSize@4" (ByVal lenms As Integer) As Byte
    Public Declare Function FSOUND_SetHWND Lib "fmod.dll" Alias "_FSOUND_SetHWND@4" (ByVal hwnd As Integer) As Byte
    Public Declare Function FSOUND_SetMinHardwareChannels Lib "fmod.dll" Alias "_FSOUND_SetMinHardwareChannels@4" (ByVal min As Short) As Byte
    Public Declare Function FSOUND_SetMaxHardwareChannels Lib "fmod.dll" Alias "_FSOUND_SetMaxHardwareChannels@4" (ByVal min As Short) As Byte
    Public Declare Function FSOUND_SetMemorySystem Lib "fmod.dll" Alias "_FSOUND_SetMemorySystem@20" (ByVal pool As Integer, ByVal poollen As Integer, ByVal useralloc As Integer, ByVal userrealloc As Integer, ByVal userfree As Integer) As Byte

    '   Main initialization / closedown functions.
    '   Note : Use FSOUND_INIT_USEDEFAULTMIDISYNTH with FSOUND_Init for software override
    '          with MIDI playback.
    '        : Use FSOUND_INIT_GLOBALFOCUS with FSOUND_Init to make sound audible no matter
    '          which window is in focus. (FSOUND_OUTPUT_DSOUND only)

    'UPGRADE_WARNING: Structure FSOUND_INITMODES may require marshalling attributes to be passed as an argument in this Declare statement. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1050"'
    Public Declare Function FSOUND_Init Lib "fmod.dll" Alias "_FSOUND_Init@12" (ByVal mixrate As Integer, ByVal maxchannels As Integer, ByVal flags As FSOUND_INITMODES) As Byte
    Public Declare Function FSOUND_Close Lib "fmod.dll" Alias "_FSOUND_Close@0" () As Integer

    '   Runtime system level functions

    Public Declare Function FSOUND_Update Lib "fmod.dll" Alias "_FSOUND_Update@0" () As Integer

    'UPGRADE_WARNING: Structure FSOUND_SPEAKERMODES may require marshalling attributes to be passed as an argument in this Declare statement. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1050"'
    Public Declare Function FSOUND_SetSpeakerMode Lib "fmod.dll" Alias "_FSOUND_SetSpeakerMode@4" (ByVal speakermode As FSOUND_SPEAKERMODES) As Integer
    Public Declare Function FSOUND_SetSFXMasterVolume Lib "fmod.dll" Alias "_FSOUND_SetSFXMasterVolume@4" (ByVal volume As Integer) As Integer
    Public Declare Function FSOUND_SetPanSeperation Lib "fmod.dll" Alias "_FSOUND_SetPanSeperation@4" (ByVal pansep As Single) As Integer
    Public Declare Function FSOUND_File_SetCallbacks Lib "fmod.dll" Alias "_FSOUND_File_SetCallbacks@20" (ByVal OpenCallback As Integer, ByVal CloseCallback As Integer, ByVal ReadCallback As Integer, ByVal SeekCallback As Integer, ByVal TellCallback As Integer) As Integer

    ' System information functions.

    Public Declare Function FSOUND_GetError Lib "fmod.dll" Alias "_FSOUND_GetError@0" () As FMOD_ERRORS
    Public Declare Function FSOUND_GetVersion Lib "fmod.dll" Alias "_FSOUND_GetVersion@0" () As Single
    Public Declare Function FSOUND_GetOutput Lib "fmod.dll" Alias "_FSOUND_GetOutput@0" () As FSOUND_OUTPUTTYPES
    Public Declare Function FSOUND_GetOutputHandle Lib "fmod.dll" Alias "_FSOUND_GetOutputHandle@0" () As Integer
    Public Declare Function FSOUND_GetDriver Lib "fmod.dll" Alias "_FSOUND_GetDriver@0" () As Integer
    Public Declare Function FSOUND_GetMixer Lib "fmod.dll" Alias "_FSOUND_GetMixer@0" () As FSOUND_MIXERTYPES
    Public Declare Function FSOUND_GetNumDrivers Lib "fmod.dll" Alias "_FSOUND_GetNumDrivers@0" () As Integer
    Public Declare Function FSOUND_GetDriverName Lib "fmod.dll" Alias "_FSOUND_GetDriverName@4" (ByVal id As Integer) As Integer
    Public Declare Function FSOUND_GetDriverCaps Lib "fmod.dll" Alias "_FSOUND_GetDriverCaps@8" (ByVal id As Integer, ByRef caps As Integer) As Byte
    Public Declare Function FSOUND_GetOutputRate Lib "fmod.dll" Alias "_FSOUND_GetOutputRate@0" () As Integer
    Public Declare Function FSOUND_GetMaxChannels Lib "fmod.dll" Alias "_FSOUND_GetMaxChannels@0" () As Integer
    Public Declare Function FSOUND_GetMaxSamples Lib "fmod.dll" Alias "_FSOUND_GetMaxSamples@0" () As Integer
    Public Declare Function FSOUND_GetSFXMasterVolume Lib "fmod.dll" Alias "_FSOUND_GetSFXMasterVolume@0" () As Integer
    Public Declare Function FSOUND_GetNumHardwareChannels Lib "fmod.dll" Alias "_FSOUND_GetNumHardwareChannels@0" () As Integer
    Public Declare Function FSOUND_GetChannelsPlaying Lib "fmod.dll" Alias "_FSOUND_GetChannelsPlaying@0" () As Integer
    Public Declare Function FSOUND_GetCPUUsage Lib "fmod.dll" Alias "_FSOUND_GetCPUUsage@0" () As Single
    Public Declare Sub FSOUND_GetMemoryStats Lib "fmod.dll" Alias "_FSOUND_GetMemoryStats@8" (ByRef currentalloced As Integer, ByRef maxalloced As Integer)

    '* FUNCTIONS (Added by Adion)
    'Usage: myerrorstring = FSOUND_GetErrorString(FSOUND_GetError)
    Public Function FSOUND_GetErrorString(ByVal errorcode As Integer) As String
        Select Case errorcode
            Case FMOD_ERRORS.FMOD_ERR_NONE : FSOUND_GetErrorString = "No errors"
            Case FMOD_ERRORS.FMOD_ERR_BUSY : FSOUND_GetErrorString = "Cannot call this command after FSOUND_Init.  Call FSOUND_Close first."
            Case FMOD_ERRORS.FMOD_ERR_UNINITIALIZED : FSOUND_GetErrorString = "This command failed because FSOUND_Init was not called"
            Case FMOD_ERRORS.FMOD_ERR_PLAY : FSOUND_GetErrorString = "Playing the sound failed."
            Case FMOD_ERRORS.FMOD_ERR_INIT : FSOUND_GetErrorString = "Error initializing output device."
            Case FMOD_ERRORS.FMOD_ERR_ALLOCATED : FSOUND_GetErrorString = "The output device is already in use and cannot be reused."
            Case FMOD_ERRORS.FMOD_ERR_OUTPUT_FORMAT : FSOUND_GetErrorString = "Soundcard does not support the features needed for this soundsystem (16bit stereo output)"
            Case FMOD_ERRORS.FMOD_ERR_COOPERATIVELEVEL : FSOUND_GetErrorString = "Error setting cooperative level for hardware."
            Case FMOD_ERRORS.FMOD_ERR_CREATEBUFFER : FSOUND_GetErrorString = "Error creating hardware sound buffer."
            Case FMOD_ERRORS.FMOD_ERR_FILE_NOTFOUND : FSOUND_GetErrorString = "File not found"
            Case FMOD_ERRORS.FMOD_ERR_FILE_FORMAT : FSOUND_GetErrorString = "Unknown file format"
            Case FMOD_ERRORS.FMOD_ERR_FILE_BAD : FSOUND_GetErrorString = "Error loading file"
            Case FMOD_ERRORS.FMOD_ERR_MEMORY : FSOUND_GetErrorString = "Not enough memory "
            Case FMOD_ERRORS.FMOD_ERR_VERSION : FSOUND_GetErrorString = "The version number of this file format is not supported"
            Case FMOD_ERRORS.FMOD_ERR_INVALID_PARAM : FSOUND_GetErrorString = "An invalid parameter was passed to this function"
            Case FMOD_ERRORS.FMOD_ERR_NO_EAX : FSOUND_GetErrorString = "Tried to use an EAX command on a non EAX enabled channel or output."
            Case FMOD_ERRORS.FMOD_ERR_CHANNEL_ALLOC : FSOUND_GetErrorString = "Failed to allocate a new channel"
            Case FMOD_ERRORS.FMOD_ERR_RECORD : FSOUND_GetErrorString = "Recording is not supported on this machine"
            Case FMOD_ERRORS.FMOD_ERR_MEDIAPLAYER : FSOUND_GetErrorString = "Required Mediaplayer codec is not installed"
            Case FMOD_ERRORS.FMOD_ERR_CDDEVICE : FSOUND_GetErrorString = "An error occured trying to open the specified CD device"
            Case Else : FSOUND_GetErrorString = "Unknown error"
        End Select
    End Function

End Class

End Namespace

  • You must to post comments

Just to notify there is .Net C++ its included as an extention to C++. I got it with microsoft visual C++.Net 2002 edition in project types its named as “Managed C++ Application” or “Managed C++ Class Library”

  • You must to post comments

Hi Sly again!

I just notice your wrapper you did!

I compare with the vb6 wrapper (*.bas)!

There are a lot and a lot of enums you did not code? You only focus on FSOUND right and not FMUSIC?

Is it bcs FMUSIC is not compatible or you did not had the time to continue this wrapper?

If it is bcs you don’t have the time, maybe i can try my best to come out the full c# wrapper for it!

There are couple of *.h files in the include folder? 1 is fmod.h, but there are other too like fmoddyn.h, fmod_errors.h? Those i also need to convert too?

If yes, so to write a wrapper, all the header files must be converted! Only header files? Hmm.. if yes.. wow.. that is not that hard as i expected!

Any comments?


Chua Wen Ching :p

  • You must to post comments
Showing 1 - 20 of 75 results
Your Answer

Please first to submit.