Jump to content

Problems with bass.dll


EnrMa
 Share

Recommended Posts

Hello AutoIT community,

I'm new to this forum. I'm working with Autoit for at least 2 years.

I want to write a small audioplayer tool in Autoit with the bass.dll from un4seen .

Here is an extract/example for my problem:

#include <Array.au3>
$BASS = DllOpen("bass.dll")
LOGGING($BASS,"open")
$ret = DllCall("bass.dll", "int", "BASS_Init", "int", "-1", "dword", "44100","dword", "0","hwnd", "0","ptr" ,"0")
LOGGING($ret,"init")
$ret = DllCall("bass.dll", "int","BASS_SetConfig","dword","BASS_CONFIG_BUFFER","dword","5000")
LOGGING($ret,"buffer to 5000 ms")
$leftstreamfile = Bass_Streamcreatefile(@ScriptDir & "\test.mp3")
LOGGING($leftstreamfile,"streamcreate")
$ret = Bass_channelplay($leftstreamfile[0])
LOGGING($ret,"play")
$fx = DllCall("bass.dll","int","BASS_ChannelSetFX","dword",$leftstreamfile[0],"int","BASS_FX_DX8_PARAMEQ","int","1")
LOGGING($fx,"set fx")
    $stra        = "float[128];float[128];float[128]"
    $a          = DllStructCreate($stra)
    DllStructSetData($a,1,800)
    DllStructSetData($a,2,1)
    DllStructSetData($a,3,10)
$ret = DllCall("bass.dll", "int", "BASS_ChannelPause", "int",$leftstreamfile[0])
LOGGING($ret,"pause")
$ret =DllCall("bass.dll","int","BASS_FXSetParameters","int",$fx[0],"ptr",DllStructGetptr($a))
LOGGING($ret,"set EQ-")
$ret = Bass_channelplay($leftstreamfile[0])
LOGGING($ret,"play")
MsgBox(0,"","")
DllCall("bass.dll", "int", "BASS_Free")
Sleep(3000)
Exit

Func Bass_Streamcreatefile($file_id)
       $File_Name = DllStructCreate("char[255]")
    DllStructSetData($File_Name, 1, $file_id)
$ret=DllCall("bass.dll","int","BASS_StreamCreateFile","int","False","ptr",DllStructGetPtr($File_Name),"int64","0","int64","0","dword","BASS_STREAM_PRESCAN/DECODE")
    If @error Then $ret="error"
    Return $ret
Endfunc

Func Bass_Channelplay($CHANNEL)
    $ret = DllCall("bass.dll", "int", "BASS_ChannelPlay", "int", $CHANNEL, "int", 0)
    If @error Then $ret="error"
    Return $ret
Endfunc

Func LOGGING($text,$other="")
    $text = _ArrayToString($text," * ")
    ConsoleWrite(@HOUR & ":" & @MIN & "," & @SEC & "other :" & $other & "Array: " & $text & "  -Error:" & Bass_errorgetcode() @CRLF)
EndFunc

Func Bass_errorgetcode()
    $ret = DllCall("bass.dll", "int", "BASS_ErrorGetCode")
    If @error Then $ret="error"
    $ret = Bass_error($ret[0])
    Return $ret
Endfunc


Func Bass_error($code)
Local $array[35] , $ret = "0"
$array[0] = "0*BASS_OK"
$array[1] = "1*BASS_ERROR_MEM"
$array[2] = "2*BASS_ERROR_FILEOPEN"
$array[3] = "3*BASS_ERROR_DRIVER"
$array[4] = "4*BASS_ERROR_BUFLOST"
$array[5] = "5*BASS_ERROR_HANDLE"
$array[6] = "6*BASS_ERROR_FORMAT"
$array[7] = "7*BASS_ERROR_POSITION"
$array[8] = "8*BASS_ERROR_INIT"
$array[9] = "9*BASS_ERROR_START"
$array[10] = "14*BASS_ERROR_ALREADY"
$array[11] = "18*BASS_ERROR_NOCHAN"
$array[12] = "19*BASS_ERROR_ILLTYPE"
$array[13] = "20*BASS_ERROR_ILLPARAM"
$array[14] = "21*BASS_ERROR_NO3D"
$array[15] = "22*BASS_ERROR_NOEAX"
$array[16] = "23*BASS_ERROR_DEVICE"
$array[17] = "24*BASS_ERROR_NOPLAY"
$array[18] = "25*BASS_ERROR_FREQ"
$array[19] = "27*BASS_ERROR_NOTFILE"
$array[20] = "29*BASS_ERROR_NOHW"
$array[21] = "31*BASS_ERROR_EMPTY"
$array[22] = "32*BASS_ERROR_NONET"
$array[23] = "33*BASS_ERROR_CREATE"
$array[24] = "34*BASS_ERROR_NOFX"
$array[25] = "37*BASS_ERROR_NOTAVAIL"
$array[26] = "38*BASS_ERROR_DECODE"
$array[27] = "39*BASS_ERROR_DX"
$array[28] = "40*BASS_ERROR_TIMEOUT"
$array[29] = "41*BASS_ERROR_FILEFORM"
$array[30] = "42*BASS_ERROR_SPEAKER"
$array[31] = "43*BASS_ERROR_VERSION"
$array[32] = "44*BASS_ERROR_CODEC"
$array[33] = "45*BASS_ERROR_ENDED"
$array[34] = "-1*BASS_ERROR_UNKNOWN"
For $i = 0 to 34
    $split = StringSplit($array[$i],"*")
    If $split[1] = $code Then
        $ret = $split[2]
        ExitLoop
    EndIf
Next
return $ret
EndFunc

The Problem is in $ret =DllCall("bass.dll","int","BASS_FXSetParameters","int",$fx[0],"ptr",DllStructGetptr($a))

I always get a BASS_ERROR_ILLPARAM . BASS_FX_DX8_PARAMEQ needs 3 floats. When I add a "ptr" then Autoit crashes with the DllCall.

Can anyone help me please ?

Enrico

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...