#ifndef __FBSOUND_BI__
#define __FBSOUND_BI__

'  ##############
' # fbsound.bi #
'##############
' Copyright 2005 - 2013 by D.J.Peters (Joshy)
' d.j.peters@web.de
#ifdef __FB_WIN32__
 #libpath "../lib/win32/"
#else
 #ifdef  __FB_LINUX__
  #libpath "../lib/linux/"
 #else
   #error Build target must be Windows or Linux !
 #endif
#endif
 
#inclib "fbsound"

#include once "fbstypes.bi"
#include once "fbscpu.bi"

#ifndef NOMOD
#include once "dumb.bi"
#endif

#ifndef NOMP3
#include once "mad.bi"
#endif

#ifndef NOOGG
#include once "vorbisfile.bi"
#endif

#ifndef NODSP
#include once "fbsdsp.bi"
#endif

declare function FBS_Init                   (byval nRate      as integer=44100, _
                                             byval nChannels  as integer=    2, _
                                             byval nBuffers   as integer=    3, _
                                             byval nFrames    as integer= 2048, _
                                             byval index      as integer=   -1) as fbsboolean

' now fbs will start,stop and exit by it self
declare function FBS_Start                  () as fbsboolean
declare function FBS_Stop                   () as fbsboolean
declare function FBS_Exit                   () as fbsboolean

declare function FBS_Get_PlugPath           () as string
declare sub      FBS_Set_PlugPath           (byval NewPath as string)

declare function FBS_Get_NumOfPlugouts      () as integer
declare function FBS_Get_PlugName           () as string
declare function FBS_Get_PlugDevice         () as string
declare function FBS_Get_PlugError          () as string
declare function FBS_Get_PlugRate           () as integer ' 6000-96000
declare function FBS_Get_PlugBits           () as integer ' curently 16bit only
declare function FBS_Get_PlugChannels       () as integer ' 1=mono 2=stereo
declare function FBS_Get_PlugBuffers        () as integer ' 2 to N N<=64
declare function FBS_Get_PlugBuffersize     () as integer ' same as FrameSize*Frames
declare function FBS_Get_PlugFrames         () as integer ' same as BufferSize\FrameSize
declare function FBS_Get_PlugFramesize      () as integer ' same as BufferSize\Frames
declare function FBS_Get_PlugRunning        () as fbsboolean

declare function FBS_Get_PlayingSounds      () as integer
#ifndef NOMP3
declare function FBS_Get_PlayingStreams     () as integer
#endif
declare function FBS_Get_PlayedBytes        () as integer
declare function FBS_Get_PlayedSamples      () as integer
declare function FBS_Get_PlayTime           () as double


declare function FBS_Get_MasterVolume       (byval lpVolume as single ptr) as fbsboolean
declare function FBS_Set_MasterVolume       (byval Volume   as single ) as fbsboolean

#ifndef NODSP
declare function FBS_Set_MasterFilter       (byval nFilter as integer, _
                                             byval Center  as single, _
                                             byval dB      as single, _
                                             byval Octave  as single = 1.0, _
                                             byval OnOff   as fbsboolean = True) as fbsboolean

declare function FBS_Enable_MasterFilter    (byval nFilter as integer) as fbsboolean
declare function FBS_Disable_MasterFilter   (byval nFilter as integer) as fbsboolean

declare sub      FBS_PitchShift             (byval d as short ptr, _
                                             byval s as short ptr, _
                                             byval v as single   , _
                                             byval n as integer  )
#endif

declare function FBS_Get_MaxChannels        (lpnChannels as integer ptr) as fbsboolean
declare function FBS_Set_MaxChannels        (nChannels   as integer ) as fbsboolean

#ifndef NOCALLBACK
declare function FBS_Set_LoadCallback       (pCallback as FBS_LOADCALLBACK) as fbsboolean
declare function FBS_Enable_LoadCallback    () as fbsboolean
declare function FBS_Disable_LoadCallback   () as fbsboolean

declare function FBS_Set_MasterCallback     (pCallback as FBS_BUFFERCALLBACK) as fbsboolean
declare function FBS_Enable_MasterCallback  () as fbsboolean
declare function FBS_Disable_MasterCallback () as fbsboolean
#endif

' create or load wave objects in the pool of Waves()

' create hWave from *.wav file
declare function FBS_Load_WAVFile           (byval Filename as string       , _
                                             byval hWave    as integer ptr       ) as fbsboolean
