MOD files

Previous topic - Next topic

PJBonoVox

Hi all

Just wondered if there were any plans to support loading of MOD files (Soundtracker/Protracker) as this is a really great way to get small tunes onto GP2X :)

Kitty Hello

Use the fmod dll. On GP2X it might work with PLAYMUSIC - not tested, though.

PJBonoVox

Hi, thanks for the reply!

Any chance you could help me out with this? I presuming I'd need to use inline ASM or C++ to interface with the DLL but wouldn't know where to start. Help much appreciated :)

Kitty Hello

There is already a wrapper for Win32: See samples\_PROJECTS_\FMod

PJBonoVox

Thanks for the tip :)

Unfortunately the FMOD example doesn't work on the latest demo SDK even on Windows :

Code (glbasic) Select
*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.2007.159 - 2D, WIN32
"fmod_player.gbas"(8) error : redefinition as different type
Any ideas?

Also, I don't believe there is FMOD for GP2X...?

BumbleBee

Hi

I got that Premium SDK, and it works fine on my Windows System. But when i change it into a Demo Version (delete keycode ) :D, it doesn't work anymore. I guess, that you must buy it.:D

Cheers
The day will come...

CPU Intel(R) Core(TM) i5-3570k, 3.4GHz, AMD Radeon 7800 , 8 GB RAM, Windows 10 Home 64Bit

Kitty Hello

Oh. How can that be? I thought the demo is fully featured!? I have to see.

S.O.P.M.

I've the full version (5.047) and the example doesn't work :wah:
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium

Schranz0r

Works fine for me !
I dont have any errors/massages on the Compilerwindow...
So it works very well ;)
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

S.O.P.M.

That's not fair!
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium

Kitty Hello

Uhm.. Impossible. Please give the exact example, and the compiler output.

S.O.P.M.

Here it is:

Code (glbasic) Select
// --------------------------------- //
// Project: fmod_player
// Start: Tuesday, May 09, 2006
// IDE Version: 3.118

snd$ = "rb_1.it"
good = FMod_Load(snd$)

FMod_Play()

WHILE TRUE
PRINT "PLAY: "+snd$ + " returns: "+good, 100,100
PRINT "IsFinished: " + FMod_IsFinished(), 100, 120
PRINT "click mouse to stop", 100,140
IF MOUSEAXIS(3) THEN BREAK
SHOWSCREEN
WEND

FMod_Stop()

INLINE
DECLARE_ALIAS(FMUSIC_LoadSong, "fmod.dll", "_FMUSIC_LoadSong@4", (const char* name), void*);
DECLARE_ALIAS(FMUSIC_PlaySong, "fmod.dll", "_FMUSIC_PlaySong@4", (void* pMod), char);
DECLARE_ALIAS(FMUSIC_FreeSong, "fmod.dll", "_FMUSIC_FreeSong@4", (void* pMod), char);
DECLARE_ALIAS(FSOUND_Init, "fmod.dll", "_FSOUND_Init@12", (int, int, unsigned int), char);
DECLARE_ALIAS(FSOUND_Close, "fmod.dll", "_FSOUND_Close@0", (void), void);
DECLARE_ALIAS(FMUSIC_IsFinished, "fmod.dll", "_FMUSIC_IsFinished@4", (void* pMod), char);

void* g_pFMod = 0;

// need this for ESC-exits
struct FMOD_killer {~FMOD_killer() {IF (g_pFMod) FMod_Stop();} } g_Fmod_killa;
ENDINLINE

FUNCTION FMod_Load: fname$
GLOBAL fmod_init
LOCAL good
IF fmod_init = FALSE
fmod_init=TRUE
ENDIF

FMod_Stop()
INLINE

if(FSOUND_Init) FSOUND_Init(44100,64,0);
if(FMUSIC_LoadSong)
g_pFMod = FMUSIC_LoadSong(fname_Str.c_str());
if(g_pFMod) good = true;

ENDINLINE
RETURN good
ENDFUNCTION

FUNCTION FMod_Play:
INLINE

if(FMUSIC_PlaySong && g_pFMod)
FMUSIC_PlaySong(g_pFMod);

ENDINLINE
ENDFUNCTION

FUNCTION FMod_Stop:
INLINE

if(FMUSIC_FreeSong && g_pFMod)
FMUSIC_FreeSong(g_pFMod);
g_pFMod = 0;
if(FSOUND_Close)
FSOUND_Close();
fmod_init=FALSE;
ENDINLINE
ENDFUNCTION

