As the FMOD system isn't availiable, I'm trying to get one running (with the latest version of FMOD which still has a C interface in it) :
INLINE
DECLARE(FMOD_System_Init, "fmodex.dll", (int, int, int), int)
ENDINLINE
x=FMOD_System_Init(1,44100,8)
Unfortunately, all I get is get is call to undefined function : FMOD_System_Init (which is in the DLL).
Or with this one :
INLINE
DECLARE_ALIAS(FMOD_Init, "fmodex.dll","FMOD_System_Init",(int, int, int), int);
ENDINLINE
_FMOD_Init()
END
FUNCTION _FMOD_Init:
INLINE
FMOD_Init(1,44100,8);
ENDINLINE
ENDFUNCTION
I get error: `FMOD_Init' was not declared in this scope
Sorted the problem - it appears all the declare stuff cant be done in the main file...
The other thing : Can the DECLARE system be used with Mac's dylibs and Linux's .o files as I dont want to tied FMOD to just Windows
uhm... FMod is already wrapped in the samples/_projects_fmod_wrapper directory. No?
Yes, but its not the latest version - lets just say its slightly old... :)
The inline call in seperate file!
Or use:
WHILE TRUE
.. Bla some coder her...
WEND
END
FUNCTION foo:
ENDFUNCTION
INLINE
ENDINLINE
c-interface...
DECLARE_C_ALIAS ?
EDIT:WOW, no way to wrapp this DLL into GLBasic.... wtf
Quote
FMOD_RESULT FMOD_System_Init(
FMOD_SYSTEM * system,
int maxchannels,
FMOD_INITFLAGS flags,
void * extradriverdata
);
You can use the headers, but i think Bassmod would be better!
It took a while to work out a new file is needed to contain INLINE stuff.
One other problem I'm having at the moment is that CreateSound requires a double-pointer :
// --------------------------------- //
// Project: Test
// Start: Sunday, December 28, 2008
// IDE Version: 6.105
INLINE
#ifdef WIN32
typedef struct FMOD_SOUND FMOD_SOUND;
DECLARE_ALIAS(FMOD_System_Create,"fmodex.dll","FMOD_System_Create",(void *),int);
DECLARE_ALIAS(FMOD_System_Init, "fmodex.dll","FMOD_System_Init",(void *,int, int, int), int);
DECLARE_ALIAS(FMOD_System_CreateSound,"fmodex.dll","FMOD_System_CreateSound",(void *,const char *,int ,void *,FMOD_SOUND **),int);
DECLARE_ALIAS(FMOD_System_PlaySound,"fmodex.dll","FMOD_System_PlaySound",(void *,int,void *,int, void *),int);
#endif
long FMOD_SYSTEM;
FMOD_SOUND*fSound;
ENDINLINE
FUNCTION FMOD_Init%:maxChannels%,flags%
LOCAL result%
INLINE
result=FMOD_System_Create(&FMOD_SYSTEM);
if (result==0)
{
result=FMOD_System_Init((void *) FMOD_SYSTEM,maxChannels,flags,0);
}
return result;
ENDINLINE
ENDFUNCTION
FUNCTION FMOD_CreateSound%:fileName$,mode%,BYREF sound%
LOCAL result%
INLINE
DEBUG("x1");
result%=FMOD_System_CreateSound((void *) FMOD_SYSTEM,fileName_Str.c_str(),mode,NULL,&fSound);
DEBUG("XX");
//sound=(int) cSound;
ENDINLINE
RETURN result%
ENDFUNCTION
FUNCTION FMOD_PlaySound%:channelID%,sound%,paused%,BYREF channel%
LOCAL result%
INLINE
result%=FMOD_System_PlaySound((void *) FMOD_SYSTEM,channelID,(void *) fSound,paused,(void *) channel);
ENDINLINE
RETURN result%
ENDFUNCTION
For some reason the CreateSound function is crashing. The reason for NOT using BASS is there is no Linux version. And unfortunately, the compiler doesn't like the headers...
Now i can play my MP3 :P
INLINE
#ifdef WIN32
typedef struct FMOD_SOUND FMOD_SOUND;
typedef struct FMOD_CHANNEL FMOD_CHANNEL;
DECLARE_ALIAS(FMOD_System_Create,"fmodex.dll","FMOD_System_Create",(void *),int);
DECLARE_ALIAS(FMOD_System_Init, "fmodex.dll","FMOD_System_Init",(void *,int, int, int), int);
DECLARE_ALIAS(FMOD_System_CreateSound,"fmodex.dll","FMOD_System_CreateSound",(void *,const char *,int ,void *,FMOD_SOUND **),int);
DECLARE_ALIAS(FMOD_System_PlaySound,"fmodex.dll","FMOD_System_PlaySound",(void *,int,FMOD_SOUND*,bool, FMOD_CHANNEL**),int);
DECLARE_ALIAS(FMOD_System_Close,"fmodex.dll","FMOD_System_Close",(void*),int);
#endif
long FMOD_SYSTEM;
//FMOD_SOUND*fSound;
DGArray<FMOD_SOUND*> fsound;
DGArray<FMOD_CHANNEL*> fchannel;
ENDINLINE
FUNCTION FMOD_Init%:maxChannels%,flags%
LOCAL result%
INLINE
result=FMOD_System_Create(&FMOD_SYSTEM);
if (result==0)
{
result=FMOD_System_Init((void *) FMOD_SYSTEM,maxChannels,flags,0);
}
return result;
ENDINLINE
ENDFUNCTION
FUNCTION FMOD_CreateSound%:fileName$,mode%,BYREF sound%
LOCAL result%
INLINE
FMOD_SOUND* xsound;
result = FMOD_System_CreateSound((void *) FMOD_SYSTEM,fileName_Str.c_str(),mode,NULL,&xsound);
if(!result){ // all ok!
REDIM(fsound(),LEN(fsound())+1);
fsound(LEN(fsound())-1) = xsound;
sound = LEN(fsound())-1; // set the handle to sound
return result;
}else{
return result;
}
ENDINLINE
RETURN result%
ENDFUNCTION
FUNCTION FMOD_PlaySound%:channelID%,sound%,paused%,BYREF channel%
LOCAL result%
INLINE
FMOD_CHANNEL* xchannel;
result=FMOD_System_PlaySound((void *) FMOD_SYSTEM,channelID,fsound(sound),(bool)paused,&xchannel);
if(!result){ // all ok!
REDIM(fchannel(),LEN(fchannel())+1);
fchannel(LEN(fchannel())-1) = xchannel;
channel = LEN(fchannel())-1; // set the handle to channel
return result;
}else{
return result;
}
ENDINLINE
ENDFUNCTION
FUNCTION FMOD_Close:
INLINE
return FMOD_System_Close( (void*)FMOD_SYSTEM);
ENDINLINE
ENDFUNCTION
That it:
OK = FMOD_Init(32,0)
LOCAL Snd%
OKs = FMOD_CreateSound("06 - A Flame For Freedom.mp3",0,Snd%)
LOCAL chan%
play = FMOD_PlaySound(0,Snd%,0,chan)
WHILE TRUE
PRINT OK,10,10
PRINT OKs,10,20
PRINT Snd,10,30
PRINT play,10,40
SHOWSCREEN
WEND
FMOD_Close()
END
NEVER use % on inline ;)
Ahhh.. and see my signature! Thats why i <3 DGArrays :)
Thanks for that - works well!
Now, the next part will be seeing if DECLARE can cope with dylib's and .o's :)
So far, there is a bit of a problem with using DECLARE and dylibs :
Quote
Process: glbasic [324]
Path: /Volumes/Volume_1/Programming/GLBasic/TestFMOD.app/Contents/MacOS/glbasic
Identifier: GLBasic.com
Version: ??? (???)
Code Type: X86 (Native)
Parent Process: launchd [88]
Date/Time: 2008-12-29 11:18:31.085 +0000
OS Version: Mac OS X 10.5.6 (9G55)
Report Version: 6
Exception Type: EXC_ARITHMETIC (SIGFPE)
Exception Codes: EXC_I386_DIV (divide by zero)
Crashed Thread: 0
Thread 0 Crashed:
0 GLBasic.com 0x00014016 __GLBASIC__::DLLCALL(__GLBASIC__::DGStr, __GLBASIC__::DGStr, void**) + 898
1 GLBasic.com 0x000d08d9 __static_initialization_and_destruction_0(int, int) + 121
2 dyld 0x8fe12f36 ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) + 246
3 dyld 0x8fe0e7e3 ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int) + 307
4 dyld 0x8fe0e8c9 ImageLoader::runInitializers(ImageLoader::LinkContext const&) + 57
5 dyld 0x8fe04102 dyld::initializeMainExecutable() + 146
6 dyld 0x8fe07bcf dyld::_main(mach_header const*, unsigned long, int, char const**, char const**, char const**) + 3087
7 dyld 0x8fe01872 dyldbootstrap::start(mach_header const*, int, char const**, long) + 818
8 dyld 0x8fe01037 _dyld_start + 39
However, the good news is it looks like the Mac version can be used by including the dylib and including the headers...
Yes! Mac version works :)
And even better news : I've now managed to get the Windows version to include the headers - and thus no need to DECLARE anything now :) AND now full access to all the constants!
At the moment, the Linux version complains with :
/cygdrive/Q/Compiler/platform/Linux/Bin/ld:X:/Programming/GLBasic/libfmodex.so: file format not recognized; treating as linker script
I've nearly got the Linux version linking. Unfortunately it turns out that libstdc++.so.6 is needed - along with newer versions of GCC and LIBC, so I wont be able to continue there...