VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Sample"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Public Enum BassMusicConst
BASS_MUSIC_FLOAT = BASS_SAMPLE_FLOAT
BASS_MUSIC_MONO = BASS_SAMPLE_MONO
BASS_MUSIC_LOOP = BASS_SAMPLE_LOOP
BASS_MUSIC_3D = BASS_SAMPLE_3D
BASS_MUSIC_FX = BASS_SAMPLE_FX
BASS_MUSIC_AUTOFREE = BASS_STREAM_AUTOFREE
BASS_MUSIC_DECODE = BASS_STREAM_DECODE
BASS_MUSIC_PRESCAN = BASS_STREAM_PRESCAN ' calculate playback length
BASS_MUSIC_CALCLEN = BASS_MUSIC_PRESCAN
BASS_MUSIC_RAMP = &H200        ' normal ramping
BASS_MUSIC_RAMPS = &H400       ' sensitive ramping
BASS_MUSIC_SURROUND = &H800    ' surround sound
BASS_MUSIC_SURROUND2 = &H1000  ' surround sound (mode 2)
BASS_MUSIC_FT2MOD = &H2000     ' play .MOD as FastTracker 2 does
BASS_MUSIC_PT1MOD = &H4000     ' play .MOD as ProTracker 1 does
BASS_MUSIC_NONINTER = &H10000  ' non-interpolated sample mixing
BASS_MUSIC_SINCINTER = &H800000 ' sinc interpolated sample mixing
BASS_MUSIC_POSRESET = 32768  ' stop all notes when moving position
BASS_MUSIC_POSRESETEX = &H400000 ' stop all notes and reset bmp/etc when moving position
BASS_MUSIC_STOPBACK = &H80000  ' stop the music on a backwards jump effect
BASS_MUSIC_NOSAMPLE = &H100000 ' don't load the samples
End Enum
    
    
    Public Type BASS_SAMPLE
        Freq As Long          ' default playback rate
        Volume As Single      ' default volume (0-100)
        pan As Single         ' default pan (-100=left, 0=middle, 100=right)
        Flags As Long         ' BASS_SAMPLE_xxx flags
        Length As Long        ' length (in samples, not bytes)
        Max As Long           ' maximum simultaneous playbacks
        origres As Long       ' original resolution
        Chans As Long         ' number of channels
        mingap As Long        ' minimum gap (ms) between creating channels
        mode3d As Long        ' BASS_3DMODE_xxx mode
        mindist As Single     ' minimum distance
        MAXDIST As Single     ' maximum distance
        iAngle As Long        ' angle of inside projection cone
        oAngle As Long        ' angle of outside projection cone
        OutVol As Single      ' delta-volume outside the projection cone
        vam As Long           ' voice allocation/management flags (BASS_VAM_xxx)
        Priority As Long      ' priority (0=lowest, &Hffffffff=highest)
    End Type

Private Declare Function BASS_SampleLoad64 Lib "bass.dll" Alias "BASS_SampleLoad" (ByVal mem As Long, ByVal file As Any, ByVal Offset As Long, ByVal offsethigh As Long, ByVal Length As Long, ByVal Max As Long, ByVal Flags As Long) As Long
Private Declare Function BASS_SampleCreate Lib "bass.dll" (ByVal Length As Long, ByVal Freq As Long, ByVal Chans As Long, ByVal Max As Long, ByVal Flags As Long) As Long
Private Declare Function BASS_SampleFree Lib "bass.dll" (ByVal Handle As Long) As Long
Private Declare Function BASS_SampleSetData Lib "bass.dll" (ByVal Handle As Long, ByRef Buffer As Any) As Long
Private Declare Function BASS_SampleGetData Lib "bass.dll" (ByVal Handle As Long, ByRef Buffer As Any) As Long
Private Declare Function BASS_SampleGetInfo Lib "bass.dll" (ByVal Handle As Long, ByRef Info As BASS_SAMPLE) As Long
Private Declare Function BASS_SampleSetInfo Lib "bass.dll" (ByVal Handle As Long, ByRef Info As BASS_SAMPLE) As Long
Private Declare Function BASS_SampleGetChannel Lib "bass.dll" (ByVal Handle As Long, ByVal OnlyNew As Long) As Long
Private Declare Function BASS_SampleGetChannels Lib "bass.dll" (ByVal Handle As Long, ByRef Channels As Long) As Long
Private Declare Function BASS_SampleStop Lib "bass.dll" (ByVal Handle As Long) As Long

Private mHandle As Long

Sub Create(Length As Long, Freq As Long, Chans As Long, Max As Long, Flags As BassSampleConst)
mHandle = BASS_SampleCreate(Length, Freq, Chans, Max, Flags)
End Sub

Function Free() As Boolean
Free = BASS_SampleFree(mHandle)
End Function

Function GetChannelHandle(OnlyNew As BassBooleanConst) As Long
GetChannelHandle = BASS_SampleGetChannel(mHandle, OnlyNew)
End Function

Function GetChannelsHandle() As Long
Dim chs As Long
Dim tmp As Long
tmp = BASS_SampleGetChannels(mHandle, chs)
GetChannelsHandle = chs
End Function

Function GetData()
Dim buff
Dim tmp As Boolean
tmp = BASS_SampleGetData(mHandle, buff)
GetData = buff
End Function

Function GetInfo() As BASS_SAMPLE
Dim tmp As BASS_SAMPLE
Dim bl As Boolean
bl = BASS_SampleGetInfo(mHandle, tmp)
GetInfo = tmp
End Function

Sub Load(Filename As String, Optional Offset As Long = 0, Optional Length As Long = 0, Optional Max As Long = 1, Optional Flags As BassSampleConst = 0)
Dim file As Long
file = StrPtr(Filename)
mHandle = BASS_SampleLoad(BASS_FALSE, file, Offset, Length, Max, Flags)
End Sub

Function SetData(ByRef Buffer) As Boolean
SetData = BASS_SampleSetData(mHandle, Buffer)
End Function

Function SetInfo(ByRef Info As BASS_SAMPLE) As Boolean
SetInfo = BASS_SampleSetInfo(mHandle, Info)
End Function

Function Stop_() As Boolean
Stop_ = BASS_SampleStop(mHandle)
End Function

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

Private Function BASS_SampleLoad(ByVal mem As Long, ByVal file As Long, ByVal Offset As Long, ByVal Length As Long, ByVal Max As Long, ByVal Flags As Long) As Long
BASS_SampleLoad = BASS_SampleLoad64(mem, file, Offset, 0, Length, Max, Flags Or BASS_UNICODE)
End Function
