Problem with miniFMOD for PB

Just starting out? Need help? Post your questions and find answers here.
neomember
User
User
Posts: 14
Joined: Tue Jul 27, 2004 12:17 am

Problem with miniFMOD for PB

Post by neomember »

I would like to use the 'minifmod170' library for my application. It sounds pretty interesting and i don't need the bells and whistles of it's bigger brother.

I've downloaded an include version for PB and tried the example file provided in the archive. But it won't compile. :?

ERROR:
Line 117: FSOUND_File_SetCallbacks() is not a function, an array, or a linked list

It does that for every FSOUND_XXX functions.

Is there any special instruction to tell to the compiler in order to use static libraries properly??

What are callbacks??
What is .XM files? What's special about them?
Will it play MP3/OGG/WMA??

Some tips:
I'm using PureBasic 3.92.
As i understand, i don't need any DLLs...
I've putted the 'minifmod170' library in '.\PureLibraries\UserLibraries'
I'm a beginner.

I'm using 'xmplay.pb' source code as followed...

Code: Select all

;
; PureBasic MiniFMOD v1.70 - xmplay.pb
; 
; This simple example shows how to use minifmod with your own
; fileloading callbacks and should be quite self-explanatory.
;
; Use at your own risk!
;
;
; NOTE:
; minifmod is copyright (c) FireLight Technologies 1999-2004
; See http://www.fmod.org For more information
;
;
; minifmod v1.70 for PureBasic v3.92 by traumatic! & AlphaSND
;


#useMemLoad = 0   ; 0 = filecallbacks
                  ; 1 = memorycallbacks


CompilerIf #useMemLoad=1

  ;
  ; MEMORY CALLBACKS
  ;  
  Structure MEMFILE
    Length.l
    pos.l
    mdata.l
  EndStructure
    
  Procedure.l modopenmem(*memfile.MEMFILE)
    *memfile = AllocateMemory(SizeOf(MEMFILE))
    *memfile\mdata = ?mod
    *memfile\Length = ?modend - ?mod
    *memfile\pos    = 0
    
    ProcedureReturn *memfile
  EndProcedure
    
  Procedure.l modclosemem(*memfile.MEMFILE)
    FreeMemory(*memfile) : *memfile = #Null
  EndProcedure
    
  Procedure.l modreadmem(Buffer.l, size.l, *memfile.MEMFILE)
    If *memfile\pos + size >= *memfile\Length
      size = *memfile\Length - *memfile\pos
    EndIf
    
    CopyMemory(*memfile\mdata+*memfile\pos, Buffer, size)
    
    *memfile\pos + size  ; update filepointer position
    ProcedureReturn size
  EndProcedure
    
  Procedure modseekmem(*memfile.MEMFILE, pos.l, mode.l) 
    Select mode
      Case #SEEK_SET
        *memfile\pos = pos
      Case #SEEK_CUR
        *memfile\pos+pos
    EndSelect
    
    If *memfile\pos > *memfile\Length
      *memfile\pos = *memfile\Length
    EndIf
  EndProcedure
    
  Procedure.l modtellmem(*memfile.MEMFILE)
    ProcedureReturn *memfile\pos
  EndProcedure

CompilerElse

  ;
  ; FILE CALLBACKS
  ;
  Procedure.l modopen(name.s)
    ProcedureReturn ReadFile(0, name.s)
  EndProcedure
    
  Procedure modclose(handle.l)
    CloseFile(0)
  EndProcedure
    
  Procedure.l modread(Buffer.l, size.l, handle.l)
    ProcedureReturn ReadData(Buffer, size)
  EndProcedure
    
  Procedure modseek(handle.l, pos.l, mode.l)
    Select mode
      Case #SEEK_SET
        FileSeek(pos)
      Case #SEEK_CUR
        FileSeek(Loc()+pos)
    EndSelect
  EndProcedure
    
  Procedure.l modtell(handle.l)
    ProcedureReturn Loc()
  EndProcedure

CompilerEndIf

;
;
;

OpenConsole()

