Author Topic: fmod FMUSIC_Get_Time  (Read 1619 times)

Offline Paul Smith

  • Mr. Polyvector
  • ***
  • Posts: 105
    • View Profile
fmod FMUSIC_Get_Time
« on: 2016-Apr-29 »
I'm using the fmod library setup from the samples folder in my project.
I need FMUSIC_Get_Time function adding.
tried to add it myself  but C++ is way above my level. How do you know if its @0 @4,void or char etc.
any help would be great.

added the function docs and fmod code below.

Cheers


Code: GLBasic [Select]
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);
        DECLARE_ALIAS(FMUSIC_SetMasterVolume, "fmod.dll", "_FMUSIC_SetMasterVolume@8", (void*, int), char);
//      DECLARE_ALIAS(FMUSIC_GetTime, "fmod.dll", "_FMUSIC_GetTime@4",
       
        void* g_pFMod = 0;

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


GLOBAL fmod_init

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

        FMod_Stop()
        INLINE

                if(FSOUND_Init) FSOUND_Init(65535,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


FUNCTION FMod_SetMasterVolume: vol
        INLINE
                if(FMUSIC_SetMasterVolume && g_pFMod)
                {
                        return FMUSIC_SetMasterVolume(g_pFMod, (int)(vol * 256.0)) ? TRUE:FALSE;
                }
        ENDINLINE
        RETURN FALSE
ENDFUNCTION

 


FMUSIC_GetTime
Returns the time in milliseconds since the song was started. This is useful for
synchronizing purposes becuase it will be exactly the same every time, and it is
reliably retriggered upon starting the song. Trying to synchronize using other
windows timers can lead to varying results, and inexact performance. This fixes that
problem by actually using the number of samples sent to the soundcard as a reference.

int F_API FMUSIC_GetTime(
FMUSIC_MODULE *mod
);

Parameters
mod Pointer to the song to get time from.

Return Value
On success, the time played in milliseconds is returned.
On failure, -1 is returned.

Remarks
Amstrad CPC 6128, ATARI STE.
Acer  SW5-173 & AMD FX 8350/1050Ti

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10695
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: fmod FMUSIC_Get_Time
« Reply #1 on: 2016-Apr-30 »
Download the "depends" program (dependency walker).

MrTAToad

  • Guest
Re: fmod FMUSIC_Get_Time
« Reply #2 on: 2016-Apr-30 »
If I remember correctly, FMOD has two interface systems - one for C++ and one for C, with the latter, of course, being easier to use with GLBasic.

Offline Paul Smith

  • Mr. Polyvector
  • ***
  • Posts: 105
    • View Profile
Re: fmod FMUSIC_Get_Time
« Reply #3 on: 2016-Apr-30 »
Right

Code: GLBasic [Select]
DECLARE_ALIAS(FMUSIC_GetTime, "fmod.dll", "_FMUSIC_GetTime@4", (void* pMod), int);

this code compiles with no error.
how do you  pass the result to a usable variable?
tried to make a function using variations of the samples but error after error.

probably simple  but my brain is leaking.

« Last Edit: 2016-Apr-30 by Paul Smith »
Amstrad CPC 6128, ATARI STE.
Acer  SW5-173 & AMD FX 8350/1050Ti

Offline Paul Smith

  • Mr. Polyvector
  • ***
  • Posts: 105
    • View Profile
Re: fmod FMUSIC_Get_Time
« Reply #4 on: 2016-May-09 »
Sorted this about a week ago, took me a bit to understand the C++ syntax but here goes if anyone needs it.

Code: GLBasic [Select]
DECLARE_ALIAS(FMUSIC_GetTime, "fmod.dll", "_FMUSIC_GetTime@4", (void* pMod), int);

FUNCTION Gettime: modtime
                INLINE
        return FMUSIC_GetTime(g_pFMod);
ENDINLINE
ENDFUNCTION

Use

Code: GLBasic [Select]
result= Gettime(modtime)

« Last Edit: 2016-May-09 by Paul Smith »
Amstrad CPC 6128, ATARI STE.
Acer  SW5-173 & AMD FX 8350/1050Ti