#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 NOMP3
#include once "mad.bi"
#endif

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

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

declare function FBS_Init                   (nRate      as integer=44100, _
                                             nChannels  as integer=    2, _
                                             nBuffers   as integer=    3, _
                                             nFrames    as integer= 2048, _
                                             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       (lpVolume as single ptr) as fbsboolean
declare function FBS_Set_MasterVolume       (Volume   as single ) as fbsboolean

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

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

declare sub      FBS_PitchShift             (d as short ptr, _
                                             s as short ptr, _
                                             v as single   , _
                                             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       , _
                                             hWave    as integer ptr       ) as fbsboolean
#ifndef NOMP3
' create hWave from *.mp3,*.mp2,*.mp file
declare function FBS_Load_MP3File           (byval Filename as string       , _
                                             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            (nSamples as integer        , _
                                             hWave    as integer ptr       , _
                                             lpWave   as any ptr ptr      ) as fbsboolean
' playtime in MS
declare function FBS_Get_WaveLength         (hWave    as integer        , _
                                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              (hWave    as integer        , _
                                             nLoops   as integer  = 1   , _
                                             Speed    as single  = 1.0 , _
                                             Volume   as single  = 1.0 , _
                                             Pan      as single  = 0.0 , _
                                             hSound   as integer ptr = NULL) as fbsboolean

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


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

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


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

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

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

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

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

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

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

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

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

#ifndef NOMP3
' create/play local WAV,MP3,OGG
enum FBS_STREAM_TYPES
  'FBS_WAV
  FBS_MP3
  'FBS_OGG
end enum
'declare function FBS_Create_Stream          (Filename   as string,StreamID as integer ptr) as fbsboolean

declare function FBS_Create_MP3Stream       (byval Filename as string   ) as fbsboolean
declare function FBS_Play_MP3Stream         (Volume     as single=1.0, _
                                             Pan        as single=0.0) as fbsboolean

declare function FBS_Set_StreamVolume       (Volume     as single=1.0) as fbsboolean
declare function FBS_Get_StreamVolume       (Volume     as single ptr   ) as fbsboolean
declare function FBS_Set_StreamPan          (Pan        as single=0.0) as fbsboolean
declare function FBS_Get_StreamPan          (lpPan      as single ptr   ) as fbsboolean

declare function FBS_Get_StreamBuffer       (lpBuffer   as short ptr ptr , _
                                             lpChannels as integer ptr   , _
                                             lpnSamples as integer ptr   ) as fbsboolean
#ifndef NOCALLBACK
declare function FBS_Set_StreamCallback     (lpCallback as FBS_BUFFERCALLBACK)  as fbsboolean
declare function FBS_Enable_StreamCallback  () as fbsboolean
declare function FBS_Disable_StreamCallback () as fbsboolean
#endif

' optional
declare function FBS_End_MP3Stream          () as fbsboolean
#endif ' NOMP3

#endif ' __FBSOUND_BI__
