Bass problem

  • ich hab ein problem mit bass, finde den fehler aber nicht.

    [autoit]

    Case $Playliste
    $ARRPLAY = _ListViewToArray($hListView)
    $titelnummer+=1
    if $titelnummer=ubound($ARRPLAY) then $titelnummer=1
    $MusicHandle = _BASS_StreamCreateFile(False,$ARRPLAY[$titelnummer],0,0,0)
    _BASS_ChannelPlay($MusicHandle, 0)

    [/autoit]
  • ok
    listview toarray:

    Spoiler anzeigen
    [autoit]

    Func _ListViewToArray($hListView)
    If Not IsHWnd($hListView) Then $hListView = GUICtrlGetHandle($hListView)
    Local $sString = ""
    For $i = 0 To _GUICtrlListView_GetItemCount($hListView)-1
    $sString &= _GUICtrlListView_GetItemTextString($hListView, $i)
    $sString &= ";"
    Next
    $aSplit = StringSplit(StringTrimRight($sString,1), ";", 2)
    $iUB1 = UBound($aSplit)
    Dim $aRet[$iUB1][1]
    For $i = 0 To $iUB1 - 1
    $aSplit2 = StringSplit($aSplit[$i], "|", 2)
    $iUB2 = UBound($aSplit2)
    If $iUB2 > UBound($aRet,2) Then ReDim $aRet[$iUB1][$iUB2]
    For $j = 0 To $iUB2 - 1
    $aRet[$i][$j] = $aSplit2[$j]
    Next
    Next
    Return $aRet
    EndFunc ;==>_ListViewToArray

    [/autoit]
  • Hab mir erstma mit der ListViewToArray ein bsp script gebastelt.
    Egal was ich mache, UBound($ListView) = 2 aber $ListViewArray[1] in MsgBox =

    Code
    Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

    Meine Projekte:
    ClipBoard Manager (beendet)
    Gutes ClipBoard Verwaltungs Programm mit nützlichen Funktionen.

    HTML Creator (beendet)
    Nützliches Tool um schnell ein eigenes HTML Dokument zu erstellen.

  • das hat damit nix zu tun
    und ja du stehst auf dem schlauch :D

    probiere mal so

    [autoit]


    Case $Playliste
    $ARRPLAY = _ListViewToArray($hListView)
    $titelnummer+=1
    if $titelnummer=ubound($ARRPLAY) -1 then $titelnummer=0
    $MusicHandle = _BASS_StreamCreateFile(False,$ARRPLAY[$titelnummer],0,0,0)
    _BASS_ChannelPlay($MusicHandle, 0)

    [/autoit]

    du musst nämlich beachten das Arrays 0-Indexer sind

  • 0 Indexer heisst, das wenn man $Array[2] = ["1", "2"] Deklariert, dass "1" mit 0 Aufgerufen wird, und "2" mit 1.
    Oder kurz, Arrays fangen mit 0 nicht mit 1 an.

    Meine Projekte:
    ClipBoard Manager (beendet)
    Gutes ClipBoard Verwaltungs Programm mit nützlichen Funktionen.

    HTML Creator (beendet)
    Nützliches Tool um schnell ein eigenes HTML Dokument zu erstellen.

  • er spukt immer den fehler aus

    $MusicHandle = _BASS_StreamCreateFile(False,$ARRPLAY[$titelnummer],0,0,0)
    $MusicHandle = _BASS_StreamCreateFile(False,^ ERROR

  • hier:

    Spoiler anzeigen
    [autoit]

    #include <Bass.au3>
    #include <GuiListView.au3>
    #include <GDIPlus.au3>
    #include <WindowsConstants.au3>
    #include <ListViewConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StructureConstants.au3>
    #include <BassConstants.au3>
    #include <_GetFilesFolder_Rekursiv.au3>
    #NoTrayIcon
    ;===================================================================================================
    ; INRadio-Localtuner by JuraX
    ;===================================================================================================
    Global $aItem[2]
    Global $playing_state = -1
    Global $MusicHandle
    Global $titelnummer=1

    [/autoit] [autoit][/autoit] [autoit]

    #Region StartUp

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    #Region OPT
    Opt("TrayMenuMode", 1)
    #EndRegion OPT

    [/autoit] [autoit][/autoit] [autoit]

    #Region Tray
    $uottray = TrayCreateItem("Anzeigen")
    $totray = TrayCreateItem("Verstecken")
    $deleate =TrayCreateItem("Schließen")
    TraySetState()
    #EndRegion Tray

    [/autoit] [autoit][/autoit] [autoit]

    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_Res_Field=INR|Jurax-Multimedia
    #AutoIt3Wrapper_Res_Field=ProductVersion|1.3
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;Bass StartUp
    _BASS_STARTUP(@ScriptDir & "\BASS.dll")
    _BASS_Init(0, -1, 44100, 0, "")

    [/autoit] [autoit][/autoit] [autoit]

    If @error Then
    MsgBox(0, "Error", "Sound konnte nicht Initialisiert werden!")
    Exit
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    #Region Register
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
    #EndRegion

    [/autoit] [autoit][/autoit] [autoit]

    #EndRegion StartUp

    [/autoit] [autoit][/autoit] [autoit]

    #Region GUI
    $width = 380
    $height = 650
    $hwnd = GUICreate("INRadio-Localtuner", $width, $height, -1, -1, Default, $WS_EX_ACCEPTFILES)
    $Close = GUICtrlCreateButton("Close", 296, 160, 75, 25, 0)
    $Play = GUICtrlCreateButton("Play", 216, 160, 75, 25, 0)
    $Stop = GUICtrlCreateButton("Stop", 136, 160, 75, 25, 0)
    $newfile = GUICtrlCreateButton("Andere Datei", 36, 160, 75, 25, 0)
    $progress_slider = GUICtrlCreateProgress(8, 32, 236, 20)
    $slots = GUICtrlCreateLabel(GUICtrlRead($progress_slider), 8, 8, 150, 17)
    $ordner = GUICtrlCreateButton("Neue Bibliothek", 136, 330)
    GUICtrlCreateLabel("Lautstärke", 8, 190, 80, 20)
    $Volume_slider = GUICtrlCreateSlider(8, 250, 366, 80)
    $hListView = GUICtrlCreateListView('Dateiname|Pfad', 10, 375, 350, 200)
    $Playliste = GUICtrlCreateButton("Playliste abspielen",20,330)

    [/autoit] [autoit][/autoit] [autoit]

    #Region BIB Füllen
    $return = IniRead(@ScriptDir &"\INRadio.ini","Load","BIB","")
    If $return = "" Then
    $return = 'C:\Users\' & @UserName & '\Desktop'
    Endif
    $returnputin = _GetFilesFolder_Rekursiv($return, "mp3", 0)
    For $i = 1 To $returnputin[0]
    $dateiname = StringSplit($returnputin[$i], "\")
    GUICtrlCreateListViewItem($dateiname[$dateiname[0]] & "|" & $returnputin[$i], $hListView)
    Next
    #EndRegion

    [/autoit] [autoit][/autoit] [autoit]

    $rightVol = GUICtrlCreateProgress(8, 88, 236, 17)
    GUICtrlSetLimit(-1, 100, 0)
    GUICtrlCreateLabel("Right Channel Volume Level", 8, 112, 150, 17)
    $LeftVol = GUICtrlCreateProgress(8, 136, 236, 17)
    GUICtrlSetLimit(-1, 100, 0)
    GUICtrlCreateLabel("Left Channel Volume Level", 8, 64, 150, 17)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    GUISetState()
    #EndRegion GUI

    [/autoit] [autoit][/autoit] [autoit]

    #Region GDIstartup
    _GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE)
    _GDIPlus_Startup()
    $iX = 120
    $iY = 145
    $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
    $bitmap = _GDIPlus_BitmapCreateFromGraphics($iX, $iY, $graphics)
    $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
    _GDIPlus_GraphicsClear($backbuffer)
    $pen1_size = 4
    $pen1 = _GDIPlus_PenCreate(0, $pen1_size)
    $pen2_size = 4
    $pen2 = _GDIPlus_PenCreate(0, $pen2_size)
    $pen3_size = 3
    $pen3 = _GDIPlus_PenCreate(0, $pen3_size)

    [/autoit] [autoit][/autoit] [autoit]

    $fall_speed_l_threshold = 0
    $fall_speed_r_threshold = 0
    $equalizer_width = 24
    $max_l = 0
    $max_r = 0
    $fall_speed = 5
    $fire_up = 15

    [/autoit] [autoit][/autoit] [autoit]

    $fft_start = 7
    $fft_end = 127
    $fft_boost = 750
    $dy = Int($iY / ($fft_end - $fft_start)) + $pen3_size
    $dyy = Int($iY / $dy / 2)
    $eq = -1
    Dim $mpos[2]
    #EndRegion

    [/autoit] [autoit][/autoit] [autoit]

    #Region Loop

    [/autoit] [autoit][/autoit] [autoit]

    While (True)
    $Msg = GUIGetMsg()
    $tmsg = TrayGetMsg()
    Switch $tmsg

    Case $uottray
    GUISetState(@SW_SHOW)
    Case $totray
    GUISetState(@sw_hide)
    Case $deleate
    EXITF()
    EndSwitch
    Switch $Msg

    Case $close ,$GUI_EVENT_CLOSE
    EXITF()
    Case $play
    Case $Stop
    If $playing_state = 1 Then
    _BASS_ChannelStop($MusicHandle)
    $playing_state = -1
    EndIf
    Case $newfile
    If $playing_state = 1 Then
    _BASS_ChannelStop($MusicHandle)
    EndIf
    $file = FileOpenDialog("Open...", "", "MP3 Files (*.mp3)")
    $MusicHandle = _BASS_StreamCreateFile(False, $file, 0, 0, 0)
    _BASS_ChannelPlay($MusicHandle, 0)
    $playing_state = 1
    Case $Volume_slider
    SoundSetWaveVolume(GUICtrlRead($Volume_slider))
    Case $ordner
    $var = FileSelectFolder("Ordner wählen", "")
    IniWrite(@ScriptDir &"\INRadio.ini","Load","BIB",$var)
    Case $Playliste
    $ARRPLAY = _ListViewToArray($hListView)
    $titelnummer+=1
    if $titelnummer=ubound($ARRPLAY) -1 then $titelnummer=0
    $MusicHandle = _BASS_StreamCreateFile(False,$ARRPLAY[$titelnummer],0,0,0)
    _BASS_ChannelPlay($MusicHandle, 0)
    EndSwitch
    WEnd
    #EndRegion Loop

    [/autoit] [autoit][/autoit] [autoit]

    #Region Func's

    [/autoit] [autoit][/autoit] [autoit]

    Func WM_DROPFILES_FUNC($hWnd, $msgID, $wParam, $lParam);Um mehrere Dateien gleichzeitig droppen zu könen
    Local $nSize, $pFileName
    Local $nAmt = DllCall('shell32.dll', 'int', 'DragQueryFileW', 'hwnd', $wParam, 'int', 0xFFFFFFFF, 'ptr', 0, 'int', 255)

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 0 To $nAmt[0]
    $nSize = DllCall('shell32.dll', 'int', 'DragQueryFileW', 'hwnd', $wParam, 'int', $i, 'ptr', 0, 'int', 0)
    $nSize = $nSize[0] + 1
    $pFileName = DllStructCreate('wchar[' & $nSize & ']')
    DllCall('shell32.dll', 'int', 'DragQueryFileW', 'hwnd', $wParam, 'int', $i, 'ptr', DllStructGetPtr($pFileName), 'int', $nSize)
    $filename = DllStructGetData($pFileName, 1) ;Dateinamen holen
    ConsoleWrite($filename & @CRLF)
    ReDim $gaDropFiles[$i + 1]
    $gaDropFiles[$i] = $filename
    $pFileName = 0
    Next
    ;_ArrayDisplay($gaDropFiles)
    For $i = 0 To UBound($gaDropFiles) - 2 ;kommt derzeit immer noch ein leerer Eintrag am schluss
    GUICtrlCreateListViewItem(StringRegExpReplace($gaDropFiles[$i], '.*\\(.*)\..*', '$1')& "|" & $gaDropFiles[$i], $hListView)
    Next
    _GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE) ;erst wenn alle eigefügt sind
    EndFunc ;==>WM_DROPFILES_FUNC

    [/autoit] [autoit][/autoit] [autoit]

    Func Aktualisieren()
    EndFunc ;==>Aktualisieren

    [/autoit] [autoit][/autoit] [autoit]

    Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam);Für Doppelcklick Erkennung
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    If @error Then Return 0
    $code = DllStructGetData($tagNMHDR, 3)
    If $wParam = $hListView And $code = -3 And _GUICtrlListView_GetSelectedCount($hListView) > 0 Then
    For $i = 0 To _GUICtrlListView_GetItemCount($hListView)
    IF _GUICtrlListView_GetItemSelected($hListView, $i) Then
    $aItem = _GUICtrlListView_GetItemTextArray($hlistview, $i)
    ;~ In aItem[1] steht der Dateiname und in $aItem[2] der Pfad zincl. Dateinamen
    _LeftDblClick()
    EndIf
    Next
    Endif
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_NOTIF

    [/autoit] [autoit][/autoit] [autoit]

    Func _LeftDblClick()
    If $Playing_State = 1 Then
    _BASS_ChannelStop($MusicHandle)
    EndIf
    $File = $aItem[2]
    $MusicHandle = _BASS_StreamCreateFile(False, $file, 0, 0, 0)
    _BASS_ChannelPlay($musicHandle, 0)
    $playing_State =1
    EndFunc ;==>_LeftDblClick

    [/autoit] [autoit][/autoit] [autoit]

    Func Display_Vis($eq = 1)
    _GDIPlus_GraphicsClear($backbuffer, 0x80F0F0F0)
    If $eq > 0 Then
    $levels = _BASS_ChannelGetLevel($MusicHandle)
    $LeftChLvl = $leftChLvlper ;Round(_HiWord($levels) / $iY, 0)
    $RightChLvl = $rightChLvlper ;Round(_LoWord($levels) / $iY, 0)

    [/autoit] [autoit][/autoit] [autoit]

    If $max_l <= $LeftChLvl Then ;fire up higest line
    $max_l = $LeftChLvl + $fire_up
    $fall_speed_l_threshold = 20
    Else
    If $fall_speed_l_threshold <= 0 Then ;increase fall speed of highest line faster until threshold is <= 0 (second fall part)
    If $max_l > $LeftChLvl + $pen2_size * 2 Then $max_l -= $fall_speed
    Else
    $fall_speed_l_threshold -= 1 ;increase fall speed of highest line by slower until threshold is <= 0 (first fall part)
    If $max_l > $LeftChLvl + $pen2_size * 2 Then $max_l -= $fall_speed / 3
    EndIf
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    If $max_r <= $RightChLvl Then
    $max_r = $RightChLvl + $fire_up
    $fall_speed_r_threshold = 20
    Else
    If $fall_speed_r_threshold <= 0 Then
    If $max_r > $RightChLvl + $pen2_size * 2 Then $max_r -= $fall_speed
    Else
    $fall_speed_r_threshold -= 1
    If $max_r > $RightChLvl + $pen2_size * 2 Then $max_r -= $fall_speed / 3
    EndIf
    EndIf
    _BASS_ChannelGetData($MusicHandle, DllStructGetPtr($fftstruct), $BASS_DATA_FFT256)
    For $i = $fft_start To $fft_end Step $dy
    $fft = Round(DllStructGetData($fftstruct, 1, $i + 1) * $fft_boost)
    $r = (-(Cos(1.7 * $fft / 256) + 1) * 0.5) * 256
    $g = ((Cos(4 * $fft / 256) + 1) * 0.5) * 256
    $b = 0
    _GDIPlus_PenSetColor($pen3, "0xFF" & Hex($r, 2) & Hex($g, 2) & Hex($b, 2))
    _GDIPlus_GraphicsDrawLine($backbuffer, $iX / 5, $i + $dyy, $iX / 5 + $fft, $i + $dyy, $pen3)
    Next
    EndIf
    _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, $width - $iX - 10, 8, $iX, $iY)
    EndFunc ;==>Display_Vis

    [/autoit] [autoit][/autoit] [autoit]

    Func _SoundGetWaveVolume()
    Local $WaveVol = -1, $p, $ret
    Const $MMSYSERR_NOERROR = 0
    $p = DllStructCreate ("dword")
    If @error Then
    SetError(2)
    Return -2
    EndIf
    $ret = DllCall("winmm.dll", "long", "waveOutGetVolume", "long", -1, "long", DllStructGetPtr ($p))
    If ($ret[0] == $MMSYSERR_NOERROR) Then
    $WaveVol = Round(Dec(StringRight(Hex(DllStructGetData ($p, 1), 8), 4)) / 0xFFFF * 100)
    Else
    SetError(1)
    EndIf
    $p=""
    Return $WaveVol
    EndFunc ;==>_SoundGetWaveVolume

    [/autoit] [autoit][/autoit] [autoit]

    Func EXITF()
    _BASS_Stop()
    _BASS_Free()
    _GDIPlus_PenDispose($pen1)
    _GDIPlus_PenDispose($pen2)
    _GDIPlus_PenDispose($pen3)
    _GDIPlus_BitmapDispose($bitmap)
    _GDIPlus_GraphicsDispose($graphics)
    _GDIPlus_GraphicsDispose($backbuffer)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>EXITF

    [/autoit] [autoit][/autoit] [autoit]

    Func _ListViewToArray($hListView)
    If Not IsHWnd($hListView) Then $hListView = GUICtrlGetHandle($hListView)
    Local $sString = ""
    For $i = 0 To _GUICtrlListView_GetItemCount($hListView)-1
    $sString &= _GUICtrlListView_GetItemTextString($hListView, $i)
    $sString &= ";"
    Next
    $aSplit = StringSplit(StringTrimRight($sString,1), ";", 2)
    $iUB1 = UBound($aSplit)
    Dim $aRet[$iUB1][1]
    For $i = 0 To $iUB1 - 1
    $aSplit2 = StringSplit($aSplit[$i], "|", 2)
    $iUB2 = UBound($aSplit2)
    If $iUB2 > UBound($aRet,2) Then ReDim $aRet[$iUB1][$iUB2]
    For $j = 0 To $iUB2 - 1
    $aRet[$i][$j] = $aSplit2[$j]
    Next
    Next
    Return $aRet
    EndFunc ;==>_ListViewToArray
    #EndRegion

    [/autoit]
  • prüfe mal die Größe mit Ubound($ARRPLAY)

    also

    [autoit]


    MsgBox(0,0,"Array:" & "Ubound($ARRPLAY) -1 & @crlf & "String:" & $titelnummer)

    [/autoit]


    und wenn die werte gleich bzw. String kleiner ist dasnn ist alles Richtig

    //Edit:JuraX hänge mal bitte alles an was nicht Standart an includes ist in Autoit,habe nämlich kb alles rauszusuchen

  • hier

    [autoit]

    >"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\Public\Desktop\TestTemp\Localtuner.au3"
    C:\Users\Public\Desktop\TestTemp\Localtuner.au3 (168) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
    $MusicHandle = _BASS_StreamCreateFile(False,$ARRPLAY[$titelnummer],0,0,0)
    $MusicHandle = _BASS_StreamCreateFile(False,^ ERROR
    >Exit code: 1 Time: 6.709

    [/autoit]