#ifndef NOMP3
' create hWave from *.mp3,*.mp2,*.mp file
declare function FBS_Load_MP3File           (byval Filename as string       , _
                                             byval lphWave  as integer ptr       , _
                                             byval tmpfile  as string =""   ) as fbsboolean
#endif

#ifndef NOMOD
' create hWave from *.it *.xm *.sm3 or *.mod file
declare function FBS_Load_MODFile           (byval Filename as string       , _
                                             byval lphWave  as integer ptr       , _
                                             byval tmpfile  as string =""   ) as fbsboolean
#endif

#ifndef NOOGG
' create hWave from *.ogg file
declare function FBS_Load_OGGFile           (byval Filename as string       , _
                                             lphWave  as integer ptr       , _
                                             byval tmpfile  as string =""   ) as fbsboolean
#endif
' create hWave with nSamples in memory
declare function FBS_Create_Wave            (byval nSamples as integer        , _
                                             byval hWave    as integer ptr       , _
                                             byval ppWave   as any ptr ptr      ) as fbsboolean
' playtime in MS
declare function FBS_Get_WaveLength         (byval hWave    as integer        , _
                                             byval lpMS     as integer ptr       ) as fbsboolean



' play any wave as sound from the pool of Waves()
' optional number of loops, playbackspeed,volume,pan
' if you need to change any param while playing use an hSound object
declare function FBS_Play_Wave              (byval hWave    as integer        , _
                                             byval nLoops   as integer  = 1   , _
                                             byval Speed    as single  = 1.0 , _
                                             byval Volume   as single  = 1.0 , _
                                             byval Pan      as single  = 0.0 , _
                                             byval hSound   as integer ptr = NULL) as fbsboolean

'create an playable sound object "hSound" from any "hWave" object
declare function FBS_Create_Sound           (byval hWave    as integer        , _
                                             byval lphSound as integer ptr = NULL) as fbsboolean


' [optinal] destroy/free created hSound's and hWave's
declare function FBS_Destroy_Wave           (byval lphWave  as integer ptr       ) as fbsboolean
declare function FBS_Destroy_Sound          (byval lphSound as integer ptr       ) as fbsboolean

' play an hSound object
declare function FBS_Play_Sound             (byval hSound   as integer        , _
                                             byval nLoops   as integer = 1    ) as fbsboolean
' play time in MS
declare function FBS_Get_SoundLength        (byval hSound   as integer        , _
                                             byval lpMS     as integer ptr       ) as fbsboolean


' get and set any params from playing hSound
declare function FBS_Set_SoundSpeed         (byval hSound   as integer        , _
                                             byval Speed    as single    ) as fbsboolean
declare function FBS_Get_SoundSpeed         (byval hSound   as integer        , _
                                             byval lpSpeed  as single ptr       ) as fbsboolean

declare function FBS_Set_SoundVolume        (byval hSound   as integer        , _
                                             byval Volume   as single        ) as fbsboolean
declare function FBS_Get_SoundVolume        (byval hSound   as integer        , _
                                             byval lpVolume as single ptr     ) as fbsboolean

declare function FBS_Set_SoundPan           (byval hSound   as integer        , _
                                             byval Pan      as single    ) as fbsboolean
declare function FBS_Get_SoundPan           (byval hSound   as integer        , _
                                             byval lpPan    as single ptr     ) as fbsboolean

declare function FBS_Set_SoundLoops         (byval hSound   as integer        , _
                                             byval nLoops   as integer      ) as fbsboolean
declare function FBS_Get_SoundLoops         (byval hSound   as integer        , _
                                             byval lpnLoops as integer ptr    ) as fbsboolean
' togle hearing
declare function FBS_Set_SoundMuted         (byval hSound   as integer        , _
                                             byval muted    as fbsboolean     ) as fbsboolean
declare function FBS_Get_SoundMuted         (byval hSound   as integer        , _
                                             byval lpMuted  as fbsboolean ptr ) as fbsboolean
' togle playing
declare function FBS_Set_SoundPaused        (byval hSound   as integer        , _
                                             byval Paused   as fbsboolean     ) as fbsboolean
declare function FBS_Get_SoundPaused        (byval hSound   as integer        , _
                                             byval lpPaused as fbsboolean ptr ) as fbsboolean

