VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Bass"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Public Enum BassErrorConsts
BASS_OK = 0               'all is OK
BASS_ERROR_MEM = 1        'memory error
BASS_ERROR_FILEOPEN = 2   'can't open the file
BASS_ERROR_DRIVER = 3     'can't find a free sound driver
BASS_ERROR_BUFLOST = 4    'the sample buffer was lost
BASS_ERROR_HANDLE = 5     'invalid handle
BASS_ERROR_FORMAT = 6     'unsupported sample format
BASS_ERROR_POSITION = 7   'invalid position
BASS_ERROR_INIT = 8       'BASS_Init has not been successfully called
BASS_ERROR_START = 9      'BASS_Start has not been successfully called
BASS_ERROR_ALREADY = 14   'already initialized/paused/whatever
BASS_ERROR_NOCHAN = 18    'can't get a free channel
BASS_ERROR_ILLType = 19   'an illegal Type was specified
BASS_ERROR_ILLPARAM = 20  'an illegal parameter was specified
BASS_ERROR_NO3D = 21      'no 3D support
BASS_ERROR_NOEAX = 22     'no EAX support
BASS_ERROR_DEVICE = 23    'illegal device number
BASS_ERROR_NOPLAY = 24    'not playing
BASS_ERROR_FREQ = 25      'illegal sample rate
BASS_ERROR_NOTFILE = 27   'the stream is not a file stream
BASS_ERROR_NOHW = 29      'no hardware voices available
BASS_ERROR_EMPTY = 31     'the MOD music has no sequence data
BASS_ERROR_NONET = 32     'no internet connection could be opened
BASS_ERROR_CREATE = 33    'couldn't create the file
BASS_ERROR_NOFX = 34      'effects are not available
BASS_ERROR_NOTAVAIL = 37  'requested data is not available
BASS_ERROR_DECODE = 38    'the channel is a "decoding channel"
BASS_ERROR_DX = 39        'a sufficient DirectX version is not installed
BASS_ERROR_TIMEOUT = 40   'connection timedout
BASS_ERROR_FILEFORM = 41  'unsupported file format
BASS_ERROR_SPEAKER = 42   'unavailable speaker
BASS_ERROR_VERSION = 43   'invalid BASS version (used by add-ons)
BASS_ERROR_CODEC = 44     'codec is not available/supported
BASS_ERROR_ENDED = 45     'the channel/file has ended
BASS_ERROR_BUSY = 46      'the device is busy
BASS_ERROR_UNKNOWN = -1   'some other mystery problem
End Enum

Public Enum BassDeviceFlagsConst
BASS_DEVICE_DEFAULT = 0
BASS_DEVICE_8BITS = 1     'use 8 bit resolution, else 16 bit
BASS_DEVICE_MONO = 2      'use mono, else stereo
BASS_DEVICE_3D = 4        'enable 3D functionality
BASS_DEVICE_LATENCY = 256 'calculate device latency (BASS_INFO struct)
BASS_DEVICE_CPSPEAKERS = 1024 'detect speakers via Windows control panel
BASS_DEVICE_SPEAKERS = 2048 'force enabling of speaker assignment
BASS_DEVICE_NOSPEAKER = 4096 'ignore speaker arrangement
BASS_DEVIDE_DMIX = 8192
BASS_DEVICE_FREQ = 16384
End Enum

    Public Type BASS_DEVICEINFO
        name As Long          ' description
        driver As Long        ' driver
        Flags As Long
    End Type
    
    Private Type GUID
        Data1 As Long
        Data2 As Integer
        Data3 As Integer
        Data4() As Byte
    End Type
    
        
    Public Type BASS_INFO
        Flags As Long         ' device capabilities (DSCAPS_xxx flags)
        hwsize As Long        ' size of total device hardware memory
        hwfree As Long        ' size of free device hardware memory
        freesam As Long       ' number of free sample slots in the hardware
        free3d As Long        ' number of free 3D sample slots in the hardware
        minrate As Long       ' min sample rate supported by the hardware
        maxrate As Long       ' max sample rate supported by the hardware
        eax As Long           ' device supports EAX? (always BASSFALSE if BASS_DEVICE_3D was not used)
        minbuf As Long        ' recommended minimum buffer length in ms (requires BASS_DEVICE_LATENCY)
        dsver As Long         ' DirectSound version
        latency As Long       ' delay (in ms) before start of playback (requires BASS_DEVICE_LATENCY)
        initflags As Long     ' BASS_Init "flags" parameter
        speakers As Long      ' number of speakers available
        Freq As Long          ' current output rate (OSX only)
    End Type
    
