Thanks to Schranz0r for sorting the double-pointer problem, the following code shows how to use the latest version of FMOD with currently Windows and Mac (Linux cant be used).
You will need FMOD to be installed (or to get the libraries from somewhere). The DLL/dylib goes in with the executable.
The test code is :
OK = FMOD_Init(32,0)
LOCAL Snd%
OKs = FMOD_CreateSound("Music.mp3",0,Snd%)
LOCAL chan%
play = FMOD_PlaySound(0,Snd%,0,chan%)
WHILE KEY(57)=0
PRINT OK,10,10
PRINT OKs,10,20
PRINT Snd,10,30
PRINT play,10,40
PRINT chan,10,50
SHOWSCREEN
WEND
FMOD_Close()
END
And the main interface code is :
INLINE
#include "fmod.h"
FMOD_SYSTEM *fSystem;
DGArray<FMOD_SOUND*> fsound;
DGArray<FMOD_CHANNEL*> fchannel;
ENDINLINE
FUNCTION FMOD_Init%:maxChannels%,flags%
LOCAL result%
INLINE
result=FMOD_System_Create(&fSystem);
if (result==FMOD_OK)
{
result=FMOD_System_Init(fSystem,maxChannels,flags,0);
}
return result;
ENDINLINE
ENDFUNCTION
FUNCTION FMOD_CreateSound%:fileName$,mode%,BYREF sound%
LOCAL result%
INLINE
FMOD_SOUND* xsound;
result = FMOD_System_CreateSound(fSystem,fileName_Str.c_str(),mode,NULL,&xsound);
if (result==FMOD_OK) { // all ok!
REDIM(fsound(),LEN(fsound())+1);
fsound(LEN(fsound())-1) = xsound;
sound = LEN(fsound())-1; // set the handle to sound
}
return result;
ENDINLINE
ENDFUNCTION
FUNCTION FMOD_PlaySound%:channelID%,sound%,paused%,BYREF channel%
LOCAL result%
INLINE
FMOD_CHANNEL* xchannel;
result=FMOD_System_PlaySound(fSystem,(FMOD_CHANNELINDEX) channelID,fsound(sound),(bool) paused,&xchannel);
if (result==FMOD_OK) { // all ok!
REDIM(fchannel(),LEN(fchannel())+1);
fchannel(LEN(fchannel())-1) = xchannel;
channel = LEN(fchannel())-1; // set the handle to channel
}
return result;
ENDINLINE
ENDFUNCTION
FUNCTION FMOD_Close:
INLINE
return FMOD_System_Close(fSystem);
ENDINLINE
ENDFUNCTION
At the moment its only just enough to get a tune working - but it does work...
For windows users, your project will need to have the following added :
cmp : -L"X:\Programming\GLBasic"
lnk : -L"X:\Programming\GLBasic" -lfmodex_vc
Mac just need :
cmp : -L"X:\Programming\GLBasic" -lfmodex
Linux cant be used because it needs a later version of STDC++, LIBC than included in GLBasic...
Nice :good:
Its a shame about the Linux version - but Gernot would need to use a later version of GCC before it'll work...
a newer gcc for linux? Oh dear. I'll try.
Yes - the newer FMOD requires STDC++.so.6, which in turn requires a later version of GCC and LIBC. I think there was also something else needed as well too...