CompilerIf #useMemLoad = 1
  FSOUND_File_SetCallbacks(@modopenmem(), @modclosemem(), @modreadmem(), @modseekmem(), @modtellmem())
  mod = FMUSIC_LoadSong("", #Null)
CompilerElse
  FSOUND_File_SetCallbacks(@modopen(), @modclose(), @modread(), @modseek(), @modtell())
  modfile$ = ProgramParameter()
  mod = FMUSIC_LoadSong_(modfile$, #Null)
CompilerEndIf



If mod
  PrintN("-------------------------------------------------------------")
  PrintN("MINIFMOD for PureBasic example XM player")
  PrintN("-------------------------------------------------------------")

  FMUSIC_PlaySong(mod)
  
  Repeat
    ord.b     = FMUSIC_GetOrder(mod)                ; get module order
    row.b     = FMUSIC_GetRow(mod)                  ; get module row 
    modtime.f  = FMUSIC_GetTime(mod) / 1000.0       ; get module time
    
    ConsoleLocate(0,5) : PrintN("Playing...")
    ConsoleLocate(0,7) : PrintN("Order: "+Str(ord)+" | Row: "+Str(row)+" | Time: "+StrF(modtime,2))
    ConsoleLocate(0,12): PrintN("Press any key to quit") 
  
    Delay(10)
  Until Inkey()
  
  FMUSIC_FreeSong(mod)
Else
  PrintN("-------------------------------------------------------------")
  PrintN("MINIFMOD for PureBasic example XM player")
  PrintN("-------------------------------------------------------------")
  ConsoleLocate(0,5)
  PrintN("Couldn't load XM-file!  Syntax: xmplay infile.xm")
  Repeat
    Delay(10)
  Until Inkey()
EndIf


CloseConsole()
End

CompilerIf #useMemLoad = 1
  DataSection
  mod:
  IncludeBinary "infile.xm"
  modend:
  EndDataSection 
CompilerEndIf 
; ExecutableFormat=
; EOF
Other threads discussing about miniFMOD on PB:
http://www.purebasic.fr/english/viewtopic.php?t=9340
http://www.purebasic.fr/english/viewtopic.php?t=13424
http://www.purebasic.fr/english/viewtopic.php?t=10910

Links to different files:
http://purebasic.myftp.org/?filename=fi ... mod170.zip
http://purebasic.myftp.org/?filename=fi ... 170_pb.zip

Thanks in advance!!!
Last edited by neomember on Tue Mar 07, 2006 12:18 am, edited 3 times in total.
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Re: Problem with miniFMOD for PB

Post by traumatic »

neomember wrote:I've download an include version for PB and tried the example file provide in the archive. But it won't compile. :?

ERROR:
Line 117: FSOUND_File_SetCallbacks() is not a function, an array, or a linked list

It does that for every FSOUND_XXX functions.
Did you use the library-file provided with this zip-archive?
http://files.connection-refused.org/minifmod170_pb.zip

EDIT: I just noticed that
http://purebasic.myftp.org/?filename=fi ... 170_pb.zip
contains the same (who mirrored it there?), don't know about the
other archive.

Is there any special instruction to tell to the compiler in order to use static libraries properly??
No.

If PB is already running, make sure to restart the compiler after
you've copied the library file into the appropriate directory.
What are callbacks??
http://en.wikipedia.org/wiki/Callback_% ... science%29
What is .XM files? What's special about them?
http://en.wikipedia.org/wiki/XM_%28mod_format%29
Will it play MP3/OGG/WMA??
No
I'm using PureBasic 3.92.
Why?
As i understand, i don't need any DLLs...
Right, miniFMOD doesn't require any external DLLs
I've put the 'minifmod170' library in '.\PureLibraries\UserLibraries'
Correct
I'm a beginner.
Never mind :D
Good programmers don't comment their code. It was hard to write, should be hard to read.
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

Re: Problem with miniFMOD for PB

Post by jack »

traumatic wrote: I just noticed that
http://purebasic.myftp.org/?filename=fi ... 170_pb.zip
contains the same (who mirrored it there?), don't know about the
other archive.
sorry about that traumatic, i was trying to help someone who could not find it, i'll remove it if you want, my apologies.
neomember
User
User
Posts: 14
Joined: Tue Jul 27, 2004 12:17 am

Post by neomember »

Works perfectly!!

I did tests with both files... and the library in the other archive is bad.

I've thought that 'callbacks' were exclusives to PB.

Now that it won't play MP3s, i can't see a purpose for it. But i'm glad i've been able to make it work. I'm gonna learn toward it.

Many thanks!!
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Re: Problem with miniFMOD for PB

Post by traumatic »

jack wrote: sorry about that traumatic, i was trying to help someone who could not find it, i'll remove it if you want, my apologies.
No problem jack, I just wondered because I didn't know.
This is no original work - do whatever you want to do with it.
Good programmers don't comment their code. It was hard to write, should be hard to read.
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Re: Problem with miniFMOD for PB

Post by traumatic »

traumatic wrote:No problem jack, I just wondered because I didn't know.
Haha Jack, I'm getting old, I must have known it before...
http://purebasic.fr/english/viewtopic.p ... 196#116196


:roll:
Good programmers don't comment their code. It was hard to write, should be hard to read.
Post Reply