0
0

After searching this forum i couldn’t find a solution for using multiple soundcards with fmod. Only one great idee for copying fmod.dll and making a copy of the library in Delphi.

Cause i work with C++ I had to search for a solution…. GOT IT ๐Ÿ˜€

Make as much copy’s of fmod.dll as you need and call them directly with [b:3ksfypt0]LoadLibrary/b:3ksfypt0;
Create [b:3ksfypt0]typedef[/b:3ksfypt0] declarations and use [b:3ksfypt0]GetProcAddress[/b:3ksfypt0]

Don’t forget to use [b:3ksfypt0]FreeLibrary[/b:3ksfypt0] to shutdown the connection with the dll!

This works for me in Borland C++ Builder 4 but the code (LoadLibrary, GetProcAddress and FreeLibrary) are windows calls (winbase.h) so it could be used in every C++ compiler.

You can download a small BCB4 VCL sample at: REMOVED CREATED A FMODDYN.H for BCB

Just use the Init(“dllname”) function where “dllname” is a copy of fmod.dll
in this way you can use as much players as you need with small code untill FMOD 4 is released 8)

Example of the BCB4 VCL component
EMCFMOD2 FMODPlayer1;
EMCFMOD2 FMODPlayer2;
FMODPlayer1->Init(“fmod.dll”);
FMODPlayer2->Init(“fmod2.dll”);

FMODPlayer1->InputOpen(“C:\music.mp3”); // calls FSOUND_STREAM_OPENFILE
FMODPlayer1->Play();
FMODPlayer2->InputOpen(“C:\music.mp3”);
FMODPlayer2->Play();

  • You must to post comments
0
0

Ok fixed it and tested it with fmod 3.62
Works fine now in Borland C++ Builder

[url:2z2z6z4t]http://home.planet.nl/~djmaze/fmoddynbcb.h[/url:2z2z6z4t]

  • You must to post comments
0
0

I assume for visual basic users, it would be as easy as copying the dll and the fmod.bas file, and just adding something to the alias names visual basic uses.
I think I’m gonna try this tommorow.

  • You must to post comments
0
0

Yep, i think just make variable of fmod.dll something like:

char fmoddll
function Init(char calldll) {
fmoddll = calldll;
}

and in the further in the .bas:
Public Declare Function FMUSIC_IsFinished Lib [b:25qvgsr7]fmoddll[/b:25qvgsr7] Alias “_FMUSIC_IsFinished@4” (ByVal module As Long) As Byte

donno if it works, have no experience with VB.

  • You must to post comments
0
0

Unfortunately I don’t think this kind of thing works in visual basic.

Now, I did manage to get multiple sound card support in vb by doing the following :
Copying fmod.dll to fmod2.dll
Copying fmod.bas to fmod2.bas

In fmod2.bas, changing
Public Declare Function FMUSIC_IsFinished Lib fmoddll Alias “_FMUSIC_IsFinished@4” (ByVal module As Long) As Byte
To
Public Declare Function FMUSIC2_IsFinished Lib “fmod2.dll” Alias “_FMUSIC_IsFinished@4” (ByVal module As Long) As Byte

Now you can just call FSOUND2_* and FMUSIC2_* for all things you want to do on soundcard 2 and FSOUND_* and FMUSIC_* for all things you want to do on soundcard 1.

Currently, there is only one problem with this :
All my effects are done in a visual c++ dll, also the creation of the dsp’s.
The dll is always using the fmod.dll, so I’ll probably have to change the dll so that the FSOUND_Stream_CreateDSP function is done in visual basic instead of in the dll, so that I can use FSOUND2_… when necessary.

  • You must to post comments
0
0

I doesn’t work here at my place ๐Ÿ˜ฅ

If my solution is completed i shall place it here for free 8)

I already changed from Ordinal (MAKEINTRESOURCE) to LPCSTR calling so every version of fmod could work with it.

It shall become a fully functional Borland C++ Builder VCL.
Including notifications of:
– Time
– Position
– PlayerStates (playing, stopped, pause, end)
etc.

If someone would help just drop a line here ๐Ÿ˜›

  • You must to post comments
0
0

Ok it almost works now!

Added: #include <stdlib.h>

Now i still get exception errors when i call a function.

BTW i’ve removed GetProcAddress by Ordinal it calls by function name now.
I only didn’t update the fmodwrap.zip yet.

  • You must to post comments
0
0

I’ve tried a couple of weeks but i can’t get the fmoddyn.h to work.

Always wenn i call a function and wants to recieve the data it throws a EAccessviolation error and shows this function:

function TControl.Perform(Msg: Cardinal; WParam, LParam: Longint): Longint;
var
Message: TMessage;
begin
Message.Msg := Msg;
Message.WParam := WParam;
Message.LParam := LParam;
Message.Result := 0;
if Self <> nil then WindowProc(Message);
Result := Message.Result;
end;

the error occurse @: if Self <> nil then WindowProc(Message);

I also don’t know why TControl is called, cause it’s not used.

Strange behaviour, couldn’t find solution so i’ll stick to mine solution for now.

  • You must to post comments
0
0

Damn stupid me, i’ve found the error!

If you see in the code below i used P_FMOD_INSTANCE twice.
(typedef FMOD_INSTANCE * P_FMOD_INSTANCE)
Sorry, sorry, sorry. In this point you can now pronounce me as EDIOT!

Code:

P_FMOD_INSTANCE fmod1;
//—————————————————————————
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//—————————————————————————
void __fastcall TForm1::Button1Click(TObject *Sender)
{
P_FMOD_INSTANCE fmod1 = FMOD_CreateInstance();
if (fmod1 == NULL) Label1->Caption = “not loaded”;
else fmod1->FSOUND_Init(44100, 1, FSOUND_INIT_GLOBALFOCUS);

// THIS WORKS!
}
//—————————————————————————
void __fastcall TForm1::Button2Click(TObject *Sender)
{
// HERE’S GOES THE ERROR!
const char *filename = Edit1->Text.c_str();
FSOUND_STREAM *fStream = fmod1->FSOUND_Stream_OpenFile(filename, FSOUND_NORMAL, 0);
}
//—————————————————————————
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
// HERE’S GOES THE ERROR TO!
fmod1->FSOUND_Close();
}
//—————————————————————————

  • You must to post comments
0
0

Well brett

after some modifications i finally managed to use fmoddyn.h in Borland C++ Builder.

I couldn’t call all functions due to errors so i placed /* */ between the procadresses i didn’t need sofar.

There’s still on minor:
When you call CreateInstance twice with 1 fmod.dll only 1 of them will play and not both at the same time.

I’ll send you the source by mail ๐Ÿ˜†

  • You must to post comments
Showing 9 results
Your Answer

Please first to submit.