Public Enum BassBooleanConst
 BASS_TRUE = 1   'Use this instead of VB Booleans
 BASS_FALSE = 0
End Enum
    
Private mGUID As GUID
Private mHandle As Long
Private dHandle As Long

Private Declare Function BASS_ErrorGetCode Lib "bass.dll" () As Long
Private Declare Function BASS_GetDeviceInfo Lib "bass.dll" (ByVal Device As Long, ByRef info As BASS_DEVICEINFO) As Long
Private Declare Function BASS_Init Lib "bass.dll" (ByVal Device As Long, ByVal Freq As Long, ByVal Flags As Long, ByVal win As Long, ByVal Clsid As Long) As Long
Private Declare Function BASS_SetDevice Lib "bass.dll" (ByVal Device As Long) As Long
Private Declare Function BASS_GetDevice Lib "bass.dll" () As Long
Private Declare Function BASS_Free Lib "bass.dll" () As Long
Private Declare Function BASS_GetDSoundObject Lib "bass.dll" (ByVal object As Long) As Long
Private Declare Function BASS_GetInfo Lib "bass.dll" (ByRef info As BASS_INFO) As Long
Private Declare Function BASS_Update Lib "bass.dll" (ByVal legnth As Long) As Long
Private Declare Function BASS_GetCPU Lib "bass.dll" () As Single
Private Declare Function BASS_Start Lib "bass.dll" () As Long
Private Declare Function BASS_Stop Lib "bass.dll" () As Long
Private Declare Function BASS_Pause Lib "bass.dll" () As Long
Private Declare Function BASS_SetVolume Lib "bass.dll" (ByVal volume As Single) As Long
Private Declare Function BASS_GetVolume Lib "bass.dll" () As Single

Function ErrorGetCode() As BassErrorConsts
ErrorGetCode = BASS_ErrorGetCode
End Function

Function Free() As Boolean
Free = BASS_Free
End Function

Function GetCPU() As Single
GetCPU = BASS_GetCPU
End Function

Function GetDevice() As Long
GetDevice = BASS_GetDevice
End Function

Function GetDeviceInfo(Device As Long) As BASS_DEVICEINFO
Dim info As BASS_DEVICEINFO
Dim bl As Boolean
bl = BASS_GetDeviceInfo(Device, info)
GetDeviceInfo = info
End Function

Sub GetDSoundObject(Options As Long)
BASS_GetDSoundObject Options
End Sub

Function GetInfo() As BASS_INFO
Dim info As BASS_INFO
Dim bl As Boolean
bl = BASS_GetInfo(info)
GetInfo = info
End Function

Function GetVersion() As Long
GetVersion = BASS_GetVersion
End Function

Function GetVolume() As Single
GetVolume = BASS_GetVolume
End Function

Function Initialize(Optional Device As Integer = -1, Optional Freq As Long = 44000, Optional Flags As BassDeviceFlagsConst = 0, Optional Hwnd As Long = 0, Optional Clsid As Long = 0) As Boolean
Dim bl As Boolean
mHandle = Hwnd
dHandle = Device
Init = BASS_Init(Device, Freq, Flags, Hwnd, 0)
End Function

Function Pause() As Boolean
Pause = BASS_Pause
End Function

Function SetDevice(Device As Long) As Boolean
SetDevice = BASS_SetDevice(Device)
End Function

Function SetVolume(volume As Single) As Boolean
SetVolume = BASS_SetVolume(volume)
End Function

Function Start() As Boolean
Start = BASS_Start()
End Function

Function Stop_() As Boolean
Stop_ = BASS_Stop()
End Function

Function Update(Length As Long) As Boolean
Update = BASS_Update(Length)
End Function

Property Get Hwnd() As Long
Hwnd = mHandle
End Property

Property Get DeviceHandle() As Long
DeviceHandle = dHandle
End Property
