Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using FMODTEST.BAS
#1
Has anyone worked out how to check if the MOD or MID file used when using FMODTEST.BAS has finished playing similar to the MP3 with PLAYMP3.BAS?

Gordon
Reply
#2
Use either of the FMOD functions FMUSIC_IsFinished or FMUSIC_IsPlaying.

From FMOD documentation:

Quote:FMUSIC_IsFinished
Returns whether the song has completed playing, or when the last order has finished playing.
This stays set even if the song loops.

signed char F_API FMUSIC_IsFinished(
FMUSIC_MODULE *mod
);


Parameters
mod Pointer to the song that you want check if finished or not.


Return Value
TRUE Song has finished playing.
FALSE Song has not finished playing.

Remarks
Some songs may use a pattern break or pattern jump and never reach the last pattern.
___________________
Supported on the following platforms : Win32, WinCE, Linux, Macintosh, XBox, PlayStation 2, GameCube

-shiftLynx
img]http://www.cdsoft.co.uk/misc/shiftlynx.png[/img]
Reply
#3
Thanks for the Info. but with my lack of understnding of these advanced features of QB, it does not help me much. For example the simple test below to discover the value of FMUSIC_IsFinished is not accepted when compiling with FB.

Print FMUSIC_IsFinished


Gordon.
Reply
#4
Quote:Parameters
mod Pointer to the song that you want check if finished or not.

You need to pass the pointer to the song...
Reply
#5
Thanks for your help guys. Here is my offering for MOD/MIDi player with Koch Patterns, for all or one of the files. I wonder if anyone has come up with a player for the CMF and or S3M files popular in Europe.
Gordon

Code:
'Simple FMOD test for FB by Plasma  [11-16-2004]
screen 12 : color 15,0
dim f$(200)
start: cls
    t$ = DIR$("*.mod")
    C%= 1 : T% = 1
Do while t$ <> ""
      print tab(T%);C%;":";t$;
      f$(C%)=t$
      C% = C%+1 : T%=T%+16
      if T% > 60 then T%=1 : Print
      t$ = DIR$("")
Loop

    t$ = DIR$("*.mid")
Do while t$ <> ""
      print tab(T%);C%;":";t$;
      f$(C%)=t$
      C% = C% +1 : T% = T% +16
      if T% > 60 then T% = 1 : print
      t$ = DIR$("")
Loop
      C% = C% - 1
    
  print : print "Enter the number of the file to be played, or A for All or 0 to abort ";
    INPUT i$
    all% = 0 : if i$ ="a" or i$ ="A" then all% = 1 : Fil% = 1 else Fil% = val(i$)
miss:
    cls : File$ = f$(Fil%)
    if File$ = "" then end
    print Fil%;":";File$

DefSng A-Z
'$Include: 'fmod.bi'

Declare Sub ErrorQuit (Message$)

Const FALSE = 0
Const MusicFile = ""
   Dim Shared Handle As Long

   If FSOUND_GetVersion <= FMOD_VERSION Then
        ErrorQuit "FMOD version " + STR$(FMOD_VERSION) + " or greater required"
   End If

   If FSOUND_Init(44100, 32, 0) = FALSE Then
        ErrorQuit "Can't initialize FMOD"
   End If

   Handle = FMUSIC_LoadSong(File$)
   If Handle = FALSE Then
        ErrorQuit "Can't load music file " + CHR$(34) + MusicFile + CHR$(34)
   End if

   FMUSIC_PlaySong(Handle)

           Print "Based on FMOD test for freeBASIC"
                   Print "Hold down the Esc key to quit." : SLEEP 2000

REM KOCH patterns from an IBM original
    CM = 15: LOCATE 10, 20
    DIM SR(20), SX1(20), SX2(20), SY1(20), SY2(20)
    DIM SX(20), SY(20), SY3(20), SY4(20), SCOL(20)
    WINDOW (0, 0)-(1279, 799)
    PI = 3.141593
    COS30 = COS(30 * PI / 180)
    FIN = 0
    WHILE FIN = 0
        SP = 0: RESTORE dat
        FOR Z = 1 TO 6: CLS : READ FA, FB
            RES = 8: RDFC = 1 / FA: X = 640: Y = 400: R = 256
            GOSUB flake
                   IF FMUSIC_IsFinished(Handle) <> 0 THEN Z = 9 :FIN = 1
            sleep 2000
        NEXT Z
    WEND

   FMUSIC_FreeSong(Handle)
   FSOUND_Close
   if all% = 0 then goto start
   Fil% = Fil% + 1 : sleep 1000 : goto miss

   End

Sub ErrorQuit (Message$)

  print "ERROR: "; Message$
  FMUSIC_FreeSong(Handle)
  FSOUND_Close
  End 1

End Sub
    
flake:
        if multikey(1) then  
       FMUSIC_FreeSong(Handle)
           FSOUND_Close
       end
    END IF
    IF R < RES THEN RETURN
    SX1(SP) = X1: SX2(SP) = X2
    SY1(SP) = Y1: SY2(SP) = Y2
    SY3(SP) = Y3: SY4(SP) = Y4
    SP = SP + 1
    X1 = X - R * COS30: X2 = X + R * COS30: XINC = R * COS30
    Y1 = Y - R: Y2 = Y - R / 2: Y3 = Y + R / 2: Y4 = Y + R
    P = INT(RND * 15) + 1
    LINE (X1, Y2)-(X, Y4), P
    LINE -(X2, Y2), P
    LINE -(X1, Y2), P
    LINE (X, Y1)-(X1, Y3), P
    LINE -(X2, Y3), P
    LINE -(X, Y1), P
    PAINT (X, Y), P, P
    PAINT (X, Y3 + R / 4), P, P
    PAINT (X2 - XINC, Y3 - R / 4), P, P
    PAINT (X2 - XINC, Y2 + R / 4), P, P
    PAINT (X, Y2 - R / 4), P, P
    PAINT (X1 + XINC, Y2 + R / 4), P, P
    PAINT (X1 + XINC, Y3 - R / 4), P, P
    SR(SP) = R: SCOL(SP) = C
    SX(SP) = X: SY(SP) = Y
    RDFC = 1 / FB
    R = R * RDFC
    C = C + PX
    X = X1: Y = Y2
    GOSUB flake
    X = SX(SP): Y = Y4
    GOSUB flake
    SLEEP 1
    X = X2: Y = Y2
    GOSUB flake
    X = SX(SP): Y = Y1
    GOSUB flake
    X = X1: Y = Y3
    GOSUB flake
    X = X2: Y = Y3
    GOSUB flake
    X = SX(SP): Y = SY(SP)
    GOSUB flake
    R = SR(SP): X = SX(SP): Y = SY(SP)
    C = SCOL(SP)
    SP = SP - 1
    X1 = SX1(SP): X2 = SX2(SP)
    Y1 = SY1(SP): Y2 = SY2(SP)
    Y3 = SY3(SP): Y4 = SY4(SP)
    RETURN
dat:
    DATA 3,3,2.6,4,2.5,2.4,3.2,3,2.5,4,3.5,2.7
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)