declare function fbs_Get_WavePointers       (byval hWave         as integer            , _
                                             byval lplpWaveStart as short ptr ptr=NULL , _
                                             byval lplpWaveEnd   as short ptr ptr=NULL , _
                                             byval lpnChannels   as integer ptr  =NULL ) as fbsboolean

declare function fbs_Get_SoundPointers      (byval hSound    as integer       , _
                                             byval lplpStart as short ptr ptr=NULL , _
                                             byval lplpPlay  as short ptr ptr=NULL , _
                                             byval lplpEnd   as short ptr ptr=NULL) as fbsboolean

declare function fbs_Set_SoundPointers      (byval hSound     as integer , _
                                             byval lpNewStart as short ptr=NULL, _
                                             byval lpNewPlay  as short ptr=NULL, _
                                             byval lpNewEnd   as short ptr=NULL) as fbsboolean

' position 0.0-1.0
declare function fbs_Get_SoundPosition      (byval hSound as integer, _
                                             byval pPosition as single ptr) as fbsboolean

#ifndef NOCALLBACK
declare function FBS_Set_SoundCallback      (byval hSound     as integer      , _
                                             byval cb         as FBS_BUFFERCALLBACK)  as fbsboolean
declare function FBS_Enable_SoundCallback   (byval hSound     as integer      ) as fbsboolean
declare function FBS_Disable_SoundCallback  (byval hSound     as integer      ) as fbsboolean
#endif

#if defined(NOMP3) and defined(NOMOD)
 ' no streams
#else

enum FBS_STREAM_TYPES
  FBS_NOSTREAM =0
#ifndef NOMOD
  FBS_MOD = 1
#endif
#ifndef NOMP3
  FBS_MP3 = 2
#endif
end enum

#ifndef NOMP3
declare function FBS_Create_MP3Stream          (byval Filename as string   ) as fbsboolean
declare function FBS_Play_MP3Stream            (byval Volume     as single=1.0, _
                                                byval Pan        as single=0.0) as fbsboolean
declare function FBS_End_MP3Stream             () as fbsboolean
declare function FBS_Set_MP3StreamVolume       (byval Volume     as single) as fbsboolean
declare function FBS_Get_MP3StreamVolume       (byval Volume     as single ptr   ) as fbsboolean
declare function FBS_Set_MP3StreamPan          (byval Pan        as single) as fbsboolean
declare function FBS_Get_MP3StreamPan          (byval lpPan      as single ptr   ) as fbsboolean

declare function FBS_Get_MP3StreamBuffer       (byval lpBuffer   as short ptr ptr , _
                                                byval lpChannels as integer ptr   , _
                                                byval lpnSamples as integer ptr   ) as fbsboolean
#ifndef NOCALLBACK
declare function FBS_Set_MP3StreamCallback     (byval cb as FBS_BUFFERCALLBACK)  as fbsboolean
declare function FBS_Enable_MP3StreamCallback  () as fbsboolean
declare function FBS_Disable_MP3StreamCallback () as fbsboolean
#endif
#endif ' NOMP3

#ifndef NOMOD
declare function FBS_Create_MODStream          (byval Filename as string   ) as fbsboolean
declare function FBS_Play_MODStream            (byval Volume     as single=1.0, _
                                                byval Pan        as single=0.0) as fbsboolean
declare function FBS_End_MODStream             () as fbsboolean
declare function FBS_Set_MODStreamVolume       (byval Volume     as single) as fbsboolean
declare function FBS_Get_MODStreamVolume       (byval Volume     as single ptr   ) as fbsboolean
declare function FBS_Set_MODStreamPan          (byval Pan        as single) as fbsboolean
declare function FBS_Get_MODStreamPan          (byval lpPan      as single ptr   ) as fbsboolean

declare function FBS_Get_MODStreamBuffer       (byval lpBuffer   as short ptr ptr , _
                                                byval lpChannels as integer ptr   , _
                                                byval lpnSamples as integer ptr   ) as fbsboolean
#ifndef NOCALLBACK
declare function FBS_Set_MODStreamCallback     (byval cb as FBS_BUFFERCALLBACK)  as fbsboolean
declare function FBS_Enable_MODStreamCallback  () as fbsboolean
declare function FBS_Disable_MODStreamCallback () as fbsboolean
#endif
#endif ' NOMP3

#endif ' NOMP3 or NOMOD

#endif ' __FBSOUND_BI__