FUNCTION FMod_IsFinished:
INLINE
char ok=1;
if(FMUSIC_IsFinished && g_pFMod)
ok = FMUSIC_IsFinished(g_pFMod);
return ok ? TRUE : FALSE;
ENDINLINE

RETURN TRUE
ENDFUNCTION
The compiler says "fmod_player.gbas"(8) error : redefinition as different type. The line it points to is the first one after the first INLINE command.
Code (glbasic) Select
DECLARE_ALIAS(FMUSIC_LoadSong, "fmod.dll", "_FMUSIC_LoadSong@4", (const char* name), void*);
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium

Kitty Hello

Ooops. That one.
There's a single file that gives you the fmod function. Just include that one.
In yous sample, the main function was not closed, yet. Thus:
Code (glbasic) Select
// --------------------------------- //
// Project: fmod_player
// Start: Tuesday, May 09, 2006
// IDE Version: 3.118

    snd$ = "rb_1.it"
    good = FMod_Load(snd$)

    FMod_Play()

WHILE TRUE
    PRINT "PLAY: "+snd$ + " returns: "+good, 100,100
    PRINT "IsFinished: " + FMod_IsFinished(), 100, 120
    PRINT "click mouse to stop", 100,140
    IF MOUSEAXIS(3) THEN BREAK
    SHOWSCREEN
WEND

    FMod_Stop()
   
FUNCTION end_main_foo:
ENDFUNCTION

INLINE
    DECLARE_ALIAS(FMUSIC_LoadSong, "fmod.dll", "_FMUSIC_LoadSong@4", (const char* name), void*);
    DECLARE_ALIAS(FMUSIC_PlaySong, "fmod.dll", "_FMUSIC_PlaySong@4", (void* pMod), char);
    DECLARE_ALIAS(FMUSIC_FreeSong, "fmod.dll", "_FMUSIC_FreeSong@4", (void* pMod), char);
    DECLARE_ALIAS(FSOUND_Init, "fmod.dll", "_FSOUND_Init@12", (int, int, unsigned int), char);
    DECLARE_ALIAS(FSOUND_Close, "fmod.dll", "_FSOUND_Close@0", (void), void);
    DECLARE_ALIAS(FMUSIC_IsFinished, "fmod.dll", "_FMUSIC_IsFinished@4", (void* pMod), char);

    void* g_pFMod = 0;

    // need this for ESC-exits
    struct FMOD_killer    {~FMOD_killer() {if (g_pFMod) FMod_Stop();}    } g_Fmod_killa;
ENDINLINE

FUNCTION FMod_Load: fname$
GLOBAL fmod_init
LOCAL good
    IF fmod_init = FALSE
        fmod_init=TRUE
    ENDIF

    FMod_Stop()
    INLINE

        if(FSOUND_Init) FSOUND_Init(44100,64,0);
        if(FMUSIC_LoadSong)
            g_pFMod = FMUSIC_LoadSong(fname_Str.c_str());
        if(g_pFMod) good = true;

    ENDINLINE
    RETURN good
ENDFUNCTION

FUNCTION FMod_Play:
    INLINE

        if(FMUSIC_PlaySong && g_pFMod)
            FMUSIC_PlaySong(g_pFMod);

    ENDINLINE
ENDFUNCTION

FUNCTION FMod_Stop:
    INLINE

        if(FMUSIC_FreeSong && g_pFMod)
            FMUSIC_FreeSong(g_pFMod);
        g_pFMod = 0;
        if(FSOUND_Close)
            FSOUND_Close();
        fmod_init=FALSE;
    ENDINLINE
ENDFUNCTION

FUNCTION FMod_IsFinished:
    INLINE
        char ok=1;
        if(FMUSIC_IsFinished && g_pFMod)
            ok = FMUSIC_IsFinished(g_pFMod);
        return ok ? TRUE : FALSE;
    ENDINLINE

    RETURN TRUE
ENDFUNCTION
works

S.O.P.M.

I simply can't get it to work! The same error reappears.

QuoteOoops. That one.
'That' one was the original example of the fmod player you provided with GLBasic!

QuoteThere's a single file that gives you the fmod function. Just include that one.
What do you mean by 'include'? I copied the code you given here into a SINGLE gbas file (the original example consisted of 2 seperate gbas files). So this is not the right way?
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium

Kitty Hello

The 2 file way is the best. One file for your game, the other file, untouched, as a library for the fmod wrapper. If you copy all in one file, make sure you indicate where the main game function ends, by writing a dummy function at the end. In my case "end_main_foo".
The "samples/_projects_/fmod_player.gbap" project works for me...